BridgeContext

Struct BridgeContext 

Source
pub struct BridgeContext<T>
where T: 'static,
{ /* private fields */ }
Expand description

Async operation context for bridging rust code into SF COM api that supports cancellation.

Implementations§

Source§

impl<T> BridgeContext<T>
where T: Send,

Source

pub fn make( callback: Ref<'_, IFabricAsyncOperationCallback>, ) -> (Self, BoxedCancelToken)

Creates the context from callback, and returns a cancellation token that can be used in rust code, and the cancellation token is hooked into self, where Cancel() api cancels the operation.

Source

pub fn spawn<F>( self, rt: &impl Executor, future: F, ) -> WinResult<IFabricAsyncOperationContext>
where F: Future<Output = T> + Send + 'static,

Spawns the future on rt. Returns a context that can be returned to SF runtime. This is intended to be used in SF Begin COM api, where rust code is spawned in background and the context is returned to caller. If the future panics, an error is set in the resulting content, caller will still get callback and receive an error in the End api. This api is in some sense unsafe, because the developer needs to ensure the following:

  • return type of the future needs to match SF COM api end return type.
Source

pub fn result(context: Ref<'_, IFabricAsyncOperationContext>) -> Result<T>

Get the result from the context from the SF End COM api. This api is in some sense unsafe, because the developer needs to ensure the following:

  • context impl type is BridgeContext3, and the T matches the SF end api return type.

Note that if T is of Result type, the current function return type is Result<Result>, so unwrap is needed.

Trait Implementations§

Source§

impl<T> AsImpl<BridgeContext<T>> for IFabricAsyncOperationContext
where T: 'static,

Source§

unsafe fn as_impl_ptr(&self) -> NonNull<BridgeContext<T>>

Returns a pointer to the implementation object. Read more
Source§

unsafe fn as_impl(&self) -> &T

Safety Read more
Source§

impl<T> ComObjectInner for BridgeContext<T>
where T: 'static,

Source§

type Outer = BridgeContext_Impl<T>

The generated <foo>_Impl type (aka the “boxed” type or “outer” type).
Source§

fn into_object(self) -> ComObject<Self>

Moves an instance of this type into a new ComObject box and returns it. Read more
Source§

impl<T> From<BridgeContext<T>> for IFabricAsyncOperationContext
where T: 'static,

Source§

fn from(this: BridgeContext<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<BridgeContext<T>> for IInspectable
where T: 'static,

Source§

fn from(this: BridgeContext<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<BridgeContext<T>> for IUnknown
where T: 'static,

Source§

fn from(this: BridgeContext<T>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<T> !Freeze for BridgeContext<T>

§

impl<T> !RefUnwindSafe for BridgeContext<T>

§

impl<T> Send for BridgeContext<T>
where T: Send,

§

impl<T> !Sync for BridgeContext<T>

§

impl<T> Unpin for BridgeContext<T>
where T: Unpin,

§

impl<T> !UnwindSafe for BridgeContext<T>

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> Instrument for T

Source§

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

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

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

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

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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