[][src]Trait slog::SerdeValue

pub trait SerdeValue: Serialize + Value {
    fn as_serde(&self) -> &dyn Serialize;
fn to_sendable(&self) -> Box<dyn SerdeValue + Send + 'static>; fn serialize_fallback(
        &self,
        _key: Key,
        _serializer: &mut dyn Serializer
    ) -> Result<()> { ... } }

A value that can be serialized via serde

This is useful for implementing nested values, like sequences or structures.

Required methods

fn as_serde(&self) -> &dyn Serialize

Convert to erased_serialize::Serialize of the underlying value, so slog::Serializers can use it to serialize via serde.

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.

Loading content...

Provided methods

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.

Loading content...

Implementors

Loading content...