log::kv

Trait VisitValue

Source
pub trait VisitValue<'v> {
    // Required method
    fn visit_any(&mut self, value: Value<'_>) -> Result<(), Error>;

    // Provided methods
    fn visit_null(&mut self) -> Result<(), Error> { ... }
    fn visit_u64(&mut self, value: u64) -> Result<(), Error> { ... }
    fn visit_i64(&mut self, value: i64) -> Result<(), Error> { ... }
    fn visit_u128(&mut self, value: u128) -> Result<(), Error> { ... }
    fn visit_i128(&mut self, value: i128) -> Result<(), Error> { ... }
    fn visit_f64(&mut self, value: f64) -> Result<(), Error> { ... }
    fn visit_bool(&mut self, value: bool) -> Result<(), Error> { ... }
    fn visit_str(&mut self, value: &str) -> Result<(), Error> { ... }
    fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error> { ... }
    fn visit_char(&mut self, value: char) -> Result<(), Error> { ... }
}
Expand description

A visitor for a Value.

Also see Value’s documentation on seralization. Value visitors are a simple alternative to a more fully-featured serialization framework like serde or sval. A value visitor can differentiate primitive types through methods like VisitValue::visit_bool and VisitValue::visit_str, but more complex types like maps and sequences will fallthrough to VisitValue::visit_any.

If you’re trying to serialize a value to a format like JSON, you can use either serde or sval directly with the value. You don’t need a visitor.

Required Methods§

Source

fn visit_any(&mut self, value: Value<'_>) -> Result<(), Error>

Visit a Value.

This is the only required method on VisitValue and acts as a fallback for any more specific methods that aren’t overridden. The Value may be formatted using its fmt::Debug or fmt::Display implementation, or serialized using its sval::Value or serde::Serialize implementation.

Provided Methods§

Source

fn visit_null(&mut self) -> Result<(), Error>

Visit an empty value.

Source

fn visit_u64(&mut self, value: u64) -> Result<(), Error>

Visit an unsigned integer.

Source

fn visit_i64(&mut self, value: i64) -> Result<(), Error>

Visit a signed integer.

Source

fn visit_u128(&mut self, value: u128) -> Result<(), Error>

Visit a big unsigned integer.

Source

fn visit_i128(&mut self, value: i128) -> Result<(), Error>

Visit a big signed integer.

Source

fn visit_f64(&mut self, value: f64) -> Result<(), Error>

Visit a floating point.

Source

fn visit_bool(&mut self, value: bool) -> Result<(), Error>

Visit a boolean.

Source

fn visit_str(&mut self, value: &str) -> Result<(), Error>

Visit a string.

Source

fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error>

Visit a string.

Source

fn visit_char(&mut self, value: char) -> Result<(), Error>

Visit a Unicode character.

Implementations on Foreign Types§

Source§

impl<'a, 'v, T> VisitValue<'v> for &'a mut T
where T: VisitValue<'v> + ?Sized,

Source§

fn visit_any(&mut self, value: Value<'_>) -> Result<(), Error>

Source§

fn visit_null(&mut self) -> Result<(), Error>

Source§

fn visit_u64(&mut self, value: u64) -> Result<(), Error>

Source§

fn visit_i64(&mut self, value: i64) -> Result<(), Error>

Source§

fn visit_u128(&mut self, value: u128) -> Result<(), Error>

Source§

fn visit_i128(&mut self, value: i128) -> Result<(), Error>

Source§

fn visit_f64(&mut self, value: f64) -> Result<(), Error>

Source§

fn visit_bool(&mut self, value: bool) -> Result<(), Error>

Source§

fn visit_str(&mut self, value: &str) -> Result<(), Error>

Source§

fn visit_borrowed_str(&mut self, value: &'v str) -> Result<(), Error>

Source§

fn visit_char(&mut self, value: char) -> Result<(), Error>

Implementors§