[−]Trait astral::thirdparty::slog::Value
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>
&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
.
Implementations on Foreign Types
impl<'a> Value for Arguments<'a>
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for str
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for char
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for usize
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<'a, V> Value for &'a V where
V: Value + ?Sized,
V: Value + ?Sized,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<T> Value for Rc<T> where
T: Value,
T: Value,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<T> Value for Wrapping<T> where
T: Value,
T: Value,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for i128
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for i64
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for i16
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<'a> Value for Display<'a>
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<T> Value for Arc<T> where
T: Value + ?Sized,
T: Value + ?Sized,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for u32
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for bool
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for u64
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for SocketAddr
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for i32
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for i8
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<T> Value for Box<T> where
T: Value + ?Sized,
T: Value + ?Sized,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for f64
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for u16
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for u128
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for u8
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for isize
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for ()
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl Value for f32
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<T> Value for Option<T> where
T: Value,
T: Value,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
Implementors
impl Value for String
fn serialize(
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
_record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<'a, V, F> Value for FnValue<V, F> where
F: 'a + for<'c> Fn(&'c Record<'d>) -> V,
V: 'a + Value,
F: 'a + for<'c> Fn(&'c Record<'d>) -> V,
V: 'a + Value,
fn serialize(
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
&self,
record: &Record,
key: &'static str,
serializer: &mut dyn Serializer
) -> Result<(), Error>
impl<F> Value for PushFnValue<F> where
F: 'static + for<'c> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result<(), Error>,
F: 'static + for<'c> Fn(&'c Record<'d>, PushFnValueSerializer<'c>) -> Result<(), Error>,