pub struct SyncCompletion<T> { /* private fields */ }Expand description
A synchronous completion handler for async FFI callbacks
This type provides a way to block until an async callback completes
and retrieve the result. It uses Arc<(Mutex, Condvar)> internally
for thread-safe signaling between the callback and the waiting thread.
Implementations§
Source§impl<T> SyncCompletion<T>
impl<T> SyncCompletion<T>
Sourcepub fn new() -> (Self, SyncCompletionPtr)
pub fn new() -> (Self, SyncCompletionPtr)
Create a new completion handler and return the context pointer for FFI
Returns a tuple of (completion, context_ptr) where:
completionis used to wait for and retrieve 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 SyncCompletion::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 SyncCompletion::new().
This function consumes the Arc reference, so it must only be called once per context.