[go: up one dir, main page]

SerdeValue

Trait SerdeValue 

Source
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§

Source

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 + 'static>

Convert to a boxed value that can be sent across threads

This enables functionality like slog-async and similar.

Provided Methods§

Source

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.

Implementors§

Source§

impl<T> SerdeValue for Serde<T>
where T: Serialize + Clone + Send + 'static,

Available on crate feature nested-values only.