Trait slog::Value [−][src]
pub trait Value { fn serialize(
&self,
record: &Record,
key: Key,
serializer: &mut Serializer
) -> Result; }
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: Key,
serializer: &mut Serializer
) -> Result
&self,
record: &Record,
key: Key,
serializer: &mut Serializer
) -> Result
Serialize self into Serializer
Structs implementing this trait should generally
only call respective methods of serializer
.
Implementations on Foreign Types
impl<'a, V: ?Sized> Value for &'a V where
V: Value,
[src]
impl<'a, V: ?Sized> Value for &'a V where
V: Value,
impl Value for usize
[src]
impl Value for usize
impl Value for isize
[src]
impl Value for isize
impl Value for bool
[src]
impl Value for bool
impl Value for char
[src]
impl Value for char
impl Value for u8
[src]
impl Value for u8
impl Value for i8
[src]
impl Value for i8
impl Value for u16
[src]
impl Value for u16
impl Value for i16
[src]
impl Value for i16
impl Value for u32
[src]
impl Value for u32
impl Value for i32
[src]
impl Value for i32
impl Value for f32
[src]
impl Value for f32
impl Value for u64
[src]
impl Value for u64
impl Value for i64
[src]
impl Value for i64
impl Value for f64
[src]
impl Value for f64
impl Value for ()
[src]
impl Value for ()
impl Value for str
[src]
impl Value for str
impl<'a> Value for Arguments<'a>
[src]
impl<'a> Value for Arguments<'a>
impl Value for String
[src]
impl Value for String
impl<T: Value> Value for Option<T>
[src]
impl<T: Value> Value for Option<T>
impl<T: ?Sized> Value for Box<T> where
T: Value,
[src]
impl<T: ?Sized> Value for Box<T> where
T: Value,
impl<T: ?Sized> Value for Arc<T> where
T: Value,
[src]
impl<T: ?Sized> Value for Arc<T> where
T: Value,
impl<T> Value for Rc<T> where
T: Value,
[src]
impl<T> Value for Rc<T> where
T: Value,
impl<T> Value for Wrapping<T> where
T: Value,
[src]
impl<T> Value for Wrapping<T> where
T: Value,
impl<'a> Value for Display<'a>
[src]
impl<'a> Value for Display<'a>
Implementors
impl<'a, V: 'a + Value, F> Value for FnValue<V, F> where
F: 'a + for<'c, 'd> Fn(&'c Record<'d>) -> V,impl<F> Value for PushFnValue<F> where
F: 'static + for<'c, 'd> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result,