pub struct WindowChannel { /* private fields */ }Expand description
Thread-safe cross-window communication channel.
Messages sent to a WindowId are queued until the window drains them via
drain_messages. The channel is cheaply
cloneable via Clone (backed by an Arc).
Implementations§
Source§impl WindowChannel
impl WindowChannel
Sourcepub fn send(
&self,
to: WindowId,
payload: impl Into<String>,
) -> Result<(), UiError>
pub fn send( &self, to: WindowId, payload: impl Into<String>, ) -> Result<(), UiError>
Enqueue a message for the target window.
§Errors
Returns UiError::Focus when the internal lock is poisoned
(extremely rare; only occurs after a panic inside drain_messages).
Sourcepub fn drain_messages(&self, id: WindowId) -> Result<Vec<String>, UiError>
pub fn drain_messages(&self, id: WindowId) -> Result<Vec<String>, UiError>
Drain all queued messages for the given window, returning them in arrival order. The internal queue for that window is cleared.
§Errors
Returns UiError::Focus when the lock is poisoned.
Sourcepub fn pending_count(&self, id: WindowId) -> usize
pub fn pending_count(&self, id: WindowId) -> usize
Return the number of pending messages for a window without consuming them.
Trait Implementations§
Source§impl Clone for WindowChannel
impl Clone for WindowChannel
Source§fn clone(&self) -> WindowChannel
fn clone(&self) -> WindowChannel
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for WindowChannel
impl Debug for WindowChannel
Source§impl Default for WindowChannel
impl Default for WindowChannel
Source§fn default() -> WindowChannel
fn default() -> WindowChannel
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for WindowChannel
impl RefUnwindSafe for WindowChannel
impl Send for WindowChannel
impl Sync for WindowChannel
impl Unpin for WindowChannel
impl UnsafeUnpin for WindowChannel
impl UnwindSafe for WindowChannel
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more