Skip to content

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.

Envelope version.

The community; every element carries the same one.

The events, in order.

pub const fn new(community_id: CommunityId, events: Vec<EventEnvelope>) -> Self

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

BatchError for the first rule broken.

pub fn serialize(&self) -> Result<String, BatchError>

The batch envelope as JSON text, after checking the same rules as Self::parse.

BatchError for the first rule an element breaks.

Clone, Debug

Full rustdoc page