#[repr(transparent)]pub struct Pin<P> { /* private fields */ }
unstable
only.Expand description
A pinned pointer.
This is a wrapper around a kind of pointer which makes that pointer “pin” its
value in place, preventing the value referenced by that pointer from being moved
unless it implements Unpin
.
See the pin
module documentation for an explanation of pinning.
Implementations
sourceimpl<P> Pin<P> where
P: Deref,
<P as Deref>::Target: Unpin,
impl<P> Pin<P> where
P: Deref,
<P as Deref>::Target: Unpin,
const: unstable · sourcepub fn new(pointer: P) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn new(pointer: P) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
1.39.0 (const: unstable) · sourcepub fn into_inner(pin: Pin<P>) -> P
pub fn into_inner(pin: Pin<P>) -> P
Unwraps this Pin<P>
returning the underlying pointer.
This requires that the data inside this Pin
is Unpin
so that we
can ignore the pinning invariants when unwrapping it.
sourceimpl<P> Pin<P> where
P: Deref,
impl<P> Pin<P> where
P: Deref,
const: unstable · sourcepub unsafe fn new_unchecked(pointer: P) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub unsafe fn new_unchecked(pointer: P) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Construct a new Pin<P>
around a reference to some data of a type that
may or may not implement Unpin
.
If pointer
dereferences to an Unpin
type, Pin::new
should be used
instead.
Safety
This constructor is unsafe because we cannot guarantee that the data
pointed to by pointer
is pinned, meaning that the data will not be moved or
its storage invalidated until it gets dropped. If the constructed Pin<P>
does
not guarantee that the data P
points to is pinned, that is a violation of
the API contract and may lead to undefined behavior in later (safe) operations.
By using this method, you are making a promise about the P::Deref
and
P::DerefMut
implementations, if they exist. Most importantly, they
must not move out of their self
arguments: Pin::as_mut
and Pin::as_ref
will call DerefMut::deref_mut
and Deref::deref
on the pinned pointer
and expect these methods to uphold the pinning invariants.
Moreover, by calling this method you promise that the reference P
dereferences to will not be moved out of again; in particular, it
must not be possible to obtain a &mut P::Target
and then
move out of that reference (using, for example mem::swap
).
For example, calling Pin::new_unchecked
on an &'a mut T
is unsafe because
while you are able to pin it for the given lifetime 'a
, you have no control
over whether it is kept pinned once 'a
ends:
use std::mem;
use std::pin::Pin;
fn move_pinned_ref<T>(mut a: T, mut b: T) {
unsafe {
let p: Pin<&mut T> = Pin::new_unchecked(&mut a);
// This should mean the pointee `a` can never move again.
}
mem::swap(&mut a, &mut b);
// The address of `a` changed to `b`'s stack slot, so `a` got moved even
// though we have previously pinned it! We have violated the pinning API contract.
}
A value, once pinned, must remain pinned forever (unless its type implements Unpin
).
Similarly, calling Pin::new_unchecked
on an Rc<T>
is unsafe because there could be
aliases to the same data that are not subject to the pinning restrictions:
use std::rc::Rc;
use std::pin::Pin;
fn move_pinned_rc<T>(mut x: Rc<T>) {
let pinned = unsafe { Pin::new_unchecked(Rc::clone(&x)) };
{
let p: Pin<&T> = pinned.as_ref();
// This should mean the pointee can never move again.
}
drop(pinned);
let content = Rc::get_mut(&mut x).unwrap();
// Now, if `x` was the only reference, we have a mutable reference to
// data that we pinned above, which we could use to move it as we have
// seen in the previous example. We have violated the pinning API contract.
}
sourcepub fn as_ref(&self) -> Pin<&<P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn as_ref(&self) -> Pin<&<P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Gets a pinned shared reference from this pinned pointer.
This is a generic method to go from &Pin<Pointer<T>>
to Pin<&T>
.
It is safe because, as part of the contract of Pin::new_unchecked
,
the pointee cannot move after Pin<Pointer<T>>
got created.
“Malicious” implementations of Pointer::Deref
are likewise
ruled out by the contract of Pin::new_unchecked
.
1.39.0 (const: unstable) · sourcepub unsafe fn into_inner_unchecked(pin: Pin<P>) -> P
pub unsafe fn into_inner_unchecked(pin: Pin<P>) -> P
Unwraps this Pin<P>
returning the underlying pointer.
Safety
This function is unsafe. You must guarantee that you will continue to
treat the pointer P
as pinned after you call this function, so that
the invariants on the Pin
type can be upheld. If the code using the
resulting P
does not continue to maintain the pinning invariants that
is a violation of the API contract and may lead to undefined behavior in
later (safe) operations.
If the underlying data is Unpin
, Pin::into_inner
should be used
instead.
sourceimpl<P> Pin<P> where
P: DerefMut,
impl<P> Pin<P> where
P: DerefMut,
sourcepub fn as_mut(&mut self) -> Pin<&mut <P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn as_mut(&mut self) -> Pin<&mut <P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Gets a pinned mutable reference from this pinned pointer.
This is a generic method to go from &mut Pin<Pointer<T>>
to Pin<&mut T>
.
It is safe because, as part of the contract of Pin::new_unchecked
,
the pointee cannot move after Pin<Pointer<T>>
got created.
“Malicious” implementations of Pointer::DerefMut
are likewise
ruled out by the contract of Pin::new_unchecked
.
This method is useful when doing multiple calls to functions that consume the pinned type.
Example
use std::pin::Pin;
impl Type {
fn method(self: Pin<&mut Self>) {
// do something
}
fn call_method_twice(mut self: Pin<&mut Self>) {
// `method` consumes `self`, so reborrow the `Pin<&mut Self>` via `as_mut`.
self.as_mut().method();
self.as_mut().method();
}
}
sourceimpl<'a, T> Pin<&'a T> where
T: ?Sized,
impl<'a, T> Pin<&'a T> where
T: ?Sized,
sourcepub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
F: FnOnce(&T) -> &U,
U: ?Sized,
pub unsafe fn map_unchecked<U, F>(self, func: F) -> Pin<&'a U>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
F: FnOnce(&T) -> &U,
U: ?Sized,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Constructs a new pin by mapping the interior value.
For example, if you wanted to get a Pin
of a field of something,
you could use this to get access to that field in one line of code.
However, there are several gotchas with these “pinning projections”;
see the pin
module documentation for further details on that topic.
Safety
This function is unsafe. You must guarantee that the data you return will not move so long as the argument value does not move (for example, because it is one of the fields of that value), and also that you do not move out of the argument you receive to the interior function.
const: unstable · sourcepub fn get_ref(self) -> &'a T
pub fn get_ref(self) -> &'a T
Gets a shared reference out of a pin.
This is safe because it is not possible to move out of a shared reference.
It may seem like there is an issue here with interior mutability: in fact,
it is possible to move a T
out of a &RefCell<T>
. However, this is
not a problem as long as there does not also exist a Pin<&T>
pointing
to the same data, and RefCell<T>
does not let you create a pinned reference
to its contents. See the discussion on “pinning projections” for further
details.
Note: Pin
also implements Deref
to the target, which can be used
to access the inner value. However, Deref
only provides a reference
that lives for as long as the borrow of the Pin
, not the lifetime of
the Pin
itself. This method allows turning the Pin
into a reference
with the same lifetime as the original Pin
.
sourceimpl<'a, T> Pin<&'a mut T> where
T: ?Sized,
impl<'a, T> Pin<&'a mut T> where
T: ?Sized,
const: unstable · sourcepub fn into_ref(self) -> Pin<&'a T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn into_ref(self) -> Pin<&'a T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Converts this Pin<&mut T>
into a Pin<&T>
with the same lifetime.
const: unstable · sourcepub fn get_mut(self) -> &'a mut T where
T: Unpin,
pub fn get_mut(self) -> &'a mut T where
T: Unpin,
Gets a mutable reference to the data inside of this Pin
.
This requires that the data inside this Pin
is Unpin
.
Note: Pin
also implements DerefMut
to the data, which can be used
to access the inner value. However, DerefMut
only provides a reference
that lives for as long as the borrow of the Pin
, not the lifetime of
the Pin
itself. This method allows turning the Pin
into a reference
with the same lifetime as the original Pin
.
const: unstable · sourcepub unsafe fn get_unchecked_mut(self) -> &'a mut T
pub unsafe fn get_unchecked_mut(self) -> &'a mut T
Gets a mutable reference to the data inside of this Pin
.
Safety
This function is unsafe. You must guarantee that you will never move
the data out of the mutable reference you receive when you call this
function, so that the invariants on the Pin
type can be upheld.
If the underlying data is Unpin
, Pin::get_mut
should be used
instead.
sourcepub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
F: FnOnce(&mut T) -> &mut U,
U: ?Sized,
pub unsafe fn map_unchecked_mut<U, F>(self, func: F) -> Pin<&'a mut U>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
F: FnOnce(&mut T) -> &mut U,
U: ?Sized,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Construct a new pin by mapping the interior value.
For example, if you wanted to get a Pin
of a field of something,
you could use this to get access to that field in one line of code.
However, there are several gotchas with these “pinning projections”;
see the pin
module documentation for further details on that topic.
Safety
This function is unsafe. You must guarantee that the data you return will not move so long as the argument value does not move (for example, because it is one of the fields of that value), and also that you do not move out of the argument you receive to the interior function.
sourceimpl<T> Pin<&'static T> where
T: ?Sized,
impl<T> Pin<&'static T> where
T: ?Sized,
1.61.0 (const: unstable) · sourcepub fn static_ref(r: &'static T) -> Pin<&'static T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn static_ref(r: &'static T) -> Pin<&'static T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Get a pinned reference from a static reference.
This is safe, because T
is borrowed for the 'static
lifetime, which
never ends.
sourceimpl<'a, P> Pin<&'a mut Pin<P>> where
P: DerefMut,
impl<'a, P> Pin<&'a mut Pin<P>> where
P: DerefMut,
sourcepub fn as_deref_mut(self) -> Pin<&'a mut <P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
🔬 This is a nightly-only experimental API. (pin_deref_mut
)
pub fn as_deref_mut(self) -> Pin<&'a mut <P as Deref>::Target>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pin_deref_mut
)Gets a pinned mutable reference from this nested pinned pointer.
This is a generic method to go from Pin<&mut Pin<Pointer<T>>>
to Pin<&mut T>
. It is
safe because the existence of a Pin<Pointer<T>>
ensures that the pointee, T
, cannot
move in the future, and this method does not enable the pointee to move. “Malicious”
implementations of P::DerefMut
are likewise ruled out by the contract of
Pin::new_unchecked
.
sourceimpl<T> Pin<&'static mut T> where
T: ?Sized,
impl<T> Pin<&'static mut T> where
T: ?Sized,
1.61.0 (const: unstable) · sourcepub fn static_mut(r: &'static mut T) -> Pin<&'static mut T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
pub fn static_mut(r: &'static mut T) -> Pin<&'static mut T>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Get a pinned mutable reference from a static mutable reference.
This is safe, because T
is borrowed for the 'static
lifetime, which
never ends.
Trait Implementations
sourceimpl<P> AsyncBufRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncBufRead,
impl<P> AsyncBufRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncBufRead,
sourceimpl<P> AsyncIterator for Pin<P> where
P: DerefMut,
<P as Deref>::Target: AsyncIterator,
impl<P> AsyncIterator for Pin<P> where
P: DerefMut,
<P as Deref>::Target: AsyncIterator,
type Item = <<P as Deref>::Target as AsyncIterator>::Item
type Item = <<P as Deref>::Target as AsyncIterator>::Item
async_iterator
)The type of items yielded by the async iterator.
sourcefn poll_next(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>
) -> Poll<Option<<Pin<P> as AsyncIterator>::Item>>
fn poll_next(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>
) -> Poll<Option<<Pin<P> as AsyncIterator>::Item>>
async_iterator
)Attempt to pull out the next value of this async iterator, registering the
current task for wakeup if the value is not yet available, and returning
None
if the async iterator is exhausted. Read more
sourceimpl<P> AsyncRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncRead,
impl<P> AsyncRead for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncRead,
sourceimpl<P> AsyncWrite for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncWrite,
impl<P> AsyncWrite for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: AsyncWrite,
sourcefn poll_write(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
fn poll_write(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
buf: &[u8]
) -> Poll<Result<usize, Error>>
Attempt to write bytes from buf
into the object. Read more
sourcefn poll_write_vectored(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
fn poll_write_vectored(
self: Pin<&mut Pin<P>>,
cx: &mut Context<'_>,
bufs: &[IoSlice<'_>]
) -> Poll<Result<usize, Error>>
Attempt to write bytes from bufs
into the object using vectored
IO operations. Read more
sourceimpl<P> Clone for Pin<P> where
P: Clone,
impl<P> Clone for Pin<P> where
P: Clone,
sourcefn clone(&self) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
fn clone(&self) -> Pin<P>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
const: unstable · sourceimpl<T, A> From<Box<T, A>> for Pin<Box<T, A>> where
A: Allocator + 'static,
T: ?Sized,
impl<T, A> From<Box<T, A>> for Pin<Box<T, A>> where
A: Allocator + 'static,
T: ?Sized,
const: unstable · sourcefn from(boxed: Box<T, A>) -> Pin<Box<T, A>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
fn from(boxed: Box<T, A>) -> Pin<Box<T, A>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Converts a Box<T>
into a Pin<Box<T>>
. If T
does not implement Unpin
, then
*boxed
will be pinned in memory and unable to be moved.
This conversion does not allocate on the heap and happens in place.
This is also available via Box::into_pin
.
Constructing and pinning a Box
with <Pin<Box<T>>>::from(Box::new(x))
can also be written more concisely using Box::pin(x)
.
This From
implementation is useful if you already have a Box<T>
, or you are
constructing a (pinned) Box
in a different way than with Box::new
.
sourceimpl<P> FusedFuture for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: FusedFuture,
impl<P> FusedFuture for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: FusedFuture,
sourcefn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns true
if the underlying future should no longer be polled.
sourceimpl<P> FusedStream for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: FusedStream,
impl<P> FusedStream for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: FusedStream,
sourcefn is_terminated(&self) -> bool
fn is_terminated(&self) -> bool
Returns true
if the stream should no longer be polled.
sourceimpl<'_, G, R> Generator<R> for Pin<&'_ mut G> where
G: Generator<R> + ?Sized,
impl<'_, G, R> Generator<R> for Pin<&'_ mut G> where
G: Generator<R> + ?Sized,
type Yield = <G as Generator<R>>::Yield
type Yield = <G as Generator<R>>::Yield
generator_trait
)The type of value this generator yields. Read more
sourceimpl<G, R, A> Generator<R> for Pin<Box<G, A>> where
G: Generator<R> + ?Sized,
A: Allocator + 'static,
impl<G, R, A> Generator<R> for Pin<Box<G, A>> where
G: Generator<R> + ?Sized,
A: Allocator + 'static,
type Yield = <G as Generator<R>>::Yield
type Yield = <G as Generator<R>>::Yield
generator_trait
)The type of value this generator yields. Read more
1.41.0 · sourceimpl<P> Ord for Pin<P> where
P: Deref,
<P as Deref>::Target: Ord,
impl<P> Ord for Pin<P> where
P: Deref,
<P as Deref>::Target: Ord,
1.41.0 · sourceimpl<P, Q> PartialEq<Pin<Q>> for Pin<P> where
P: Deref,
Q: Deref,
<P as Deref>::Target: PartialEq<<Q as Deref>::Target>,
impl<P, Q> PartialEq<Pin<Q>> for Pin<P> where
P: Deref,
Q: Deref,
<P as Deref>::Target: PartialEq<<Q as Deref>::Target>,
1.41.0 · sourceimpl<P, Q> PartialOrd<Pin<Q>> for Pin<P> where
P: Deref,
Q: Deref,
<P as Deref>::Target: PartialOrd<<Q as Deref>::Target>,
impl<P, Q> PartialOrd<Pin<Q>> for Pin<P> where
P: Deref,
Q: Deref,
<P as Deref>::Target: PartialOrd<<Q as Deref>::Target>,
sourcefn partial_cmp(&self, other: &Pin<Q>) -> Option<Ordering>
fn partial_cmp(&self, other: &Pin<Q>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
sourcefn lt(&self, other: &Pin<Q>) -> bool
fn lt(&self, other: &Pin<Q>) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
sourcefn le(&self, other: &Pin<Q>) -> bool
fn le(&self, other: &Pin<Q>) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<P> Stream for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: Stream,
impl<P> Stream for Pin<P> where
P: DerefMut + Unpin,
<P as Deref>::Target: Stream,
impl<P, U> CoerceUnsized<Pin<U>> for Pin<P> where
P: CoerceUnsized<U>,
impl<P> Copy for Pin<P> where
P: Copy,
impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where
P: DispatchFromDyn<U>,
impl<P> Eq for Pin<P> where
P: Deref,
<P as Deref>::Target: Eq,
Auto Trait Implementations
impl<P> RefUnwindSafe for Pin<P> where
P: RefUnwindSafe,
impl<P> Send for Pin<P> where
P: Send,
impl<P> Sync for Pin<P> where
P: Sync,
impl<P> Unpin for Pin<P> where
P: Unpin,
impl<P> UnwindSafe for Pin<P> where
P: UnwindSafe,
Blanket Implementations
sourceimpl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
impl<R> AsyncBufReadExt for R where
R: AsyncBufRead + ?Sized,
sourcefn fill_buf(&mut self) -> FillBuf<'_, Self>ⓘNotable traits for FillBuf<'a, R>impl<'a, R> Future for FillBuf<'a, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<&'a [u8], Error>;
where
Self: Unpin,
fn fill_buf(&mut self) -> FillBuf<'_, Self>ⓘNotable traits for FillBuf<'a, R>impl<'a, R> Future for FillBuf<'a, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<&'a [u8], Error>;
where
Self: Unpin,
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<&'a [u8], Error>;
Returns the contents of the internal buffer, filling it with more data if empty. Read more
sourcefn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self>ⓘNotable traits for ReadUntilFuture<'_, R>impl<'_, R> Future for ReadUntilFuture<'_, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read_until(
&'a mut self,
byte: u8,
buf: &'a mut Vec<u8, Global>
) -> ReadUntilFuture<'a, Self>ⓘNotable traits for ReadUntilFuture<'_, R>impl<'_, R> Future for ReadUntilFuture<'_, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
Reads all bytes and appends them into buf
until the delimiter byte
or EOF is found. Read more
sourcefn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>ⓘNotable traits for ReadLineFuture<'_, R>impl<'_, R> Future for ReadLineFuture<'_, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read_line(&'a mut self, buf: &'a mut String) -> ReadLineFuture<'a, Self>ⓘNotable traits for ReadLineFuture<'_, R>impl<'_, R> Future for ReadLineFuture<'_, R> where
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncBufRead + Unpin + ?Sized, type Output = Result<usize, Error>;
Reads all bytes and appends them into buf
until a newline (the 0xA byte) or EOF is found. Read more
sourceimpl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
impl<R> AsyncReadExt for R where
R: AsyncRead + ?Sized,
sourcefn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>ⓘNotable traits for ReadFuture<'_, R>impl<'_, R> Future for ReadFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read(&'a mut self, buf: &'a mut [u8]) -> ReadFuture<'a, Self>ⓘNotable traits for ReadFuture<'_, R>impl<'_, R> Future for ReadFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
Reads some bytes from the byte stream. Read more
sourcefn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>ⓘNotable traits for ReadVectoredFuture<'_, R>impl<'_, R> Future for ReadVectoredFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read_vectored(
&'a mut self,
bufs: &'a mut [IoSliceMut<'a>]
) -> ReadVectoredFuture<'a, Self>ⓘNotable traits for ReadVectoredFuture<'_, R>impl<'_, R> Future for ReadVectoredFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
sourcefn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>ⓘNotable traits for ReadToEndFuture<'_, R>impl<'_, R> Future for ReadToEndFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read_to_end(
&'a mut self,
buf: &'a mut Vec<u8, Global>
) -> ReadToEndFuture<'a, Self>ⓘNotable traits for ReadToEndFuture<'_, R>impl<'_, R> Future for ReadToEndFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
sourcefn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>ⓘNotable traits for ReadToStringFuture<'_, R>impl<'_, R> Future for ReadToStringFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn read_to_string(
&'a mut self,
buf: &'a mut String
) -> ReadToStringFuture<'a, Self>ⓘNotable traits for ReadToStringFuture<'_, R>impl<'_, R> Future for ReadToStringFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
R: AsyncRead + Unpin + ?Sized, type Output = Result<usize, Error>;
sourcefn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>ⓘNotable traits for ReadExactFuture<'_, R>impl<'_, R> Future for ReadExactFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
fn read_exact(&'a mut self, buf: &'a mut [u8]) -> ReadExactFuture<'a, Self>ⓘNotable traits for ReadExactFuture<'_, R>impl<'_, R> Future for ReadExactFuture<'_, R> where
R: AsyncRead + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
R: AsyncRead + Unpin + ?Sized, type Output = Result<(), Error>;
Reads the exact number of bytes required to fill buf
. Read more
sourcefn take(self, limit: u64) -> Take<Self>
fn take(self, limit: u64) -> Take<Self>
Creates an adapter which will read at most limit
bytes from it. Read more
sourcefn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: AsyncRead,
Creates an adapter which will chain this stream with another. Read more
sourcefn boxed_reader<'a>(self) -> Pin<Box<dyn AsyncRead + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
fn boxed_reader<'a>(self) -> Pin<Box<dyn AsyncRead + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the reader and changes its type to dyn AsyncRead + Send + 'a
. Read more
sourceimpl<S> AsyncSeekExt for S where
S: AsyncSeek + ?Sized,
impl<S> AsyncSeekExt for S where
S: AsyncSeek + ?Sized,
sourceimpl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
impl<W> AsyncWriteExt for W where
W: AsyncWrite + ?Sized,
sourcefn write(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>ⓘNotable traits for WriteFuture<'_, W>impl<'_, W> Future for WriteFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn write(&'a mut self, buf: &'a [u8]) -> WriteFuture<'a, Self>ⓘNotable traits for WriteFuture<'_, W>impl<'_, W> Future for WriteFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
Writes some bytes into the byte stream. Read more
sourcefn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self>ⓘNotable traits for WriteVectoredFuture<'_, W>impl<'_, W> Future for WriteVectoredFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
fn write_vectored(
&'a mut self,
bufs: &'a [IoSlice<'a>]
) -> WriteVectoredFuture<'a, Self>ⓘNotable traits for WriteVectoredFuture<'_, W>impl<'_, W> Future for WriteVectoredFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
where
Self: Unpin,
W: AsyncWrite + Unpin + ?Sized, type Output = Result<usize, Error>;
sourcefn write_all(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>ⓘNotable traits for WriteAllFuture<'_, W>impl<'_, W> Future for WriteAllFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
fn write_all(&'a mut self, buf: &'a [u8]) -> WriteAllFuture<'a, Self>ⓘNotable traits for WriteAllFuture<'_, W>impl<'_, W> Future for WriteAllFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
Writes an entire buffer into the byte stream. Read more
sourcefn flush(&mut self) -> FlushFuture<'_, Self>ⓘNotable traits for FlushFuture<'_, W>impl<'_, W> Future for FlushFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
fn flush(&mut self) -> FlushFuture<'_, Self>ⓘNotable traits for FlushFuture<'_, W>impl<'_, W> Future for FlushFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
Flushes the stream to ensure that all buffered contents reach their destination. Read more
sourcefn close(&mut self) -> CloseFuture<'_, Self>ⓘNotable traits for CloseFuture<'_, W>impl<'_, W> Future for CloseFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
fn close(&mut self) -> CloseFuture<'_, Self>ⓘNotable traits for CloseFuture<'_, W>impl<'_, W> Future for CloseFuture<'_, W> where
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
where
Self: Unpin,
W: AsyncWrite + Unpin + ?Sized, type Output = Result<(), Error>;
Closes the writer. Read more
sourcefn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
fn boxed_writer<'a>(self) -> Pin<Box<dyn AsyncWrite + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the writer and changes its type to dyn AsyncWrite + Send + 'a
. Read more
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<F> FutureExt for F where
F: Future + ?Sized,
impl<F> FutureExt for F where
F: Future + ?Sized,
sourcefn poll(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
fn poll(&mut self, cx: &mut Context<'_>) -> Poll<Self::Output> where
Self: Unpin,
A convenience for calling Future::poll()
on !
Unpin
types.
sourcefn or<F>(self, other: F) -> Or<Self, F>ⓘNotable traits for Or<F1, F2>impl<T, F1, F2> Future for Or<F1, F2> where
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
where
F: Future<Output = Self::Output>,
fn or<F>(self, other: F) -> Or<Self, F>ⓘNotable traits for Or<F1, F2>impl<T, F1, F2> Future for Or<F1, F2> where
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
where
F: Future<Output = Self::Output>,
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
Returns the result of self
or other
future, preferring self
if both are ready. Read more
sourcefn race<F>(self, other: F) -> Race<Self, F>ⓘNotable traits for Race<F1, F2>impl<T, F1, F2> Future for Race<F1, F2> where
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
where
F: Future<Output = Self::Output>,
fn race<F>(self, other: F) -> Race<Self, F>ⓘNotable traits for Race<F1, F2>impl<T, F1, F2> Future for Race<F1, F2> where
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
where
F: Future<Output = Self::Output>,
F1: Future<Output = T>,
F2: Future<Output = T>, type Output = T;
Returns the result of self
or other
future, with no preference if both are ready. Read more
sourcefn catch_unwind(self) -> CatchUnwind<Self>ⓘNotable traits for CatchUnwind<F>impl<F> Future for CatchUnwind<F> where
F: Future + UnwindSafe, type Output = Result<<F as Future>::Output, Box<dyn Any + Send + 'static, Global>>;
where
Self: UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self>ⓘNotable traits for CatchUnwind<F>impl<F> Future for CatchUnwind<F> where
F: Future + UnwindSafe, type Output = Result<<F as Future>::Output, Box<dyn Any + Send + 'static, Global>>;
where
Self: UnwindSafe,
F: Future + UnwindSafe, type Output = Result<<F as Future>::Output, Box<dyn Any + Send + 'static, Global>>;
Catches panics while polling the future. Read more
sourcefn boxed<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
fn boxed<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the future and changes its type to dyn Future + Send + 'a
. Read more
sourcefn boxed_local<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a,
fn boxed_local<'a>(
self
) -> Pin<Box<dyn Future<Output = Self::Output> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the future and changes its type to dyn Future + 'a
. Read more
sourceimpl<F> IntoFuture for F where
F: Future,
impl<F> IntoFuture for F where
F: Future,
type Output = <F as Future>::Output
type Output = <F as Future>::Output
into_future
)The output that the future will produce on completion.
type IntoFuture = F
type IntoFuture = F
into_future
)Which kind of future are we turning this into?
sourcefn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
into_future
)Creates a future from a value. Read more
sourceimpl<S> StreamExt for S where
S: Stream + ?Sized,
impl<S> StreamExt for S where
S: Stream + ?Sized,
sourcefn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> where
Self: Unpin,
fn poll_next(&mut self, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> where
Self: Unpin,
A convenience for calling Stream::poll_next()
on !
Unpin
types.
sourcefn next(&mut self) -> NextFuture<'_, Self>ⓘNotable traits for NextFuture<'_, S>impl<'_, S> Future for NextFuture<'_, S> where
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
fn next(&mut self) -> NextFuture<'_, Self>ⓘNotable traits for NextFuture<'_, S>impl<'_, S> Future for NextFuture<'_, S> where
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
Retrieves the next item in the stream. Read more
sourcefn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>ⓘNotable traits for TryNextFuture<'_, S>impl<'_, T, E, S> Future for TryNextFuture<'_, S> where
S: Stream<Item = Result<T, E>> + Unpin + ?Sized, type Output = Result<Option<T>, E>;
where
Self: Stream<Item = Result<T, E>> + Unpin,
fn try_next<T, E>(&mut self) -> TryNextFuture<'_, Self>ⓘNotable traits for TryNextFuture<'_, S>impl<'_, T, E, S> Future for TryNextFuture<'_, S> where
S: Stream<Item = Result<T, E>> + Unpin + ?Sized, type Output = Result<Option<T>, E>;
where
Self: Stream<Item = Result<T, E>> + Unpin,
S: Stream<Item = Result<T, E>> + Unpin + ?Sized, type Output = Result<Option<T>, E>;
Retrieves the next item in the stream. Read more
sourcefn count(self) -> CountFuture<Self>ⓘNotable traits for CountFuture<S>impl<S> Future for CountFuture<S> where
S: Stream + ?Sized, type Output = usize;
fn count(self) -> CountFuture<Self>ⓘNotable traits for CountFuture<S>impl<S> Future for CountFuture<S> where
S: Stream + ?Sized, type Output = usize;
S: Stream + ?Sized, type Output = usize;
Counts the number of items in the stream. Read more
sourcefn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
fn map<T, F>(self, f: F) -> Map<Self, F> where
F: FnMut(Self::Item) -> T,
Maps items of the stream to new values using a closure. Read more
sourcefn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
U: Stream,
F: FnMut(Self::Item) -> U,
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F> where
U: Stream,
F: FnMut(Self::Item) -> U,
Maps items to streams and then concatenates them. Read more
sourcefn flatten(self) -> Flatten<Self> where
Self::Item: Stream,
fn flatten(self) -> Flatten<Self> where
Self::Item: Stream,
Concatenates inner streams. Read more
sourcefn then<F, Fut>(self, f: F) -> Then<Self, F, Fut> where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
fn then<F, Fut>(self, f: F) -> Then<Self, F, Fut> where
F: FnMut(Self::Item) -> Fut,
Fut: Future,
Maps items of the stream to new values using an async closure. Read more
sourcefn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
fn filter<P>(self, predicate: P) -> Filter<Self, P> where
P: FnMut(&Self::Item) -> bool,
Keeps items of the stream for which predicate
returns true
. Read more
sourcefn filter_map<T, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<T>,
fn filter_map<T, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option<T>,
Filters and maps items of the stream using a closure. Read more
sourcefn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Takes items while predicate
returns true
. Read more
sourcefn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool,
Skips items while predicate
returns true
. Read more
sourcefn chain<U>(self, other: U) -> Chain<Self, U> where
U: Stream<Item = Self::Item>,
fn chain<U>(self, other: U) -> Chain<Self, U> where
U: Stream<Item = Self::Item>,
Appends another stream to the end of this one. Read more
sourcefn cloned<'a, T>(self) -> Cloned<Self> where
Self: Stream<Item = &'a T>,
T: 'a + Clone,
fn cloned<'a, T>(self) -> Cloned<Self> where
Self: Stream<Item = &'a T>,
T: 'a + Clone,
Clones all items. Read more
sourcefn copied<'a, T>(self) -> Copied<Self> where
Self: Stream<Item = &'a T>,
T: 'a + Copy,
fn copied<'a, T>(self) -> Copied<Self> where
Self: Stream<Item = &'a T>,
T: 'a + Copy,
Copies all items. Read more
sourcefn collect<C>(self) -> CollectFuture<Self, C>ⓘNotable traits for CollectFuture<S, C>impl<S, C> Future for CollectFuture<S, C> where
S: Stream,
C: Default + Extend<<S as Stream>::Item>, type Output = C;
where
C: Default + Extend<Self::Item>,
fn collect<C>(self) -> CollectFuture<Self, C>ⓘNotable traits for CollectFuture<S, C>impl<S, C> Future for CollectFuture<S, C> where
S: Stream,
C: Default + Extend<<S as Stream>::Item>, type Output = C;
where
C: Default + Extend<Self::Item>,
S: Stream,
C: Default + Extend<<S as Stream>::Item>, type Output = C;
Collects all items in the stream into a collection. Read more
sourcefn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>ⓘNotable traits for TryCollectFuture<S, C>impl<T, E, S, C> Future for TryCollectFuture<S, C> where
S: Stream<Item = Result<T, E>>,
C: Default + Extend<T>, type Output = Result<C, E>;
where
Self: Stream<Item = Result<T, E>>,
C: Default + Extend<T>,
fn try_collect<T, E, C>(self) -> TryCollectFuture<Self, C>ⓘNotable traits for TryCollectFuture<S, C>impl<T, E, S, C> Future for TryCollectFuture<S, C> where
S: Stream<Item = Result<T, E>>,
C: Default + Extend<T>, type Output = Result<C, E>;
where
Self: Stream<Item = Result<T, E>>,
C: Default + Extend<T>,
S: Stream<Item = Result<T, E>>,
C: Default + Extend<T>, type Output = Result<C, E>;
Collects all items in the fallible stream into a collection. Read more
sourcefn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>ⓘNotable traits for PartitionFuture<S, P, B>impl<S, P, B> Future for PartitionFuture<S, P, B> where
S: Stream,
P: FnMut(&<S as Stream>::Item) -> bool,
B: Default + Extend<<S as Stream>::Item>, type Output = (B, B);
where
B: Default + Extend<Self::Item>,
P: FnMut(&Self::Item) -> bool,
fn partition<B, P>(self, predicate: P) -> PartitionFuture<Self, P, B>ⓘNotable traits for PartitionFuture<S, P, B>impl<S, P, B> Future for PartitionFuture<S, P, B> where
S: Stream,
P: FnMut(&<S as Stream>::Item) -> bool,
B: Default + Extend<<S as Stream>::Item>, type Output = (B, B);
where
B: Default + Extend<Self::Item>,
P: FnMut(&Self::Item) -> bool,
S: Stream,
P: FnMut(&<S as Stream>::Item) -> bool,
B: Default + Extend<<S as Stream>::Item>, type Output = (B, B);
Partitions items into those for which predicate
is true
and those for which it is
false
, and then collects them into two collections. Read more
sourcefn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>ⓘNotable traits for FoldFuture<S, F, T>impl<S, F, T> Future for FoldFuture<S, F, T> where
S: Stream,
F: FnMut(T, <S as Stream>::Item) -> T, type Output = T;
where
F: FnMut(T, Self::Item) -> T,
fn fold<T, F>(self, init: T, f: F) -> FoldFuture<Self, F, T>ⓘNotable traits for FoldFuture<S, F, T>impl<S, F, T> Future for FoldFuture<S, F, T> where
S: Stream,
F: FnMut(T, <S as Stream>::Item) -> T, type Output = T;
where
F: FnMut(T, Self::Item) -> T,
S: Stream,
F: FnMut(T, <S as Stream>::Item) -> T, type Output = T;
Accumulates a computation over the stream. Read more
sourcefn try_fold<T, E, F, B>(
&mut self,
init: B,
f: F
) -> TryFoldFuture<'_, Self, F, B>ⓘNotable traits for TryFoldFuture<'a, S, F, B>impl<'a, T, E, S, F, B> Future for TryFoldFuture<'a, S, F, B> where
S: Stream<Item = Result<T, E>> + Unpin,
F: FnMut(B, T) -> Result<B, E>, type Output = Result<B, E>;
where
Self: Stream<Item = Result<T, E>> + Unpin,
F: FnMut(B, T) -> Result<B, E>,
fn try_fold<T, E, F, B>(
&mut self,
init: B,
f: F
) -> TryFoldFuture<'_, Self, F, B>ⓘNotable traits for TryFoldFuture<'a, S, F, B>impl<'a, T, E, S, F, B> Future for TryFoldFuture<'a, S, F, B> where
S: Stream<Item = Result<T, E>> + Unpin,
F: FnMut(B, T) -> Result<B, E>, type Output = Result<B, E>;
where
Self: Stream<Item = Result<T, E>> + Unpin,
F: FnMut(B, T) -> Result<B, E>,
S: Stream<Item = Result<T, E>> + Unpin,
F: FnMut(B, T) -> Result<B, E>, type Output = Result<B, E>;
Accumulates a fallible computation over the stream. Read more
sourcefn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
fn scan<St, B, F>(self, initial_state: St, f: F) -> Scan<Self, St, F> where
F: FnMut(&mut St, Self::Item) -> Option<B>,
Maps items of the stream to new values using a state value and a closure. Read more
sourcefn cycle(self) -> Cycle<Self> where
Self: Clone,
fn cycle(self) -> Cycle<Self> where
Self: Clone,
Repeats the stream from beginning to end, forever. Read more
sourcefn enumerate(self) -> Enumerate<Self>
fn enumerate(self) -> Enumerate<Self>
Enumerates items, mapping them to (index, item)
. Read more
sourcefn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
fn inspect<F>(self, f: F) -> Inspect<Self, F> where
F: FnMut(&Self::Item),
Calls a closure on each item and passes it on. Read more
sourcefn nth(&mut self, n: usize) -> NthFuture<'_, Self>ⓘNotable traits for NthFuture<'a, S>impl<'a, S> Future for NthFuture<'a, S> where
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
fn nth(&mut self, n: usize) -> NthFuture<'_, Self>ⓘNotable traits for NthFuture<'a, S>impl<'a, S> Future for NthFuture<'a, S> where
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
S: Stream + Unpin + ?Sized, type Output = Option<<S as Stream>::Item>;
Gets the n
th item of the stream. Read more
sourcefn last(self) -> LastFuture<Self>ⓘNotable traits for LastFuture<S>impl<S> Future for LastFuture<S> where
S: Stream, type Output = Option<<S as Stream>::Item>;
fn last(self) -> LastFuture<Self>ⓘNotable traits for LastFuture<S>impl<S> Future for LastFuture<S> where
S: Stream, type Output = Option<<S as Stream>::Item>;
S: Stream, type Output = Option<<S as Stream>::Item>;
Returns the last item in the stream. Read more
sourcefn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>ⓘNotable traits for FindFuture<'a, S, P>impl<'a, S, P> Future for FindFuture<'a, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(&<S as Stream>::Item) -> bool, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
P: FnMut(&Self::Item) -> bool,
fn find<P>(&mut self, predicate: P) -> FindFuture<'_, Self, P>ⓘNotable traits for FindFuture<'a, S, P>impl<'a, S, P> Future for FindFuture<'a, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(&<S as Stream>::Item) -> bool, type Output = Option<<S as Stream>::Item>;
where
Self: Unpin,
P: FnMut(&Self::Item) -> bool,
S: Stream + Unpin + ?Sized,
P: FnMut(&<S as Stream>::Item) -> bool, type Output = Option<<S as Stream>::Item>;
Finds the first item of the stream for which predicate
returns true
. Read more
sourcefn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>ⓘNotable traits for FindMapFuture<'a, S, F>impl<'a, S, B, F> Future for FindMapFuture<'a, S, F> where
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Option<B>, type Output = Option<B>;
where
Self: Unpin,
F: FnMut(Self::Item) -> Option<B>,
fn find_map<F, B>(&mut self, f: F) -> FindMapFuture<'_, Self, F>ⓘNotable traits for FindMapFuture<'a, S, F>impl<'a, S, B, F> Future for FindMapFuture<'a, S, F> where
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Option<B>, type Output = Option<B>;
where
Self: Unpin,
F: FnMut(Self::Item) -> Option<B>,
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Option<B>, type Output = Option<B>;
sourcefn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>ⓘNotable traits for PositionFuture<'a, S, P>impl<'a, S, P> Future for PositionFuture<'a, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = Option<usize>;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn position<P>(&mut self, predicate: P) -> PositionFuture<'_, Self, P>ⓘNotable traits for PositionFuture<'a, S, P>impl<'a, S, P> Future for PositionFuture<'a, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = Option<usize>;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = Option<usize>;
Finds the index of the first item of the stream for which predicate
returns true
. Read more
sourcefn all<P>(&mut self, predicate: P) -> AllFuture<'_, Self, P>ⓘNotable traits for AllFuture<'_, S, P>impl<'_, S, P> Future for AllFuture<'_, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn all<P>(&mut self, predicate: P) -> AllFuture<'_, Self, P>ⓘNotable traits for AllFuture<'_, S, P>impl<'_, S, P> Future for AllFuture<'_, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
Tests if predicate
returns true
for all items in the stream. Read more
sourcefn any<P>(&mut self, predicate: P) -> AnyFuture<'_, Self, P>ⓘNotable traits for AnyFuture<'_, S, P>impl<'_, S, P> Future for AnyFuture<'_, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
fn any<P>(&mut self, predicate: P) -> AnyFuture<'_, Self, P>ⓘNotable traits for AnyFuture<'_, S, P>impl<'_, S, P> Future for AnyFuture<'_, S, P> where
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
where
Self: Unpin,
P: FnMut(Self::Item) -> bool,
S: Stream + Unpin + ?Sized,
P: FnMut(<S as Stream>::Item) -> bool, type Output = bool;
Tests if predicate
returns true
for any item in the stream. Read more
sourcefn for_each<F>(self, f: F) -> ForEachFuture<Self, F>ⓘNotable traits for ForEachFuture<S, F>impl<S, F> Future for ForEachFuture<S, F> where
S: Stream,
F: FnMut(<S as Stream>::Item), type Output = ();
where
F: FnMut(Self::Item),
fn for_each<F>(self, f: F) -> ForEachFuture<Self, F>ⓘNotable traits for ForEachFuture<S, F>impl<S, F> Future for ForEachFuture<S, F> where
S: Stream,
F: FnMut(<S as Stream>::Item), type Output = ();
where
F: FnMut(Self::Item),
S: Stream,
F: FnMut(<S as Stream>::Item), type Output = ();
Calls a closure on each item of the stream. Read more
sourcefn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>ⓘNotable traits for TryForEachFuture<'a, S, F>impl<'a, S, F, E> Future for TryForEachFuture<'a, S, F> where
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Result<(), E>, type Output = Result<(), E>;
where
Self: Unpin,
F: FnMut(Self::Item) -> Result<(), E>,
fn try_for_each<F, E>(&mut self, f: F) -> TryForEachFuture<'_, Self, F>ⓘNotable traits for TryForEachFuture<'a, S, F>impl<'a, S, F, E> Future for TryForEachFuture<'a, S, F> where
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Result<(), E>, type Output = Result<(), E>;
where
Self: Unpin,
F: FnMut(Self::Item) -> Result<(), E>,
S: Stream + Unpin + ?Sized,
F: FnMut(<S as Stream>::Item) -> Result<(), E>, type Output = Result<(), E>;
Calls a fallible closure on each item of the stream, stopping on first error. Read more
sourcefn zip<U>(self, other: U) -> Zip<Self, U> where
U: Stream,
fn zip<U>(self, other: U) -> Zip<Self, U> where
U: Stream,
Zips up two streams into a single stream of pairs. Read more
sourcefn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>ⓘNotable traits for UnzipFuture<S, FromA, FromB>impl<S, A, B, FromA, FromB> Future for UnzipFuture<S, FromA, FromB> where
S: Stream<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>, type Output = (FromA, FromB);
where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Stream<Item = (A, B)>,
fn unzip<A, B, FromA, FromB>(self) -> UnzipFuture<Self, FromA, FromB>ⓘNotable traits for UnzipFuture<S, FromA, FromB>impl<S, A, B, FromA, FromB> Future for UnzipFuture<S, FromA, FromB> where
S: Stream<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>, type Output = (FromA, FromB);
where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Stream<Item = (A, B)>,
S: Stream<Item = (A, B)>,
FromA: Default + Extend<A>,
FromB: Default + Extend<B>, type Output = (FromA, FromB);
Collects a stream of pairs into a pair of collections. Read more
sourcefn or<S>(self, other: S) -> Or<Self, S> where
S: Stream<Item = Self::Item>,
fn or<S>(self, other: S) -> Or<Self, S> where
S: Stream<Item = Self::Item>,
Merges with other
stream, preferring items from self
whenever both streams are ready. Read more
sourcefn race<S>(self, other: S) -> Race<Self, S> where
S: Stream<Item = Self::Item>,
fn race<S>(self, other: S) -> Race<Self, S> where
S: Stream<Item = Self::Item>,
Merges with other
stream, with no preference for either stream when both are ready. Read more
sourcefn boxed<'a>(
self
) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
fn boxed<'a>(
self
) -> Pin<Box<dyn Stream<Item = Self::Item> + Send + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a + Send,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the stream and changes its type to dyn Stream + Send + 'a
. Read more
sourcefn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a,
fn boxed_local<'a>(self) -> Pin<Box<dyn Stream<Item = Self::Item> + 'a, Global>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
Self: 'a,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Boxes the stream and changes its type to dyn Stream + 'a
. Read more