[][src]Trait slog::Serializer

pub trait Serializer {
    pub fn emit_arguments(&mut self, key: Key, val: &Arguments<'_>) -> Result;

    pub fn emit_usize(&mut self, key: Key, val: usize) -> Result { ... }
pub fn emit_isize(&mut self, key: Key, val: isize) -> Result { ... }
pub fn emit_bool(&mut self, key: Key, val: bool) -> Result { ... }
pub fn emit_char(&mut self, key: Key, val: char) -> Result { ... }
pub fn emit_u8(&mut self, key: Key, val: u8) -> Result { ... }
pub fn emit_i8(&mut self, key: Key, val: i8) -> Result { ... }
pub fn emit_u16(&mut self, key: Key, val: u16) -> Result { ... }
pub fn emit_i16(&mut self, key: Key, val: i16) -> Result { ... }
pub fn emit_u32(&mut self, key: Key, val: u32) -> Result { ... }
pub fn emit_i32(&mut self, key: Key, val: i32) -> Result { ... }
pub fn emit_f32(&mut self, key: Key, val: f32) -> Result { ... }
pub fn emit_u64(&mut self, key: Key, val: u64) -> Result { ... }
pub fn emit_i64(&mut self, key: Key, val: i64) -> Result { ... }
pub fn emit_f64(&mut self, key: Key, val: f64) -> Result { ... }
pub fn emit_u128(&mut self, key: Key, val: u128) -> Result { ... }
pub fn emit_i128(&mut self, key: Key, val: i128) -> Result { ... }
pub fn emit_str(&mut self, key: Key, val: &str) -> Result { ... }
pub fn emit_unit(&mut self, key: Key) -> Result { ... }
pub fn emit_none(&mut self, key: Key) -> Result { ... }
pub fn emit_serde(&mut self, key: Key, value: &dyn SerdeValue) -> Result { ... }
pub fn emit_error(
        &mut self,
        key: Key,
        error: &(dyn Error + 'static)
    ) -> Result { ... } }

Serializer

Drains using Format will internally use types implementing this trait.

Required methods

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

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.

Loading content...

Provided methods

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

Emit usize

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

Emit isize

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

Emit bool

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

Emit char

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

Emit u8

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

Emit i8

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

Emit u16

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

Emit i16

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

Emit u32

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

Emit i32

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

Emit f32

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

Emit u64

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

Emit i64

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

Emit f64

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

Emit u128

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

Emit i128

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

Emit &str

pub fn emit_unit(&mut self, key: Key) -> Result[src]

Emit ()

pub fn emit_none(&mut self, key: Key) -> Result[src]

Emit None

pub fn emit_serde(&mut self, key: Key, value: &dyn SerdeValue) -> Result[src]

Emit a value implementing serde::Serialize

This is especially useful for composite values, eg. structs as Json values, or sequences.

To prevent pulling-in serde dependency, this is an extension behind a serde feature flag.

The value needs to implement SerdeValue.

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

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.

Loading content...

Implementors

Loading content...