pub struct Event(/* private fields */);Expand description
An immutable event whose parent membership and derivation laws were checked.
Implementations§
Source§impl Event
impl Event
Sourcepub fn new(
body: EventBody,
parents: impl IntoIterator<Item = ContentId>,
resolve: impl Fn(&ContentId) -> Option<Event>,
) -> Result<Self, EventError>
pub fn new( body: EventBody, parents: impl IntoIterator<Item = ContentId>, resolve: impl Fn(&ContentId) -> Option<Event>, ) -> Result<Self, EventError>
Construct an event through the same boundary used for foreign bytes.
resolve supplies already admitted, authorized events. Root and payload
resolution remain the storage layer’s job; see the module’s limits.
§Errors
Returns EventError for missing/substituted links or invalid derivation.
Sourcepub fn admit(
raw: RawEvent,
resolve: impl Fn(&ContentId) -> Option<Event>,
) -> Result<Self, EventError>
pub fn admit( raw: RawEvent, resolve: impl Fn(&ContentId) -> Option<Event>, ) -> Result<Self, EventError>
Admit a decoded event after resolving and re-addressing every parent.
This checks one event against admitted parents, not an unbounded graph traversal. A durable reader must restore the closure in dependency order. An intervention with no derivation sources is generated from its explicit root at depth one; causal predecessors do not become its evidence.
§Errors
Returns EventError if links, origins, source relations, or depth fail.
Sourcepub fn parents(&self) -> &BTreeSet<ContentId>
pub fn parents(&self) -> &BTreeSet<ContentId>
Causal parents, separate from the publication packet’s predecessor.
Sourcepub fn id(&self) -> Result<ContentId, ContentError>
pub fn id(&self) -> Result<ContentId, ContentError>
Address of the complete event body and causal parent set.
§Errors
Propagates canonical encoding errors.
Sourcepub fn to_raw(&self) -> RawEvent
pub fn to_raw(&self) -> RawEvent
Clone the transparent encoding; modifications must pass admission again.
Sourcepub fn verify_elision(
&self,
unit: &Unit,
source: &Event,
bytes: &[u8],
) -> Result<Verified, EventError>
pub fn verify_elision( &self, unit: &Unit, source: &Event, bytes: &[u8], ) -> Result<Verified, EventError>
Verify an elision’s existing unit proof against its linked source event.
The unit proves the addressed byte span. The event adds inherited origin and depth, which v0’s byte-only unit cannot determine. This checks neither the pointer’s rendering nor the root’s authority; the consumer owns both.
§Errors
Refuses mismatched unit/source/root links, then propagates verify_unit.
Trait Implementations§
Source§impl ContentAddressable for Event
impl ContentAddressable for Event
Source§fn canonical_form(&self) -> Result<Vec<u8>, ContentError>
fn canonical_form(&self) -> Result<Vec<u8>, ContentError>
Source§fn content_id(&self) -> Result<ContentId, ContentError>
fn content_id(&self) -> Result<ContentId, ContentError>
Source§fn verify(&self, expected: &ContentId) -> Result<bool, ContentError>
fn verify(&self, expected: &ContentId) -> Result<bool, ContentError>
expected id. Read moreSource§fn ensure_content_id(&self, expected: &ContentId) -> Result<(), ContentError>
fn ensure_content_id(&self, expected: &ContentId) -> Result<(), ContentError>
Ok(false). Read more