Struct Shared

#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Shared<Fut: Future> { /* private fields */ }

Future for the shared method.

Implementations

impl<Fut> Shared<Fut> where Fut: Future,

fn peek(&self) -> Option<&Fut::Output>

Returns Some containing a reference to this Shared's output if it has already been computed by a clone or None if it hasn't been computed yet or this Shared already returned its output from poll.

fn downgrade(&self) -> Option<WeakShared<Fut>>

Creates a new WeakShared for this Shared.

Returns None if it has already been polled to completion.

fn strong_count(&self) -> Option<usize>

Gets the number of strong pointers to this allocation.

Returns None if it has already been polled to completion.

Safety

This method by itself is safe, but using it correctly requires extra care. Another thread can change the strong count at any time, including potentially between calling this method and acting on the result.

fn weak_count(&self) -> Option<usize>

Gets the number of weak pointers to this allocation.

Returns None if it has already been polled to completion.

Safety

This method by itself is safe, but using it correctly requires extra care. Another thread can change the weak count at any time, including potentially between calling this method and acting on the result.

fn ptr_hash<H: Hasher>(&self, state: &mut H)

Hashes the internal state of this Shared in a way that's compatible with ptr_eq.

fn ptr_eq(&self, rhs: &Self) -> bool

Returns true if the two Shareds point to the same future (in a vein similar to Arc::ptr_eq).

Returns false if either Shared has terminated.

Trait Implementations

impl<Fut> Clone for Shared<Fut> where Fut: Future,

fn clone(&self) -> Self

impl<Fut> Drop for Shared<Fut> where Fut: Future,

fn drop(&mut self)

impl<Fut> FusedFuture for Shared<Fut> where Fut: Future, Fut::Output: Clone,

fn is_terminated(&self) -> bool

impl<Fut> Future for Shared<Fut> where Fut: Future, Fut::Output: Clone,

type Output = <Fut as Future>::Output;
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

impl<Fut: Future> Debug for Shared<Fut>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<Fut> !RefUnwindSafe for Shared<Fut>

impl<Fut> !UnwindSafe for Shared<Fut>

impl<Fut> Freeze for Shared<Fut> where Option<Arc<Inner<Fut>>>: Freeze,

impl<Fut> Send for Shared<Fut> where Option<Arc<Inner<Fut>>>: Send,

impl<Fut> Sync for Shared<Fut> where Option<Arc<Inner<Fut>>>: Sync,

impl<Fut> Unpin for Shared<Fut> where Option<Arc<Inner<Fut>>>: Unpin,

impl<Fut> UnsafeUnpin for Shared<Fut> where Option<Arc<Inner<Fut>>>: UnsafeUnpin,

Blanket Implementations

impl<F> IntoFuture for Shared<Fut> where F: Future,

type Output = <F as Future>::Output;
type IntoFuture = F;
fn into_future(self) -> <F as IntoFuture>::IntoFuture

impl<F, T, E> TryFuture for Shared<Fut> where F: Future<Output = Result<T, E>> + ?Sized,

type Ok = T;
type Error = E;
fn try_poll(self: Pin<&mut F>, cx: &mut Context<'_>) -> Poll<<F as Future>::Output>

impl<Fut> TryFutureExt for Shared<Fut> where Fut: TryFuture + ?Sized,

impl<T> Any for Shared<Fut> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Shared<Fut> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Shared<Fut> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Shared<Fut> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Shared<Fut>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> FutureExt for Shared<Fut> where T: Future + ?Sized,

impl<T> ToOwned for Shared<Fut> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for Shared<Fut> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Shared<Fut> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Shared<Fut> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>