Skip to main content

Key

Trait Key 

Source
pub trait Key:
    Copy
    + Eq
    + 'static {
    const MAX_KEYS: usize;
    const DURATION_PATH: &'static [Self];

    // Required methods
    fn as_str(self) -> &'static str;
    fn as_index(self) -> usize;
}
Expand description

Trait for wide-event keys.

Each variant of a key enum represents a JSON key in the wide event. The wide_log! macro generates the enum and this trait impl automatically from the JSON structure — users do not implement this trait manually.

§Path-Based Duration

DURATION_PATH specifies the nested path to the duration field (e.g. [Duration, TotalMs]). The guard auto-sets this field to the elapsed time in milliseconds on drop.

The user does not define Log, Level, or Message variants. Log entries are handled entirely internally by a LogEntry type and the log_entries field on WideEvent.

Required Associated Constants§

Source

const MAX_KEYS: usize

The total number of keys in the enum.

Source

const DURATION_PATH: &'static [Self]

Path to the duration field (e.g. [Duration, TotalMs]). Auto-set by the guard on drop. The value is in milliseconds (u64).

Required Methods§

Source

fn as_str(self) -> &'static str

Returns the JSON string representation of this key.

Source

fn as_index(self) -> usize

Returns the discriminant index of this key.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§