DeserializationState

Trait DeserializationState 

Source
pub trait DeserializationState<'de>: Default {
    type Value: DeserializationError;

    // Required methods
    fn is_param_known(&self, key: &str) -> bool;
    fn deserialize_temp(
        &mut self,
        key: &str,
        value: Param<'_>,
    ) -> Result<ParamKind, <Self::Value as DeserializationError>::Error>;
    fn finalize(
        self,
    ) -> Result<Self::Value, <Self::Value as DeserializationError>::Error>;

    // Provided method
    fn deserialize_borrowed(
        &mut self,
        key: &'de str,
        value: Param<'de>,
    ) -> Result<ParamKind, <Self::Value as DeserializationError>::Error> { ... }
}
Expand description

Represents the state of deserialization of extras.

Required Associated Types§

Source

type Value: DeserializationError

Value returned when deserialization finishes.

Required Methods§

Source

fn is_param_known(&self, key: &str) -> bool

Returns true if the parameter is known.

Required parameters include the req- prefix.

Source

fn deserialize_temp( &mut self, key: &str, value: Param<'_>, ) -> Result<ParamKind, <Self::Value as DeserializationError>::Error>

Deserializes a temporary.

This can not borrow the key nor value, so has to clone them or throw away. Required parameters include the req- prefix.

Source

fn finalize( self, ) -> Result<Self::Value, <Self::Value as DeserializationError>::Error>

Signals that all parameters were processed.

This function may perform additional validation - e.g. checking if some mandatory fields are missing.

Provided Methods§

Source

fn deserialize_borrowed( &mut self, key: &'de str, value: Param<'de>, ) -> Result<ParamKind, <Self::Value as DeserializationError>::Error>

Deserializes a borrowed value possibly avoiding cloning.

Implementing this can enable zero-copy deserialization. Required parameters include the req- prefix.

The default implementation forwards to deserialize_temp

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.

Implementors§