Skip to main content

DataVersions

Struct DataVersions 

Source
pub struct DataVersions<const N: usize> { /* private fields */ }
Expand description

A fixed-capacity table of §7.10.3’s cluster data versions.

N is how many cluster instances the node has — endpoints times the clusters on each, which is const data, so the number is known when the node is designed. A table that fills stops tracking new instances rather than evicting a live one: an evicted version would be handed out again later and tell a client its cache is current when it is not, which is worse than having no version at all.

Implementations§

Source§

impl<const N: usize> DataVersions<N>

Source

pub fn new(seed: u32) -> Self

An empty table whose first version is derived from seed.

§7.10.3: “A cluster data version SHALL be initialized randomly when it is first published.” seed should come from Rng. Starting every cluster at zero on every boot is what lets a client keep a cache across a device’s restart and be wrong about it: the versions match, the data does not.

Source

pub fn drain_changes(&self) -> Vec<(EndpointId, ClusterId), N>

The cluster instances whose data changed since this was last called, and clears them.

Drained rather than read, because the caller is expected to hand each one to SubscriptionTable::note_cluster_change and a change reported twice is a report sent twice.

This is the seam between “a cluster changed” and “a subscriber is owed a report”. Writes that arrive through the interaction model land here on their own; a cluster that changes on its own — a sensor reading, a switch somebody pressed — is the one that has to call DataVersionSource::touch, which §7.10.3 requires of it regardless.

Source

pub fn len(&self) -> usize

How many cluster instances are being tracked.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been published yet.

Trait Implementations§

Source§

impl<const N: usize> DataVersionSource for DataVersions<N>

Source§

fn version(&self, endpoint: EndpointId, cluster: ClusterId) -> u32

The current version of one cluster instance, allocating one if it has never been read.
Source§

fn touch(&self, endpoint: EndpointId, cluster: ClusterId)

Records that an attribute of this cluster instance changed. Read more
Source§

impl<const N: usize> Debug for DataVersions<N>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const N: usize> !Freeze for DataVersions<N>

§

impl<const N: usize> !RefUnwindSafe for DataVersions<N>

§

impl<const N: usize> !Sync for DataVersions<N>

§

impl<const N: usize> Forget for DataVersions<N>

§

impl<const N: usize> Move for DataVersions<N>

§

impl<const N: usize> Send for DataVersions<N>
where RefCell<VecInner<Entry, usize, VecStorageInner<[MaybeUninit<Entry>; N]>>>: Send, RefCell<VecInner<(u16, u32), usize, VecStorageInner<[MaybeUninit<(u16, u32)>; N]>>>: Send,

§

impl<const N: usize> Unpin for DataVersions<N>
where RefCell<VecInner<Entry, usize, VecStorageInner<[MaybeUninit<Entry>; N]>>>: Unpin, RefCell<VecInner<(u16, u32), usize, VecStorageInner<[MaybeUninit<(u16, u32)>; N]>>>: Unpin,

§

impl<const N: usize> UnsafeUnpin for DataVersions<N>
where RefCell<VecInner<Entry, usize, VecStorageInner<[MaybeUninit<Entry>; N]>>>: UnsafeUnpin, RefCell<VecInner<(u16, u32), usize, VecStorageInner<[MaybeUninit<(u16, u32)>; N]>>>: UnsafeUnpin,

§

impl<const N: usize> UnwindSafe for DataVersions<N>
where RefCell<VecInner<Entry, usize, VecStorageInner<[MaybeUninit<Entry>; N]>>>: UnwindSafe, RefCell<VecInner<(u16, u32), usize, VecStorageInner<[MaybeUninit<(u16, u32)>; N]>>>: UnwindSafe,

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.