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>
impl<C: Config, const N: usize, const A: usize> AtomicWrites<C, N, A>
Sourcepub fn begin(
&mut self,
endpoint: EndpointId,
cluster: ClusterId,
writer: Writer,
attributes: &[AttributeId],
timeout: Duration,
now: Instant,
) -> Result<(), Status>
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.
Sourcepub fn finish(
&mut self,
endpoint: EndpointId,
cluster: ClusterId,
writer: Writer,
attributes: &[AttributeId],
) -> Result<(), Status>
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”.
Sourcepub fn find(
&self,
endpoint: EndpointId,
cluster: ClusterId,
writer: Writer,
) -> Option<&Claim<A>>
pub fn find( &self, endpoint: EndpointId, cluster: ClusterId, writer: Writer, ) -> Option<&Claim<A>>
The claim a client holds on a cluster instance, if any.
Sourcepub fn holder(
&self,
endpoint: EndpointId,
cluster: ClusterId,
attribute: AttributeId,
) -> Option<Writer>
pub fn holder( &self, endpoint: EndpointId, cluster: ClusterId, attribute: AttributeId, ) -> Option<Writer>
Who holds a claim covering one attribute, if anybody.
Sourcepub fn check_write(
&self,
endpoint: EndpointId,
cluster: ClusterId,
writer: Option<Writer>,
attribute: AttributeId,
) -> Result<(), Status>
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.
Sourcepub fn reap(&mut self, now: Instant) -> usize
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.
Sourcepub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize
pub fn remove_fabric(&mut self, fabric: FabricIndex) -> usize
Drops every claim a fabric holds — what RemoveFabric must do.
Sourcepub fn next_deadline(&self) -> Option<Instant>
pub fn next_deadline(&self) -> Option<Instant>
When AtomicWrites::reap next has something to do.