Struct gloo::worker::WorkerScope
source · pub struct WorkerScope<W>where
W: Worker,{ /* private fields */ }
Available on crate feature
worker
only.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 respond(&self, id: HandlerId, output: <W as Worker>::Output)
pub fn respond(&self, id: HandlerId, output: <W as Worker>::Output)
Send response to a worker bridge.
sourcepub fn send_message<T>(&self, msg: T)where
T: Into<<W as Worker>::Message>,
pub fn send_message<T>(&self, msg: T)where T: Into<<W as Worker>::Message>,
Send a message to the worker
sourcepub fn callback<F, IN, M>(&self, function: F) -> Rc<dyn Fn(IN), Global>where
M: Into<<W as Worker>::Message>,
F: Fn(IN) -> M + 'static,
pub fn callback<F, IN, M>(&self, function: F) -> Rc<dyn Fn(IN), Global>where M: Into<<W as Worker>::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), Global>where
M: Into<<W as Worker>::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), Global>where M: Into<<W as Worker>::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 as Worker>::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 as Worker>::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> Clone for WorkerScope<W>where
W: Worker,
impl<W> Clone for WorkerScope<W>where W: Worker,
source§fn clone(&self) -> WorkerScope<W>
fn clone(&self) -> WorkerScope<W>
Returns a copy 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<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