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,
impl<T> BridgeContext<T>where
T: Send,
Sourcepub fn make(
callback: Ref<'_, IFabricAsyncOperationCallback>,
) -> (Self, BoxedCancelToken)
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.
Sourcepub fn spawn<F>(
self,
rt: &impl Executor,
future: F,
) -> WinResult<IFabricAsyncOperationContext>
pub fn spawn<F>( self, rt: &impl Executor, future: F, ) -> WinResult<IFabricAsyncOperationContext>
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.
Sourcepub fn result(context: Ref<'_, IFabricAsyncOperationContext>) -> Result<T>
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