pub struct Serde<T>(pub T)
where
T: Serialize + Clone + Send + 'static;
Expand description
Use to wrap a value that implements serde::Serialize so it’s written to the log record as an object, rather than a primitive.
§Examples
#[derive(Clone, Serialize)]
struct Thing {
one: String,
two: String,
}
let thing = get_thing();
info!(log, "Got a thing"; "thing" => slog::Serde(thing.clone()));
Tuple Fields§
§0: T
Trait Implementations§
Source§impl<T> SerdeValue for Serde<T>
impl<T> SerdeValue for Serde<T>
Source§fn as_serde(&self) -> &dyn Serialize
fn as_serde(&self) -> &dyn Serialize
Convert to
erased_serialize::Serialize
of the underlying value,
so slog::Serializer
s can use it to serialize via serde
.Source§fn to_sendable(&self) -> Box<dyn SerdeValue + Send + 'static>
fn to_sendable(&self) -> Box<dyn SerdeValue + Send + 'static>
Convert to a boxed value that can be sent across threads Read more
Source§fn serialize_fallback(
&self,
_key: Key,
_serializer: &mut dyn Serializer,
) -> Result<()>
fn serialize_fallback( &self, _key: Key, _serializer: &mut dyn Serializer, ) -> Result<()>
Serialize the value in a way that is compatible with
slog::Serializer
s
that do not support serde. Read moreAuto Trait Implementations§
impl<T> Freeze for Serde<T>where
T: Freeze,
impl<T> RefUnwindSafe for Serde<T>where
T: RefUnwindSafe,
impl<T> Send for Serde<T>
impl<T> Sync for Serde<T>where
T: Sync,
impl<T> Unpin for Serde<T>where
T: Unpin,
impl<T> UnwindSafe for Serde<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more