Skip to main content

TranscriptSink

Trait TranscriptSink 

Source
pub trait TranscriptSink: Send {
    // Required methods
    fn begin(&mut self, header: &TranscriptHeader) -> Result<()>;
    fn record(
        &mut self,
        at: DateTime<Utc>,
        level: Level,
        fact: &StepFact,
    ) -> Result<()>;
    fn finalize(&mut self) -> Result<TranscriptFingerprint>;
}
Expand description

Synchronous, durable observer of StepFacts.

Implementations must record each fact, including syncing it to the underlying storage where applicable, before returning. The executor relies on this to maintain the invariant that the UI never sees a fact that has not been durably persisted.

Required Methods§

Source

fn begin(&mut self, header: &TranscriptHeader) -> Result<()>

Write the header line. Must be called once, before any fact.

§Errors

Returns an error if the header was already written, or the underlying I/O error if the sink cannot persist it.

Source

fn record( &mut self, at: DateTime<Utc>, level: Level, fact: &StepFact, ) -> Result<()>

Record a single fact at level, stamped with the caller-supplied event time at. Must persist before returning, the file-backed implementation calls sync_data so a power loss after record returns cannot drop the fact.

at and level are supplied by the executor, not chosen here, so the sink stays a serializer with no policy of its own.

§Errors

Returns an error if the header has not been written or the transcript is finalized, if the header does not declare level, if the fact holds a value the canonical form does not cover, or the underlying I/O error if the sink cannot persist the fact.

Source

fn finalize(&mut self) -> Result<TranscriptFingerprint>

Finalize the transcript and return its fingerprint.

Calling finalize more than once is implementation-defined; the default expectation is that the second call returns the cached fingerprint.

§Errors

Returns an error if the header was never written, or the underlying I/O error if any pending state cannot be persisted.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§