pub struct PkPromise { /* private fields */ }Expand description
A simple implementation of Pollable based on multi-thread.
This is like Promise in JavaScript.
Implementations§
Source§impl PkPromise
impl PkPromise
Sourcepub fn execute<T>(function: T) -> Pin<Box<Self>>
pub fn execute<T>(function: T) -> Pin<Box<Self>>
Creates a new PkPromise and executes a function in a new thread.
The provided function function will be executed in a separate thread.
It receives a resolve closure as an argument. The user’s function
should call this resolve closure with the result data (Vec<u8>)
when the asynchronous operation is complete.
§Arguments
function: A closure that takes aresolveclosure and performs the asynchronous task. Theresolveclosure should be called with the result data when the task finishes successfully.
§Returns
A new PkPromise instance that can be polled to check the status
of the asynchronous operation.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PkPromise
impl RefUnwindSafe for PkPromise
impl Send for PkPromise
impl Sync for PkPromise
impl Unpin for PkPromise
impl UnwindSafe for PkPromise
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