Skip to main content

AtomicWrites

Struct AtomicWrites 

Source
pub struct AtomicWrites<C: Config, const N: usize, const A: usize> { /* private fields */ }
Expand description

The claims a node is holding (§7.15.3).

N is how many may be open at once and A how many attributes one may cover.

Implementations§

Source§

impl<C: Config, const N: usize, const A: usize> AtomicWrites<C, N, A>

Source

pub fn new() -> Self

A node holding no claims.

Source

pub fn len(&self) -> usize

How many claims are open.

Source

pub fn is_empty(&self) -> bool

Whether none are.

Source

pub fn iter(&self) -> impl Iterator<Item = &Claim<A>>

Every open claim.

Source

pub fn begin( &mut self, endpoint: EndpointId, cluster: ClusterId, writer: Writer, attributes: &[AttributeId], timeout: Duration, now: Instant, ) -> Result<(), Status>

§7.15.6.4’s BeginWrite.

The per-attribute statuses §7.15.6.4 BeginWrite step 3(a) asks for are the cluster’s to produce — only it knows whether an attribute supports atomic writes or whether it has room to pend a value. What this decides is the two rules that are about the table:

  • a client already holding a claim on the same cluster and endpoint is Status::InvalidInState (§7.15.6.4 BeginWrite step 1);
  • an attribute another client is already using is Status::Busy (§7.15.6.4 BeginWrite step 3(a)(iii)).

attributes must be non-empty and free of duplicates — §7.15.6.4’s rules 1 and 2, both Status::InvalidCommand.

Source

pub fn finish( &mut self, endpoint: EndpointId, cluster: ClusterId, writer: Writer, attributes: &[AttributeId], ) -> Result<(), Status>

§7.15.6’s CommitWrite and RollbackWrite: releases the claim.

Both end the claim; what differs is whether the cluster applies its pending values, which it does on the strength of the RequestType it was given. Returns Status::InvalidInState when the client holds no matching claim — §7.15.6’s rule 1 for CommitWrite, which requires the attribute set to match too, “irrespective of order”.

Source

pub fn find( &self, endpoint: EndpointId, cluster: ClusterId, writer: Writer, ) -> Option<&Claim<A>>

The claim a client holds on a cluster instance, if any.

Source

pub fn holder( &self, endpoint: EndpointId, cluster: ClusterId, attribute: AttributeId, ) -> Option<Writer>

Who holds a claim covering one attribute, if anybody.

Source

pub fn check_write( &self, endpoint: EndpointId, cluster: ClusterId, writer: Option<Writer>, attribute: AttributeId, ) -> Result<(), Status>

Whether a write to an attribute with the Atomic quality may proceed (§7.15.3).

If a server receives a Write Request for an attribute that is not associated with an Atomic Write State that is also associated with the client making the request, the server SHALL return the error code INVALID_IN_STATE.

Both halves matter, and they are different failures. A write with no claim is a client that skipped BeginWrite; a write against somebody else’s claim is a client trying to change values another client has staged and is about to commit.

Source

pub fn reap(&mut self, now: Instant) -> usize

Drops every claim whose timeout has passed, returning how many — §7.15.6.4 BeginWrite step 3(e)(iii).

If the server does not receive a matching AtomicRequest with a RequestType of CommitWrite from the associated client before the timeout … the server SHALL roll back any pending writes and discard the atomic write.

Without this a client that crashed mid-write would hold its attributes against every other client until the device was restarted.

Source

pub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize

Drops every claim a fabric holds — what RemoveFabric must do.

Source

pub fn next_deadline(&self) -> Option<Instant>

When AtomicWrites::reap next has something to do.

Trait Implementations§

Source§

impl<C: Debug + Config, const N: usize, const A: usize> Debug for AtomicWrites<C, N, A>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<C: Config, const N: usize, const A: usize> Default for AtomicWrites<C, N, A>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<C, const N: usize, const A: usize> Forget for AtomicWrites<C, N, A>

§

impl<C, const N: usize, const A: usize> Freeze for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: Freeze, PhantomData<C>: Freeze,

§

impl<C, const N: usize, const A: usize> Move for AtomicWrites<C, N, A>

§

impl<C, const N: usize, const A: usize> RefUnwindSafe for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: RefUnwindSafe, PhantomData<C>: RefUnwindSafe,

§

impl<C, const N: usize, const A: usize> Send for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: Send, PhantomData<C>: Send,

§

impl<C, const N: usize, const A: usize> Sync for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: Sync, PhantomData<C>: Sync,

§

impl<C, const N: usize, const A: usize> Unpin for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: Unpin, PhantomData<C>: Unpin,

§

impl<C, const N: usize, const A: usize> UnsafeUnpin for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: UnsafeUnpin, PhantomData<C>: UnsafeUnpin,

§

impl<C, const N: usize, const A: usize> UnwindSafe for AtomicWrites<C, N, A>
where VecInner<Claim<A>, usize, VecStorageInner<[MaybeUninit<Claim<A>>; N]>>: UnwindSafe, PhantomData<C>: 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.