Struct envelope::EventsBatch
zaun_community_protocol::envelope::EventsBatch · Struct
pub struct EventsBatch { … }A validated events batch. Its events are processed in order, exactly as individual
events; the batch itself has no stream, sequence or timestamp.
Fields
Section titled “Fields”v: u16
Section titled “v: u16”Envelope version.
community_id: CommunityId
Section titled “community_id: CommunityId”The community; every element carries the same one.
events: Vec<EventEnvelope>
Section titled “events: Vec<EventEnvelope>”The events, in order.
Methods
Section titled “Methods”pub const fn new(community_id: CommunityId, events: Vec<EventEnvelope>) -> SelfA batch of events for community_id at PROTOCOL_VERSION.
pub fn parse(json: &str) -> Result<Self, BatchError>Parses a whole (reassembled) batch envelope. All or nothing: the first bad element fails the batch.
SPEC: the protocol says each element’s v and community_id MUST equal the batch’s; a batch
carrying stream, sequence or timestamp is not rejected (unknown fields are ignored).
Errors
Section titled “Errors”BatchError for the first rule broken.
serialize
Section titled “serialize”pub fn serialize(&self) -> Result<String, BatchError>The batch envelope as JSON text, after checking the same rules as Self::parse.
Errors
Section titled “Errors”BatchError for the first rule an element breaks.
Trait implementations
Section titled “Trait implementations”Clone, Debug