[−][src]Trait slog::Value
Value that can be serialized
Types that implement this type implement custom serialization in the
structured part of the log macros. Without an implementation of Value
for
your type you must emit using either the ?
"debug", #?
"pretty-debug",
%
"display", #%
"alternate 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
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn 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]
V: Value,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for usize
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for isize
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for bool
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for char
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for u8
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for i8
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for u16
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for i16
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for u32
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for i32
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for f32
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for u64
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for i64
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for f64
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for u128
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for i128
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for ()
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for str
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<'a> Value for Arguments<'a>
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for String
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<T: Value> Value for Option<T>
[src]
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<T: ?Sized> Value for Box<T> where
T: Value,
[src]
T: Value,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<T: ?Sized> Value for Arc<T> where
T: Value,
[src]
T: Value,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<T> Value for Rc<T> where
T: Value,
[src]
T: Value,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<T> Value for Wrapping<T> where
T: Value,
[src]
T: Value,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<'a> Value for Display<'a>
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for SocketAddr
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl Value for Error
[src]
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
Implementors
impl<'a, V: 'a + Value, F> Value for FnValue<V, F> where
F: 'a + for<'c, 'd> Fn(&'c Record<'d>) -> V,
[src]
F: 'a + for<'c, 'd> Fn(&'c Record<'d>) -> V,
pub fn serialize(
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<E> Value for ErrorValue<E> where
E: 'static + Error,
[src]
E: 'static + Error,
pub fn serialize(
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
[src]
&self,
_record: &Record<'_>,
key: Key,
serializer: &mut dyn Serializer
) -> Result
impl<F> Value for PushFnValue<F> where
F: 'static + for<'c, 'd> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result,
[src]
F: 'static + for<'c, 'd> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result,