Skip to main content

TraceEvent

Trait TraceEvent 

Source
pub trait TraceEvent {
    type Ref<'a>;

    // Required methods
    fn event_name() -> &'static str;
    fn field_defs() -> Vec<FieldDef>;
    fn timestamp(&self) -> u64;
    fn encode_fields<W: Write>(
        &self,
        enc: &mut EventEncoder<'_, W>,
    ) -> Result<()>;
    fn decode<'a>(
        timestamp_ns: Option<u64>,
        fields: &[FieldValueRef<'a>],
        field_defs: &[FieldDef],
    ) -> Option<Self::Ref<'a>>;

    // Provided methods
    fn has_timestamp() -> bool { ... }
    fn schema_entry() -> SchemaEntry { ... }
}
Expand description

Trait implemented by #[derive(TraceEvent)] for compile-time event types.

Required Associated Types§

Source

type Ref<'a>

Decoded form of this event, potentially borrowing from the input buffer.

Required Methods§

Source

fn event_name() -> &'static str

The event type name (used in schema registration).

Source

fn field_defs() -> Vec<FieldDef>

Field definitions for schema registration. When has_timestamp() is true, the timestamp is NOT included here — it is encoded in the event frame header.

Source

fn timestamp(&self) -> u64

Return the event’s timestamp in nanoseconds.

Source

fn encode_fields<W: Write>(&self, enc: &mut EventEncoder<'_, W>) -> Result<()>

Encode this event’s non-timestamp fields into the encoder.

Source

fn decode<'a>( timestamp_ns: Option<u64>, fields: &[FieldValueRef<'a>], field_defs: &[FieldDef], ) -> Option<Self::Ref<'a>>

Decode from field values using field definitions for name resolution. timestamp_ns is the absolute timestamp from the event header (if present).

Provided Methods§

Source

fn has_timestamp() -> bool

Whether this event type carries a packed timestamp in the event header.

Source

fn schema_entry() -> SchemaEntry

Build a SchemaEntry for this event type.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§