pub struct PkPollable { /* private fields */ }Expand description
A simple implementation of Pollable based on multi-thread.
This is like Promise in JavaScript.
Implementations§
Source§impl PkPollable
impl PkPollable
Sourcepub fn execute<T>(function: T) -> Pin<Box<Self>>
pub fn execute<T>(function: T) -> Pin<Box<Self>>
Creates a new PkPollable 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 PkPollable instance that can be polled to check the status
of the asynchronous operation.
Trait Implementations§
Source§impl Clone for PkPollable
impl Clone for PkPollable
Source§fn clone(&self) -> PkPollable
fn clone(&self) -> PkPollable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PkPollable
impl RefUnwindSafe for PkPollable
impl Send for PkPollable
impl Sync for PkPollable
impl Unpin for PkPollable
impl UnwindSafe for PkPollable
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