[]Trait astral::thirdparty::slog::Value

pub trait Value {
    fn serialize(
        &self,
        record: &Record,
        key: &'static str,
        serializer: &mut dyn Serializer
    ) -> Result<(), Error>; }

Value that can be serialized

Types that implement this type implement custome serialization in the structured part of the log macros. Without an implementation of Value for your type you must emit using either the ? "debug", % "display" or SerdeValue (if you have the nested-values feature enabled) formatters.

Example

use slog::{Key, Value, Record, Result, Serializer};
struct MyNewType(i64);

impl Value for MyNewType {
    fn serialize(&self, _rec: &Record, key: Key, serializer: &mut Serializer) -> Result {
        serializer.emit_i64(key, self.0)
    }
}

See also KV for formatting both the key and value.

Required methods

fn serialize(
    &self,
    record: &Record,
    key: &'static str,
    serializer: &mut dyn Serializer
) -> Result<(), Error>

Serialize self into Serializer

Structs implementing this trait should generally only call respective methods of serializer.

Loading content...

Implementations on Foreign Types

impl<'a> Value for Arguments<'a>

impl Value for str

impl Value for char

impl Value for usize

impl<'a, V> Value for &'a V where
    V: Value + ?Sized

impl<T> Value for Rc<T> where
    T: Value

impl<T> Value for Wrapping<T> where
    T: Value

impl Value for i128

impl Value for i64

impl Value for i16

impl<'a> Value for Display<'a>

impl<T> Value for Arc<T> where
    T: Value + ?Sized

impl Value for u32

impl Value for bool

impl Value for u64

impl Value for SocketAddr

impl Value for i32

impl Value for i8

impl<T> Value for Box<T> where
    T: Value + ?Sized

impl Value for f64

impl Value for u16

impl Value for u128

impl Value for u8

impl Value for isize

impl Value for ()

impl Value for f32

impl<T> Value for Option<T> where
    T: Value

Loading content...

Implementors

impl Value for String

impl<'a, V, F> Value for FnValue<V, F> where
    F: 'a + for<'c> Fn(&'c Record<'d>) -> V,
    V: 'a + Value

impl<F> Value for PushFnValue<F> where
    F: 'static + for<'c> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result<(), Error>, 

Loading content...