Struct futures_util::future::Shared

source ·
pub struct Shared<Fut: Future> { /* private fields */ }
Expand description

Future for the shared method.

Implementations§

source§

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

source

pub 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.

source

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

Creates a new WeakShared for this Shared.

Returns None if it has already been polled to completion.

source

pub 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.

source

pub 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.

source

pub 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.

source

pub 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§

source§

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

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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

source§

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

Formats the value using the given formatter. Read more
source§

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

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

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

source§

fn is_terminated(&self) -> bool

Returns true if the underlying future should no longer be polled.
source§

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

§

type Output = <Fut as Future>::Output

The type of value produced on completion.
source§

fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output>

Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more
source§

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

Auto Trait Implementations§

§

impl<Fut> !RefUnwindSafe for Shared<Fut>

§

impl<Fut> Send for Shared<Fut>where Fut: Send, <Fut as Future>::Output: Send + Sync,

§

impl<Fut> Sync for Shared<Fut>where Fut: Send, <Fut as Future>::Output: Send + Sync,

§

impl<Fut> !UnwindSafe for Shared<Fut>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<F> IntoFuture for Fwhere F: Future,

§

type Output = <F as Future>::Output

The output that the future will produce on completion.
§

type IntoFuture = F

Which kind of future are we turning this into?
source§

fn into_future(self) -> <F as IntoFuture>::IntoFuture

Creates a future from a value. Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

type Ok = T

The type of successful values yielded by this future
§

type Error = E

The type of failures yielded by this future
source§

fn try_poll( self: Pin<&mut F>, cx: &mut Context<'_> ) -> Poll<<F as Future>::Output>

Poll this TryFuture as if it were a Future. Read more
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.