Trait ESExprOptionalFieldCodec

Source
pub trait ESExprOptionalFieldCodec<'a>:
    ESExprEncodedEq
    + Sized
    + 'a {
    type Element: ESExprCodec<'a> + 'a;

    // Required methods
    fn encode_optional_field(&'a self) -> Option<ESExpr<'a>>;
    fn decode_optional_field(
        value: Option<ESExpr<'a>>,
    ) -> Result<Self, DecodeError>;
}
Expand description

A field codec for optional fields.

Required Associated Types§

Source

type Element: ESExprCodec<'a> + 'a

The element type.

Required Methods§

Source

fn encode_optional_field(&'a self) -> Option<ESExpr<'a>>

Encode an optional field or None when the value should be excluded.

Source

fn decode_optional_field(value: Option<ESExpr<'a>>) -> Result<Self, DecodeError>

Decode an optional field value.

§Errors

Will return Err if decoding fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a, A: ESExprCodec<'a>> ESExprOptionalFieldCodec<'a> for Option<A>

Source§

impl<'a, F: ESExprOptionalFieldCodec<'a>> ESExprOptionalFieldCodec<'a> for Box<F>

Implementors§