watch
Generated Rust API reference for byte_engine.
byte_engine / ui / watch
Module watch
A shared latest-value cell whose changes wake the UI components watching it.
A Watch holds one value and a version that every write advances. A component that
subscribes awaits Subscriber::changed, which sleeps until the version moves past the
one it last read, then hands out the current value. Writes that land between two reads collapse into one wake,
so a producer running far faster than the display never queues work for the UI; the component only ever sees
the newest state at its next poll. Writers may live on any thread, and a write from another thread reaches the
host through the engine's task wakers, so nothing polls while the value is idle.
Quick Reference
| Item | Kind | Description |
|---|---|---|
Watch | struct | The Watch struct shares a value between its writers and the components waiting for it to change. |
Subscriber | struct | The Subscriber struct tracks which version of a [Watch] one component has already seen. |
Changed | struct | The Changed struct is the wait for the next write to a watched value. |
Structs
Watch<T>
struct Watch<T>();Defined in crates/byte-engine/src/ui/watch.rs:30
The Watch struct shares a value between its writers and the components waiting for it to change.
Implementations
-
fn new(value: T) -> Self -
fn update<R>(&self, update: impl FnOnce(&mut T) -> R) -> RMutates the value in place, then wakes every subscriber waiting on it.
-
fn set(&self, value: T) -
fn read(&self) -> utils::sync::MutexGuard<'_, T>Reads the value without waiting or affecting any subscriber.
-
fn subscribe(&self) -> Subscriber<T>Related:
SubscriberStarts watching from the current version, so the first wait resolves on the next write.
Trait Implementations
impl<T> ArchivePointee for Watch<T>
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for Watch<T>
impl<T> Clone for Watch<T>
-
fn clone(&self) -> Self
impl<T: Default> Default for Watch<T>
-
fn default() -> Self
impl<T> Downcast for Watch<T>
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl<T> DowncastSync for Watch<T>
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl<T> Instrument for Watch<T>
impl<T> LayoutRaw for Watch<T>
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for Watch<T>
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl<T> Pointee for Watch<T>
-
type Metadata = ()
impl<T> Read for Watch<T>
impl<R> ReadPrimitive for Watch<T>
impl<T> WithSubscriber for Watch<T>
Subscriber<T>
struct Subscriber<T> {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/ui/watch.rs:84-87
The Subscriber struct tracks which version of a Watch one component has already seen.
Implementations
-
fn changed(&mut self) -> Changed<'_, T>Related:
ChangedResolves with the value once it has changed since the last read through this subscriber.
-
fn read(&mut self) -> utils::sync::MutexGuard<'_, T>Reads the current value and marks it seen, so the next wait only resolves on a later write.
Trait Implementations
impl<T> ArchivePointee for Subscriber<T>
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for Subscriber<T>
impl<T> Downcast for Subscriber<T>
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl<T> DowncastSync for Subscriber<T>
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl<T> Instrument for Subscriber<T>
impl<T> LayoutRaw for Subscriber<T>
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for Subscriber<T>
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl<T> Pointee for Subscriber<T>
-
type Metadata = ()
impl<T> Read for Subscriber<T>
impl<T> WithSubscriber for Subscriber<T>
Changed<'a, T>
struct Changed<'a, T> {
// [REDACTED: Private Fields]
}Defined in crates/byte-engine/src/ui/watch.rs:103-106
The Changed struct is the wait for the next write to a watched value.
Trait Implementations
impl<T> ArchivePointee for Changed<'a, T>
-
type ArchivedMetadata = () -
fn pointer_metadata(_: &<T as ArchivePointee>::ArchivedMetadata) -> <T as Pointee>::Metadata
impl<ST> CastableFrom for Changed<'a, T>
impl<T> Downcast for Changed<'a, T>
-
fn into_any(self: Box<T>) -> Box<dyn Any> -
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any> -
fn as_any(&self) -> &dyn Any -
fn as_any_mut(&mut self) -> &mut dyn Any
impl<T> DowncastSync for Changed<'a, T>
-
fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>
impl<T> FusedFuture for Changed<'_, T>
-
fn is_terminated(&self) -> bool
impl<T> Future for Changed<'a, T>
-
type Output = MutexGuard<'a, RawMutex, T> -
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<<Self as >::Output>
impl<T> FutureExt for Changed<'a, T>
impl<T> Instrument for Changed<'a, T>
impl IntoFuture for Changed<'a, T>
-
type Output = <F as Future>::Output -
type IntoFuture = F -
fn into_future(self) -> <F as IntoFuture>::IntoFuture
impl<T> LayoutRaw for Changed<'a, T>
-
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
impl<T, N1> Niching for Changed<'a, T>
-
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool -
fn resolve_niched(out: Place<NichedOption<T, N1>>)
impl<T> Pointee for Changed<'a, T>
-
type Metadata = ()