pub struct TokioFuturePollable { /* private fields */ }Available on crate features
std and tokio-runtime only.Expand description
A Pollable adapter that spawns a Future onto the Tokio runtime and
exposes its completion through the Pollable interface.
§Example with PkHashmapMethod
use pk_command::{PkCommand, PkHashmapMethod, tokio_adapter::TokioFuturePollable};
let method_impl = Box::new(move |param: Option<Vec<u8>>| {
TokioFuturePollable::from_future(async move {
// do_something_with(param);
Ok(Some(b"async result".to_vec()))
})
});
let methods = PkHashmapMethod::new(vec![("ASYNC".to_string(), method_impl)]);Implementations§
Source§impl TokioFuturePollable
impl TokioFuturePollable
Sourcepub fn from_future<F>(fut: F) -> Pin<Box<dyn Pollable>>
pub fn from_future<F>(fut: F) -> Pin<Box<dyn Pollable>>
Spawn a future onto the Tokio runtime and return a Pollable that
becomes ready when the future completes.
The provided Future must output Result<Option<Vec<u8>>, String>.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TokioFuturePollable
impl RefUnwindSafe for TokioFuturePollable
impl Send for TokioFuturePollable
impl Sync for TokioFuturePollable
impl Unpin for TokioFuturePollable
impl UnwindSafe for TokioFuturePollable
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