WatchReceiver

Struct WatchReceiver 

Source
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

Source

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.

Source

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.

Source

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.

Source

pub fn version(&self) -> Result<u64>

Read the current version counter from shared memory.

This returns the version stored in the arena, not the receiver’s last-seen version. Compare with the result of a previous recv() to detect changes, or use changed for convenience.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.