Struct futures_util::task::WakerRef

source ·
pub struct WakerRef<'a> { /* private fields */ }
Expand description

A Waker that is only valid for a given lifetime.

Note: this type implements Deref<Target = Waker>, so it can be used to get a &Waker.

Implementations§

source§

impl<'a> WakerRef<'a>

source

pub fn new(waker: &'a Waker) -> WakerRef<'a>

Create a new WakerRef from a Waker reference.

source

pub fn new_unowned(waker: ManuallyDrop<Waker>) -> WakerRef<'a>

Create a new WakerRef from a Waker that must not be dropped.

Note: this if for rare cases where the caller created a Waker in an unsafe way (that will be valid only for a lifetime to be determined by the caller), and the Waker doesn’t need to or must not be destroyed.

Methods from Deref<Target = Waker>§

1.36.0 · source

pub fn wake_by_ref(&self)

Wake up the task associated with this Waker without consuming the Waker.

This is similar to wake(), but may be slightly less efficient in the case where an owned Waker is available. This method should be preferred to calling waker.clone().wake().

1.36.0 · source

pub fn will_wake(&self, other: &Waker) -> bool

Returns true if this Waker and another Waker would awake the same task.

This function works on a best-effort basis, and may return false even when the Wakers would awaken the same task. However, if this function returns true, it is guaranteed that the Wakers will awaken the same task.

This function is primarily used for optimization purposes.

source

pub fn as_raw(&self) -> &RawWaker

🔬This is a nightly-only experimental API. (waker_getters)

Get a reference to the underlying RawWaker.

Trait Implementations§

source§

impl<'a> Debug for WakerRef<'a>

source§

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

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

impl Deref for WakerRef<'_>

§

type Target = Waker

The resulting type after dereferencing.
source§

fn deref(&self) -> &Waker

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for WakerRef<'a>

§

impl<'a> Send for WakerRef<'a>

§

impl<'a> Sync for WakerRef<'a>

§

impl<'a> Unpin for WakerRef<'a>

§

impl<'a> UnwindSafe for WakerRef<'a>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
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.
source§

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

Performs the conversion.