Skip to main content

EventSink

Trait EventSink 

Source
pub trait EventSink {
    // Required methods
    fn finish(self) -> Result<()>;
    fn handle_event(&mut self, event: Event) -> Result<()>;
}
Expand description

Consumes a stream of crate::Events to produce output.

Writers implement this trait to translate document events into a target format. Call EventSink::handle_event for each event in order, then call EventSink::finish to flush output and signal completion.

finish consumes self to prevent reuse after the stream has ended.

Required Methods§

Source

fn finish(self) -> Result<()>

Flush any buffered output and finalize the document.

Consumes self to prevent further use after the stream ends.

§Errors

Returns an error if flushing or finalization fails.

Source

fn handle_event(&mut self, event: Event) -> Result<()>

Process one event from the stream.

Events must arrive in valid document order. Writers may assume the stream is well-formed per the rules in EVENTS.md.

§Errors

Returns an error if the sink cannot process the event (write failure, invalid format, resource exhaustion).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§