Struct gloo_worker::WorkerScope
source · pub struct WorkerScope<W: Worker> { /* private fields */ }
Expand description
This struct holds a reference to a component and to a global scheduler.
Implementations§
source§impl<W> WorkerScope<W>where
W: Worker + 'static,
impl<W> WorkerScope<W>where W: Worker + 'static,
sourcepub fn send_message<T>(&self, msg: T)where
T: Into<W::Message>,
pub fn send_message<T>(&self, msg: T)where T: Into<W::Message>,
Send a message to the worker
sourcepub fn callback<F, IN, M>(&self, function: F) -> Rc<dyn Fn(IN)>where
M: Into<W::Message>,
F: Fn(IN) -> M + 'static,
pub fn callback<F, IN, M>(&self, function: F) -> Rc<dyn Fn(IN)>where M: Into<W::Message>, F: Fn(IN) -> M + 'static,
Create a callback which will send a message to the worker when invoked.
sourcepub fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Rc<dyn Fn(IN)>where
M: Into<W::Message>,
FU: Future<Output = M> + 'static,
FN: Fn(IN) -> FU + 'static,
Available on crate feature futures
only.
pub fn callback_future<FN, FU, IN, M>(&self, function: FN) -> Rc<dyn Fn(IN)>where M: Into<W::Message>, FU: Future<Output = M> + 'static, FN: Fn(IN) -> FU + 'static,
futures
only.This method creates a callback which returns a Future which returns a message to be sent back to the worker
Panics
If the future panics, then the promise will not resolve, and will leak.
sourcepub fn send_future<F, M>(&self, future: F)where
M: Into<W::Message>,
F: Future<Output = M> + 'static,
Available on crate feature futures
only.
pub fn send_future<F, M>(&self, future: F)where M: Into<W::Message>, F: Future<Output = M> + 'static,
futures
only.This method processes a Future that returns a message and sends it back to the worker.
Panics
If the future panics, then the promise will not resolve, and will leak.
Trait Implementations§
source§impl<W: Worker> Clone for WorkerScope<W>
impl<W: Worker> Clone for WorkerScope<W>
Auto Trait Implementations§
impl<W> !RefUnwindSafe for WorkerScope<W>
impl<W> !Send for WorkerScope<W>
impl<W> !Sync for WorkerScope<W>
impl<W> Unpin for WorkerScope<W>
impl<W> !UnwindSafe for WorkerScope<W>
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