pub struct WriteEvent { /* private fields */ }Expand description
A cursor-advance notification delivered to a write callback.
A WriteEvent carries no entry payloads — only the cursor brackets
(previous_tips → post_tips) and the WriteSource. Callbacks that
only care that something changed (cache invalidation, UI wake-ups)
can act on the event directly without touching the wire or the DAG.
Callbacks that need to enumerate or fetch the new entries call
Database::ids_added with the brackets:
// Enumerate the IDs added between the two cursors
let new_ids = db.ids_added(event.previous_tips(), event.post_tips()).await?;
for id in new_ids {
// … fetch entry bodies via db.get_entry(id) if needed …
}Cursor semantics: previous_tips is this callback’s frontier before
this fire — the user-supplied initial tips on the first fire, then the
preceding fire’s post_tips on each subsequent fire. The cursor
advances to post_tips synchronously before the user closure is
awaited, so the next fire is guaranteed to bracket against the latest
observed frontier even if the closure is slow.
Triggered only by settled-state (Verified) writes, but the cursors are
raw DAG frontiers — the bracket can span Unverified/Failed entries,
which Database::ids_added will
enumerate. See
Notification::DatabaseWrite
rustdoc for the full verification contract.
Implementations§
Source§impl WriteEvent
impl WriteEvent
Sourcepub fn previous_tips(&self) -> &Snapshot
pub fn previous_tips(&self) -> &Snapshot
Get the database state at this callback’s cursor before this fire.
The first fire on a freshly-registered callback returns the
initial snapshot passed at registration time. Subsequent fires
return the previous fire’s post_tips.
Sourcepub fn post_tips(&self) -> &Snapshot
pub fn post_tips(&self) -> &Snapshot
Get the database state at this callback’s cursor after this fire.
The cursor advances to this value before the callback is awaited,
so the next fire on the same callback will have
previous_tips() == this fire's post_tips().
Sourcepub fn source(&self) -> WriteSource
pub fn source(&self) -> WriteSource
The source of this write (local commit or remote sync).
Trait Implementations§
Source§impl Clone for WriteEvent
impl Clone for WriteEvent
Source§fn clone(&self) -> WriteEvent
fn clone(&self) -> WriteEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WriteEvent
impl RefUnwindSafe for WriteEvent
impl Send for WriteEvent
impl Sync for WriteEvent
impl Unpin for WriteEvent
impl UnsafeUnpin for WriteEvent
impl UnwindSafe for WriteEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more