pub struct WatchReceiver { /* private fields */ }Expand description
Receiving half of a fabric watch channel.
Reads the current value from shared memory and tracks the last-seen version to detect changes. Multiple receivers can be created from the same base offset (each tracking its own version independently).
Implementations§
Source§impl WatchReceiver
impl WatchReceiver
Sourcepub fn recv(&mut self) -> Result<Vec<u8>>
pub fn recv(&mut self) -> Result<Vec<u8>>
Read the current value from shared memory.
Updates the receiver’s tracked version to the current version, so
subsequent calls to changed will return false
until the sender publishes a new value.
Sourcepub fn changed(&self) -> Result<bool>
pub fn changed(&self) -> Result<bool>
Check whether the value has changed since the last recv call.
Compares the current version in shared memory against the version
recorded during the last recv(). Does not update the tracked
version; call recv() to consume the change.
Sourcepub fn wait_for_change(&mut self, max_polls: u32) -> Result<Vec<u8>>
pub fn wait_for_change(&mut self, max_polls: u32) -> Result<Vec<u8>>
Poll until the version changes, up to max_polls iterations.
Combines changed and recv in a tight
loop. Returns the new value once a change is detected, or
grafos_std::error::FabricError::LeaseExpired if max_polls is exhausted without
observing a version change.