Struct Serde
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: TTrait Implementations§
Source§impl<T> SerdeValue for Serde<T>
Available on crate feature nested-values only.
impl<T> SerdeValue for Serde<T>
Available on crate feature
nested-values only.Source§fn as_serde(&self) -> &dyn Serialize
fn as_serde(&self) -> &dyn Serialize
Convert to
erased_serde::Serialize of the underlying value,
so slog::Serializers can use it to serialize via serde.Source§fn to_sendable(&self) -> Box<dyn SerdeValue + Send>
fn to_sendable(&self) -> Box<dyn SerdeValue + Send>
Convert to a boxed value that can be sent across threads Read more
Source§fn serialize_fallback(
&self,
_key: &'static str,
_serializer: &mut dyn Serializer,
) -> Result<(), Error>
fn serialize_fallback( &self, _key: &'static str, _serializer: &mut dyn Serializer, ) -> Result<(), Error>
Serialize the value in a way that is compatible with
slog::Serializers
that do not support serde. Read moreSource§impl<T> Serialize for Serde<T>
Available on crate feature nested-values only.
impl<T> Serialize for Serde<T>
Available on crate feature
nested-values only.Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto 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> UnsafeUnpin for Serde<T>where
T: UnsafeUnpin,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more