Struct mfio::backend::BackendHandle

source ·
pub struct BackendHandle<'a, B: ?Sized> { /* private fields */ }
Expand description

Handle to a backend.

This handle can be used to drive arbitrary future to completion by attaching a backend to it. This is typically done using WithBackend that is constructed in IoBackendExt::with_backend.

Usually, the user would want to bypass this type and use IoBackendExt::block_on, or an Integration equivalent.

Methods from Deref<Target = Pin<&'a mut B>>§

1.33.0 · source

pub fn as_ref(&self) -> Pin<&<P as Deref>::Target>

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.33.0 · source

pub fn as_mut(&mut self) -> Pin<&mut <P as Deref>::Target>

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();
    }
}
1.33.0 · source

pub fn set(&mut self, value: <P as Deref>::Target)
where <P as Deref>::Target: Sized,

Assigns a new value to the memory behind the pinned reference.

This overwrites pinned data, but that is okay: its destructor gets run before being overwritten, so no pinning guarantee is violated.

Example
use std::pin::Pin;

let mut val: u8 = 5;
let mut pinned: Pin<&mut u8> = Pin::new(&mut val);
println!("{}", pinned); // 5
pinned.as_mut().set(10);
println!("{}", pinned); // 10

Trait Implementations§

source§

impl<'a, B: ?Sized> Deref for BackendHandle<'a, B>

§

type Target = Pin<&'a mut B>

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<'a, B: ?Sized> DerefMut for BackendHandle<'a, B>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'a, B: ?Sized> Drop for BackendHandle<'a, B>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, B> !RefUnwindSafe for BackendHandle<'a, B>

§

impl<'a, B: ?Sized> Send for BackendHandle<'a, B>
where B: Send,

§

impl<'a, B: ?Sized> Sync for BackendHandle<'a, B>
where B: Send + Sync,

§

impl<'a, B: ?Sized> Unpin for BackendHandle<'a, B>

§

impl<'a, B> !UnwindSafe for BackendHandle<'a, B>

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> Forward for T
where T: Deref,

source§

fn forward(self) -> Fwd<Self>

source§

impl<T> ForwardMut for T
where T: DerefMut,

source§

fn forward_mut(self) -> Fwd<Self>

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, F> From2<T> for F
where T: Into<F>,

source§

fn from2(other: T) -> F

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

§

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>,

§

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> GenericTypeBounds for T