pub struct Event<C, V> { /* private fields */ }Expand description
One change, delivered to a caller Subscription, keyed by components of type
C and carrying the caller value type V.
A single raw source event fans out to every overlapping subscription that covers
it (design §5), each seeing it retagged with its own subscription
id. The event is keyed by its key — a Vec<C> of components, the
coordinate coverage and coalescing operate in (for the fs source, the change
path’s components).
§Epoch is umbrella-relative, not the raw fs epoch
epoch is the umbrella’s own per-subscription monotone stamp,
assigned by the driver at delivery time (design §8) — not the raw source epoch
(tributary-fs’s per-event epoch), which is per-ScopeId and restarts at
Epoch::START on every new kernel arm. Because a subscription is delivered
from different fs roots over its lifetime (a widen re-points it onto a
freshly-armed wider root whose epoch sequence restarts at 0), the raw fs epoch is
not a valid dominance order across a re-point; the driver rebases every delivered
event into the subscription’s own monotone space so the no-silent-loss /
re-enumeration contract holds end-to-end.
Implementations§
Source§impl<C, V> Event<C, V>
impl<C, V> Event<C, V>
Sourcepub const fn subscription(&self) -> Subscription
pub const fn subscription(&self) -> Subscription
The caller subscription this event was routed to.
Sourcepub fn key(&self) -> &[C]
pub fn key(&self) -> &[C]
The change’s located key — its components in C-space (for the fs source, the
change path’s components). The coordinate coverage and coalescing key on.
Sourcepub const fn epoch(&self) -> Epoch
pub const fn epoch(&self) -> Epoch
This subscription’s monotone reconciliation epoch for this event.
The umbrella-relative stamp (design §8), not the raw source epoch
(SourceEvent::epoch) — see the type docs. A delivered
Rescan carries a stamp that strictly dominates every event
previously delivered to this subscription; events with epochs dominated by a
delivered Rescan may have been dropped, and everything they described is
covered by re-enumerating the Rescan’s key.
Sourcepub const fn change_id(&self) -> Option<ChangeId>
pub const fn change_id(&self) -> Option<ChangeId>
The change’s unique id (monotonic per source), when the source supplied one.
A synthetic event (a widen Rescan, a coalesced-churn
Modified, or a move-out/move-in projection) has no single
underlying source change and so reports None — as does an event from a source
that mints no ids; dominance rides the epoch, not a change id.
Sourcepub const fn value(&self) -> Option<&V>
pub const fn value(&self) -> Option<&V>
The caller value attributed to this delivery (design §3): the value of the
subscription this event was routed to, baked on by the
driver at emit time.
This is the per-event attribution, and it is stable across teardown: the
value is captured when the event is minted (while its owning subscription is live),
so a consumer draining a queued event after the owner has torn down — when the
WatchView has been emptied and
resolve would answer None — still attributes it
from here. Prefer this to attribute a delivered event; use
WatchView::resolve /
covering for the live “is key k watched, and by
whom” query (membership + pre-watch dedup), which reflects the current watch-set
rather than the moment a given event was emitted.
None only when the event has no live owning subscription (a pure-test fixture, or
a delivery whose subscription raced retirement).
Sourcepub fn reaches(&self, key: &[C]) -> boolwhere
C: PartialEq,
pub fn reaches(&self, key: &[C]) -> boolwhere
C: PartialEq,
Whether this event bears on key: it names key exactly, or it is a
Rescan at key or an ancestor of it (a rescan obliges
re-enumeration of everything below its key). The dispatch idiom every
re-enumeration-class consumer needs.