Trait fourleaf::de::Deserialize [] [src]

pub trait Deserialize<R: Read, STYLE = Copying>: Sized {
    type Accum: Default + Sized;
    fn deserialize_field(
        accum: &mut Self::Accum,
        context: &Context,
        field: &mut Field<R>
    ) -> Result<()>; fn finish(accum: Self::Accum, context: &Context) -> Result<Self>; fn deserialize_body(
        context: &Context,
        stream: &mut Stream<R>
    ) -> Result<Self> { ... } fn deserialize_element(
        context: &Context,
        field: &mut Field<R>
    ) -> Result<Self> { ... } fn serialized_as_slice() -> bool { ... } fn deserialize_vec(
        context: &Context,
        field: &mut Field<R>
    ) -> Option<Result<Vec<Self>>> { ... } fn deserialize_slice(
        dst: &mut [Self],
        context: &Context,
        field: &mut Field<R>
    ) -> Option<Result<()>> { ... } fn deserialize_array_0(
        context: &Context,
        field: &mut Field<R>
    ) -> Option<Result<[Self; 0]>> { ... } }

Trait for high-level deserialisation.

The STYLE type parameter (which is supposed to be a marker struct from the style submodule) is used to select between buffering and referencing the input.

Unlike Sererialize, the reader type is parameterised on the trait itself, since ZeroCopy for certain types requires additional capabilities on R.

Associated Types

Type used to accumulate the deserialised value of this field.

Single-valued fields usually use Option<Self> here.

Parent deserialisers default-initialise accumulators for their fields before starting deserialisation.

Required Methods

Deserialises this type from a field in a container.

This may be called any number of times with the same accumulator to account for the field occurring more than once.

Convert an accumulated value to a value of this type.

May fail if the appropriate number of items have not been accumulated, etc.

Provided Methods

Deserialises this type from a top-level stream or from the tail portion of a struct. If this call succeeds, all field elements up to and including the closing EndOfStruct element are consumed.

The default inverts the default implementation of Serialize::serialize_body.

Deserialises this type from a single field entry, which is known to be the only occurrence that would constitute this value.

The default implementation default-initialises an Accum, calls deserialize_field, and then finish.

Returns whether deserialize_vec and the deserialize_array_* methods return non-None.

If this type's Serialize implementation has special behaviour in serialize_slice, perform the reverse operation here and return a Vec of values.

Note

If this method is implemented, all 32 of the deserialize_array_* functions as well as deserialize_slice must also be implemented.

If this type's Serialize implementation has special behaviour in serialize_slice, perform the reverse operation here and write into the given slice of values, or return Err if the slice is not the appropriate length.

Note

If this method is implemented, all 32 of the deserialize_array_* functions as well as deserialize_vec must also be implemented.

If this type's Serialize implementation has special behaviour in serialize_slice, perform the reverse operation here return an array of the given length, or return an error if the actual number of values is different from the length of the array.

Note

There are actually 33 of these functions with the same signature except for the suffix (0..32) and the length of the result, but the others are not shown in the documentation for the sake of conciseness. If any are implemented, all must be implemented.

Implementors