pub struct WriteStamp {
pub observed_at: Instant,
pub source: ChangeSource,
}Expand description
When a value was observed, and by what.
The critical word is observed, not written. A fetch() reads the
device at request time but only calls set_property when the SOAP response
comes back, which can be hundreds of milliseconds later. If the stamp were
taken at write time, a slow fetch() would always look newer than an event
that arrived while it was in flight, and would overwrite a fresher value
with a stale one — the speaker would visibly snap back to its old volume.
So the caller stamps the moment the observation was made
(WriteStamp::observed_at) and the store rejects any write that is older
than the one already recorded. Event and local-action writes have no such
gap and use WriteStamp::now.
Fields§
§observed_at: InstantWhen the underlying observation was made — not when it was written.
source: ChangeSourceWhat produced the observation.
Implementations§
Source§impl WriteStamp
impl WriteStamp
Sourcepub fn now(source: ChangeSource) -> WriteStamp
pub fn now(source: ChangeSource) -> WriteStamp
Stamp an observation made right now.
Correct for ChangeSource::Event and ChangeSource::LocalAction,
where observation and write happen in the same breath.
Sourcepub fn observed_at(source: ChangeSource, observed_at: Instant) -> WriteStamp
pub fn observed_at(source: ChangeSource, observed_at: Instant) -> WriteStamp
Stamp an observation made at a known earlier instant.
Use this for fetch(): pass the Instant captured before the SOAP
request, so a response that lands after a newer event loses to it.
Trait Implementations§
Source§impl Clone for WriteStamp
impl Clone for WriteStamp
Source§fn clone(&self) -> WriteStamp
fn clone(&self) -> WriteStamp
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more