slog

Trait Serializer

Source
pub trait Serializer {
Show 21 methods // Required method fn emit_arguments(&mut self, key: Key, val: &Arguments<'_>) -> Result; // Provided methods fn emit_usize(&mut self, key: Key, val: usize) -> Result { ... } fn emit_isize(&mut self, key: Key, val: isize) -> Result { ... } fn emit_bool(&mut self, key: Key, val: bool) -> Result { ... } fn emit_char(&mut self, key: Key, val: char) -> Result { ... } fn emit_u8(&mut self, key: Key, val: u8) -> Result { ... } fn emit_i8(&mut self, key: Key, val: i8) -> Result { ... } fn emit_u16(&mut self, key: Key, val: u16) -> Result { ... } fn emit_i16(&mut self, key: Key, val: i16) -> Result { ... } fn emit_u32(&mut self, key: Key, val: u32) -> Result { ... } fn emit_i32(&mut self, key: Key, val: i32) -> Result { ... } fn emit_f32(&mut self, key: Key, val: f32) -> Result { ... } fn emit_u64(&mut self, key: Key, val: u64) -> Result { ... } fn emit_i64(&mut self, key: Key, val: i64) -> Result { ... } fn emit_f64(&mut self, key: Key, val: f64) -> Result { ... } fn emit_u128(&mut self, key: Key, val: u128) -> Result { ... } fn emit_i128(&mut self, key: Key, val: i128) -> Result { ... } fn emit_str(&mut self, key: Key, val: &str) -> Result { ... } fn emit_unit(&mut self, key: Key) -> Result { ... } fn emit_none(&mut self, key: Key) -> Result { ... } fn emit_error(&mut self, key: Key, error: &(dyn Error + 'static)) -> Result { ... }
}
Expand description

Serializer

Drains using Format will internally use types implementing this trait.

Required Methods§

Source

fn emit_arguments(&mut self, key: Key, val: &Arguments<'_>) -> Result

Emit fmt::Arguments

This is the only method that has to implemented, but for performance and to retain type information most serious Serializers will want to implement all other methods as well.

Provided Methods§

Source

fn emit_usize(&mut self, key: Key, val: usize) -> Result

Emit usize

Source

fn emit_isize(&mut self, key: Key, val: isize) -> Result

Emit isize

Source

fn emit_bool(&mut self, key: Key, val: bool) -> Result

Emit bool

Source

fn emit_char(&mut self, key: Key, val: char) -> Result

Emit char

Source

fn emit_u8(&mut self, key: Key, val: u8) -> Result

Emit u8

Source

fn emit_i8(&mut self, key: Key, val: i8) -> Result

Emit i8

Source

fn emit_u16(&mut self, key: Key, val: u16) -> Result

Emit u16

Source

fn emit_i16(&mut self, key: Key, val: i16) -> Result

Emit i16

Source

fn emit_u32(&mut self, key: Key, val: u32) -> Result

Emit u32

Source

fn emit_i32(&mut self, key: Key, val: i32) -> Result

Emit i32

Source

fn emit_f32(&mut self, key: Key, val: f32) -> Result

Emit f32

Source

fn emit_u64(&mut self, key: Key, val: u64) -> Result

Emit u64

Source

fn emit_i64(&mut self, key: Key, val: i64) -> Result

Emit i64

Source

fn emit_f64(&mut self, key: Key, val: f64) -> Result

Emit f64

Source

fn emit_u128(&mut self, key: Key, val: u128) -> Result

Emit u128

Source

fn emit_i128(&mut self, key: Key, val: i128) -> Result

Emit i128

Source

fn emit_str(&mut self, key: Key, val: &str) -> Result

Emit &str

Source

fn emit_unit(&mut self, key: Key) -> Result

Emit ()

Source

fn emit_none(&mut self, key: Key) -> Result

Emit None

Source

fn emit_error(&mut self, key: Key, error: &(dyn Error + 'static)) -> Result

Emit a type implementing std::error::Error

Error values are a bit special as their Display implementation doesn’t show full information about the type but must be retrieved using source(). This can be used for formatting sources of errors differntly.

The default implementation of this method formats the sources separated with : . Serializers are encouraged to take advantage of the type information and format it as appropriate.

This method is only available in std because the Error trait is not available without std.

Implementors§