pub trait SerdeValue: Serialize + Value {
// Required methods
fn as_serde(&self) -> &dyn Serialize;
fn to_sendable(&self) -> Box<dyn SerdeValue + Send + 'static>;
// Provided method
fn serialize_fallback(
&self,
_key: Key,
_serializer: &mut dyn Serializer,
) -> Result<()> { ... }
}Expand description
A value that can be serialized via serde, using erased_serde 0.3.
This is useful for implementing nested values, like sequences or structures.
Required Methods§
Sourcefn 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.
Sourcefn 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
This enables functionality like slog-async and similar.
Provided Methods§
Sourcefn 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::Serializers
that do not support serde.
The implementation should not call slog::Serialize::serialize
on itself, as it will lead to infinite recursion.
Default implementation is provided, but it returns error, so use it
only for internal types in systems and libraries where serde is always
enabled.