pub enum Notification {
DatabaseWrite {
root_id: ID,
previous_tips: Snapshot,
post_tips: Snapshot,
source: WriteSource,
},
}Expand description
Server-initiated push to the client, interleaved with normal responses at any point after a connection has authenticated.
Notifications are not solicited by a specific request; the client signs up
for them with a DatabaseOp::SubscribeWrites and unsubscribes by
dropping the connection or sending DatabaseOp::UnsubscribeWrites.
Notifications are triggered only by settled-state writes — i.e.
entries that have passed local verification on the daemon. An entry
that arrives Unverified (via sync, or as a SubmitSignedEntry body)
is ingested silently and only produces a notification once the daemon’s
verification pass promotes it to Verified.
This does not mean the bracket contains only Verified entries. The
cursors are raw DAG frontiers (Backend::snapshot), not the Verified
frontier, so an Unverified or Failed entry sitting as a raw tip
falls inside every subsequent bracket and
Database::ids_added will enumerate it.
A subscriber that expands a bracket and fetches the IDs can therefore
observe entries that failed the daemon’s auth settings. Consumers that
care must filter on verification status themselves; locally that is
Backend::get_verification_status, and over the wire there is
currently no way to do it at all — treat bracket-derived IDs as
untrusted until read back through a gated path.
A second consequence of the raw-frontier cursor: because it advances
past a still-Unverified tip, a later verify() that promotes that
entry fires with previous_tips == post_tips for the subscriber, so
ids_added returns empty and the promotion is never signalled. An
entry can be reported once while untrusted and never mentioned again.
The frame carries cursor brackets only — no entry payloads, no entry
IDs. Subscribers that need to enumerate the new entries expand the
brackets locally via
Database::ids_added. This decision
has two consequences:
- Security: per-tree Read is gated once at
SubscribeWrites; the publisher fan-out does not re-check on each event. Shipping cursors only means a subscriber whose permission is revoked mid-session can at most learn that some write happened on the tree — never the contents of those writes, which would only reach the client through an explicit, currently-gated read. - Efficiency: sync ingest can batch many entries; a cursor pair is constant-size regardless of batch width.
Variants§
DatabaseWrite
A settled-state write landed on the daemon for root_id.
previous_tipsis the daemon-side subscription cursor at the moment of this fire — i.e. theprevious_tipsof the event the daemon dispatched to this subscription’s callback. Useful for thin-forwarder topologies and trace/debug.post_tipsis the daemon’s tips after this write. The client uses it to advance every local per-callback cursor for this tree — each local callback’s next event will haveprevious_tips = post_tips(the cursor moves forward by exactly one event).sourcedistinguishes local-vs-sync for consumers that want to branch.
Trait Implementations§
Source§impl Clone for Notification
impl Clone for Notification
Source§fn clone(&self) -> Notification
fn clone(&self) -> Notification
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Notification
impl Debug for Notification
Source§impl<'de> Deserialize<'de> for Notification
impl<'de> Deserialize<'de> for Notification
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Notification
impl RefUnwindSafe for Notification
impl Send for Notification
impl Sync for Notification
impl Unpin for Notification
impl UnsafeUnpin for Notification
impl UnwindSafe for Notification
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