Skip to content

Commit 57e7a28

Browse files
jannickjdwrensha
authored andcommitted
redesign static lifetime into generic lifetime requirements for functions/data
1 parent e2f8f4c commit 57e7a28

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

capnp-futures/src/read_stream.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,21 @@ use capnp::{Error, message};
2828

2929
async fn read_next_message<R>(mut reader: R, options: message::ReaderOptions)
3030
-> Result<(R, Option<message::Reader<capnp::serialize::OwnedSegments>>), Error>
31-
where R: AsyncRead + Unpin + 'static
31+
where R: AsyncRead + Unpin
3232
{
3333
let m = crate::serialize::read_message(&mut reader, options).await?;
3434
Ok((reader, m))
3535
}
3636

3737
#[must_use = "streams do nothing unless polled"]
38-
pub struct ReadStream<R> where R: AsyncRead + Unpin + 'static {
38+
pub struct ReadStream<'a, R> where R: AsyncRead + Unpin {
3939
options: message::ReaderOptions,
40-
read: Pin<Box<dyn Future<Output=Result<(R, Option<message::Reader<capnp::serialize::OwnedSegments>>), Error>> + 'static>>,
40+
read: Pin<Box<dyn Future<Output=Result<(R, Option<message::Reader<capnp::serialize::OwnedSegments>>), Error>> + 'a >>,
4141
}
4242

43-
impl <R> Unpin for ReadStream<R> where R: AsyncRead + Unpin + 'static {}
43+
impl <'a, R> Unpin for ReadStream<'a, R> where R: AsyncRead + Unpin {}
4444

45-
impl <R> ReadStream<R> where R: AsyncRead + Unpin + 'static {
45+
impl <'a, R> ReadStream<'a, R> where R: AsyncRead + Unpin + 'a {
4646
pub fn new(reader: R, options: message::ReaderOptions) -> Self
4747
{
4848
ReadStream {
@@ -52,7 +52,7 @@ impl <R> ReadStream<R> where R: AsyncRead + Unpin + 'static {
5252
}
5353
}
5454

55-
impl <R> Stream for ReadStream<R> where R: AsyncRead + Unpin + 'static {
55+
impl <'a, R> Stream for ReadStream<'a, R> where R: AsyncRead + Unpin + 'a {
5656
type Item = Result<message::Reader<capnp::serialize::OwnedSegments>, Error>;
5757

5858
fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<Option<Self::Item>> {

capnp-futures/src/write_queue.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ impl <M> Clone for Sender<M> where M: AsOutputSegments {
4242
}
4343

4444
/// Creates a new WriteQueue that wraps the given writer.
45-
pub fn write_queue<W, M>(mut writer: W) -> (Sender<M>, impl Future<Output=Result<(),Error>> + 'static)
46-
where W: AsyncWrite + Unpin + 'static, M: AsOutputSegments + 'static
45+
pub fn write_queue<W, M>(mut writer: W) -> (Sender<M>, impl Future<Output=Result<(),Error>> )
46+
where W: AsyncWrite + Unpin , M: AsOutputSegments
4747
{
4848
let (tx, mut rx) = futures::channel::mpsc::unbounded();
4949

@@ -69,10 +69,10 @@ pub fn write_queue<W, M>(mut writer: W) -> (Sender<M>, impl Future<Output=Result
6969
(sender, queue)
7070
}
7171

72-
impl <M> Sender<M> where M: AsOutputSegments + 'static {
72+
impl <M> Sender<M> where M: AsOutputSegments {
7373
/// Enqueues a message to be written. The returned future resolves once the write
7474
/// has completed.
75-
pub fn send(&mut self, message: M) -> impl Future<Output=Result<M,Error>> + Unpin + 'static {
75+
pub fn send(&mut self, message: M) -> impl Future<Output=Result<M,Error>> + Unpin {
7676
let (complete, oneshot) = oneshot::channel();
7777

7878
let _ = self.sender.unbounded_send(Item::Message(message, complete));
@@ -89,7 +89,7 @@ impl <M> Sender<M> where M: AsOutputSegments + 'static {
8989
/// Commands the queue to stop writing messages once it is empty. After this method has been called,
9090
/// any new calls to `send()` will return a future that immediately resolves to an error.
9191
/// If the passed-in `result` is an error, then the `WriteQueue` will resolve to that error.
92-
pub fn terminate(&mut self, result: Result<(), Error>) -> impl Future<Output=Result<(),Error>> + Unpin + 'static {
92+
pub fn terminate(&mut self, result: Result<(), Error>) -> impl Future<Output=Result<(),Error>> + Unpin {
9393
let (complete, receiver) = oneshot::channel();
9494

9595
let _ = self.sender.unbounded_send(Item::Done(result, complete));

0 commit comments

Comments
 (0)