pub trait Encode {
// Required method
fn encode_log_value_into(&self, output: ValueEncoder<'_>);
}Expand description
Trait for types that can be encoded as log field values.
Implementing this trait allows custom types to be used directly in log macros without requiring explicit formatting.
§Examples
use kvlog::encoding::{Encode, ValueEncoder};
struct UserId(u64);
impl Encode for UserId {
fn encode_log_value_into(&self, output: ValueEncoder<'_>) {
self.0.encode_log_value_into(output);
}
}
let user_id = UserId(12345);
kvlog::info!("User action", user_id);Required Methods§
Sourcefn encode_log_value_into(&self, output: ValueEncoder<'_>)
fn encode_log_value_into(&self, output: ValueEncoder<'_>)
Encodes this value into the log output buffer.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".