pub struct MessagePort<'a>(/* private fields */);
Expand description
One of the two ports of a message channel
Allowing messages to be sent from one port and listening out for them arriving at the other.
Implementations§
Source§impl<'a> MessagePort<'a>
impl<'a> MessagePort<'a>
Sourcepub fn post_message<M: Any + Send + 'static>(&self, msg: M)
pub fn post_message<M: Any + Send + 'static>(&self, msg: M)
Send a message from the port.
Sourcepub fn set_onmessage<F: FnMut(Box<dyn Any + Send + 'static>) + Send + 'static>(
&self,
callback: F,
)
pub fn set_onmessage<F: FnMut(Box<dyn Any + Send + 'static>) + Send + 'static>( &self, callback: F, )
Register callback to run when a message arrives on the channel.
Only a single event handler is active at any time. Calling this method multiple times will override the previous event handler.
Sourcepub fn clear_onmessage(&self)
pub fn clear_onmessage(&self)
Unset the callback to run when a message arrives on the channel.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for MessagePort<'a>
impl<'a> RefUnwindSafe for MessagePort<'a>
impl<'a> Send for MessagePort<'a>
impl<'a> Sync for MessagePort<'a>
impl<'a> Unpin for MessagePort<'a>
impl<'a> UnwindSafe for MessagePort<'a>
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