Skip to main content

Event

Struct Event 

Source
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>

Source

pub const fn subscription(&self) -> Subscription

The caller subscription this event was routed to.

Source

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.

Source

pub fn location(&self) -> &Location

The change’s location relative to its watched root.

A synthetic widen Rescan reports the empty (root-anchored) location, since its key is the root.

Source

pub fn kind(&self) -> &EventKind<C>

What happened.

Source

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.

Source

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.

Source

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).

Source

pub fn is_rescan(&self) -> bool

Whether this is a Rescan.

Source

pub fn reaches(&self, key: &[C]) -> bool
where 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.

Source

pub fn move_from(&self) -> Option<&[C]>

The move’s source key, if this is a whole Moved delivery — the second endpoint the coalescer keys on (design §6, move-is-atomic).

Some iff this delivery is a whole move; the destination is key. A synthesized move-out / move-in projection is a plain Removed / Created and reports None.

Source§

impl<V> Event<OsString, V>

Source

pub fn path(&self) -> PathBuf

The change’s absolute path — the fs-source convenience over key, reconstructed from the located key’s OsString components.

This allocates a fresh PathBuf from the key components on every call; key is the allocation-free &[C] accessor for hot paths.

Source

pub fn moved_from_path(&self) -> Option<PathBuf>

The move’s source as an absolute path, if this is a whole Moved delivery — the fs-source convenience over move_from, mirroring path.

This allocates a fresh PathBuf from the source key’s components on every call; move_from is the allocation-free Option<&[C]> accessor for hot paths.

Trait Implementations§

Source§

impl<C: Clone, V: Clone> Clone for Event<C, V>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug, V: Debug> Debug for Event<C, V>

Source§

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

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

impl<C: Eq, V: Eq> Eq for Event<C, V>

Source§

impl<C: PartialEq, V: PartialEq> PartialEq for Event<C, V>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<C: PartialEq, V: PartialEq> StructuralPartialEq for Event<C, V>

Auto Trait Implementations§

§

impl<C, V> Freeze for Event<C, V>
where Vec<C>: Freeze, EventKind<C>: Freeze, Option<V>: Freeze,

§

impl<C, V> RefUnwindSafe for Event<C, V>

§

impl<C, V> Send for Event<C, V>
where Vec<C>: Send, EventKind<C>: Send, Option<V>: Send,

§

impl<C, V> Sync for Event<C, V>
where Vec<C>: Sync, EventKind<C>: Sync, Option<V>: Sync,

§

impl<C, V> Unpin for Event<C, V>
where Vec<C>: Unpin, EventKind<C>: Unpin, Option<V>: Unpin,

§

impl<C, V> UnsafeUnpin for Event<C, V>

§

impl<C, V> UnwindSafe for Event<C, V>

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> AutoreleaseSafe for T
where T: ?Sized,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.