Serializer

Trait Serializer 

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

Serializer

Drains using Format will internally use types implementing this trait.

Required Methods§

Source

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

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: &'static str, val: usize) -> Result<(), Error>

Emit usize

Source

fn emit_isize(&mut self, key: &'static str, val: isize) -> Result<(), Error>

Emit isize

Source

fn emit_bool(&mut self, key: &'static str, val: bool) -> Result<(), Error>

Emit bool

Source

fn emit_char(&mut self, key: &'static str, val: char) -> Result<(), Error>

Emit char

Source

fn emit_u8(&mut self, key: &'static str, val: u8) -> Result<(), Error>

Emit u8

Source

fn emit_i8(&mut self, key: &'static str, val: i8) -> Result<(), Error>

Emit i8

Source

fn emit_u16(&mut self, key: &'static str, val: u16) -> Result<(), Error>

Emit u16

Source

fn emit_i16(&mut self, key: &'static str, val: i16) -> Result<(), Error>

Emit i16

Source

fn emit_u32(&mut self, key: &'static str, val: u32) -> Result<(), Error>

Emit u32

Source

fn emit_i32(&mut self, key: &'static str, val: i32) -> Result<(), Error>

Emit i32

Source

fn emit_f32(&mut self, key: &'static str, val: f32) -> Result<(), Error>

Emit f32

Source

fn emit_u64(&mut self, key: &'static str, val: u64) -> Result<(), Error>

Emit u64

Source

fn emit_i64(&mut self, key: &'static str, val: i64) -> Result<(), Error>

Emit i64

Source

fn emit_f64(&mut self, key: &'static str, val: f64) -> Result<(), Error>

Emit f64

Source

fn emit_u128(&mut self, key: &'static str, val: u128) -> Result<(), Error>

Emit u128

Source

fn emit_i128(&mut self, key: &'static str, val: i128) -> Result<(), Error>

Emit i128

Source

fn emit_str(&mut self, key: &'static str, val: &str) -> Result<(), Error>

Emit &str

Source

fn emit_unit(&mut self, key: &'static str) -> Result<(), Error>

Emit ()

Source

fn emit_none(&mut self, key: &'static str) -> Result<(), Error>

Emit None

Source

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

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§