pub struct AsyncCompletion<T> { /* private fields */ }Expand description
An async completion handler for FFI callbacks
This type provides a Future that resolves when an async callback completes.
It uses Arc<Mutex> internally for thread-safe signaling and waker management.
Implementations§
Source§impl<T> AsyncCompletion<T>
impl<T> AsyncCompletion<T>
Sourcepub fn create() -> (AsyncCompletionFuture<T>, SyncCompletionPtr)
pub fn create() -> (AsyncCompletionFuture<T>, SyncCompletionPtr)
Create a new async completion handler and return the context pointer for FFI
Returns a tuple of (future, context_ptr) where:
futurecan be awaited to get the resultcontext_ptrshould be passed to the FFI callback
Sourcepub unsafe fn complete_ok(context: SyncCompletionPtr, value: T)
pub unsafe fn complete_ok(context: SyncCompletionPtr, value: T)
Signal successful completion with a value
§Safety
The context pointer must be a valid pointer obtained from AsyncCompletion::new().
This function consumes the Arc reference, so it must only be called once per context.
Sourcepub unsafe fn complete_err(context: SyncCompletionPtr, error: String)
pub unsafe fn complete_err(context: SyncCompletionPtr, error: String)
Signal completion with an error
§Safety
The context pointer must be a valid pointer obtained from AsyncCompletion::new().
This function consumes the Arc reference, so it must only be called once per context.
Sourcepub unsafe fn complete_with_result(
context: SyncCompletionPtr,
result: Result<T, String>,
)
pub unsafe fn complete_with_result( context: SyncCompletionPtr, result: Result<T, String>, )
Auto Trait Implementations§
impl<T> Freeze for AsyncCompletion<T>
impl<T> RefUnwindSafe for AsyncCompletion<T>where
T: RefUnwindSafe,
impl<T> Send for AsyncCompletion<T>where
T: Send,
impl<T> Sync for AsyncCompletion<T>where
T: Sync,
impl<T> Unpin for AsyncCompletion<T>where
T: Unpin,
impl<T> UnwindSafe for AsyncCompletion<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more