Skip to main content

DetectDispatcher

Struct DetectDispatcher 

Source
pub struct DetectDispatcher { /* private fields */ }
Expand description

Implements a dispatcher that is either set at construction or detected and cached on first use.

This is intended to be used inside futures to implement detecting the current dispatcher on first poll if the instigator of the future did not specify a dispatcher to run on.

Implementations§

Source§

impl DetectDispatcher

Source

pub fn new(with_dispatcher: impl AsAsyncDispatcherRef) -> Self

Use this to pre-set the dispatcher so that future calls to GetAsyncDispatcher will return is dispatcher instead of trying to get the default one.

Source

pub fn get_or_detect(&self) -> Result<&AsyncDispatcher, Status>

Gets the dispatcher if set in the constructor, or attempts to retrieve the current dispatcher as set by crate::CurrentDispatcher::set (or the underlying async-default api).

Use this in a std::task::Poll implementation to defer finding the current dispatcher until the future is being run on the dispatcher.

Once a dispatcher has been set or detected, that dispatcher will be held and returned for all future calls.

Returns Status::BAD_STATE if there is no dispatcher set or detected.

Source

pub fn get(&self) -> Option<&AsyncDispatcher>

Gets the dispatcher if it had been previously set or detected. If it hasn’t, this will return None.

Trait Implementations§

Source§

impl Debug for DetectDispatcher

Source§

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

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

impl Default for DetectDispatcher

Source§

fn default() -> DetectDispatcher

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.