Trait Trace

Source
pub trait Trace: Sized {
    type Label: Clone;
    type TimeStamp: TimeStamp;

    // Required methods
    fn emit(&self, ev: TraceEvent<Self::Label, Self::TimeStamp>);
    fn report(self) -> Vec<TraceEvent<Self::Label, Self::TimeStamp>>;

    // Provided methods
    fn emit_span(&self, label: Self::Label) -> SpanHandle<'_, Self> { ... }
    fn emit_on_the_fly(&self, label: Self::Label) { ... }
}
Expand description

This trait describes a trace that is behind some sort of interior mutability mechanism. It can log trace events and later make these available. This is usually an argument to the trace_span function attribute macro in `libcrux-macros``, but it can also be called manually.

When used with the trace_span macros, this needs to be a global static. For defining and instantiating this, take a look at std::sync::LazyLock.

Required Associated Types§

Source

type Label: Clone

The label type used in events. Typically either &'static str or an enum.

Source

type TimeStamp: TimeStamp

The type used for timing the events. Typically std::time::Instant or a cycle counter.

Required Methods§

Source

fn emit(&self, ev: TraceEvent<Self::Label, Self::TimeStamp>)

Writes an event to the trace.

Source

fn report(self) -> Vec<TraceEvent<Self::Label, Self::TimeStamp>>

Returns a vector of all entries in the trace.

Provided Methods§

Source

fn emit_span(&self, label: Self::Label) -> SpanHandle<'_, Self>

Emits an event of type EventType::SpanOpen and returns a SpanHandle that emits another EventType::SpanClose when dropped.

Source

fn emit_on_the_fly(&self, label: Self::Label)

Emits an EventType::OnTheFly event.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Label: Clone, TS: TimeStamp> Trace for MutexTrace<Label, TS>

Source§

type Label = Label

Source§

type TimeStamp = TS

Source§

impl<Label: Clone, TS: TimeStamp> Trace for RefCellTrace<Label, TS>

Source§

type Label = Label

Source§

type TimeStamp = TS