Skip to main content

Serializer

Trait Serializer 

Source
pub trait Serializer {
    type Error: Error;
    type SerializeClass<'a>: Serializer<Error = Self::Error>
       where Self: 'a;
    type SerializeField<'a>: Serializer<Error = Self::Error>
       where Self: 'a;
    type SerializeMethod<'a>: Serializer<Error = Self::Error>
       where Self: 'a;
    type SerializeMethodArg<'a>: Serializer<Error = Self::Error>
       where Self: 'a;
    type SerializeMethodVar<'a>: Serializer<Error = Self::Error>
       where Self: 'a;

    const FLAT_CLASSES: bool;

    // Required methods
    fn serialize_comment(&mut self, value: &str) -> Result<(), Self::Error>;
    fn serialize_class<Dst>(
        &mut self,
        src: &str,
        dst: Dst,
    ) -> Result<Self::SerializeClass<'_>, Self::Error>
       where Dst: IntoIterator<Item: AsRef<str>>;
    fn serialize_field<Dst, DstDesc>(
        &mut self,
        src: &str,
        desc: Option<&str>,
        dst: Dst,
        dst_desc: Option<DstDesc>,
    ) -> Result<Self::SerializeField<'_>, Self::Error>
       where Dst: IntoIterator<Item: AsRef<str>>,
             DstDesc: IntoIterator<Item: AsRef<str>>;
    fn serialize_method<Dst, DstDesc>(
        &mut self,
        src: &str,
        desc: Option<&str>,
        dst: Dst,
        dst_desc: Option<DstDesc>,
    ) -> Result<Self::SerializeMethod<'_>, Self::Error>
       where Dst: IntoIterator<Item: AsRef<str>>,
             DstDesc: IntoIterator<Item: AsRef<str>>;
    fn serialize_method_arg<Dst>(
        &mut self,
        src: Option<&str>,
        dst: Option<Dst>,
        pos: Option<usize>,
        lv_index: Option<usize>,
    ) -> Result<Self::SerializeMethodArg<'_>, Self::Error>
       where Dst: IntoIterator<Item: AsRef<str>>;
    fn serialize_method_var<Dst>(
        &mut self,
        src: Option<&str>,
        dst: Option<Dst>,
        lv_index: Option<usize>,
        lvt_row_index: Option<usize>,
        op_idx: Option<(usize, Option<usize>)>,
    ) -> Result<Self::SerializeMethodVar<'_>, Self::Error>
       where Dst: IntoIterator<Item: AsRef<str>>;

    // Provided method
    fn layout_matches<'de, D>() -> bool
       where D: Deserializer<'de> + ?Sized { ... }
}
Expand description

Serializer of a mapping file.

Required Associated Constants§

Source

const FLAT_CLASSES: bool

Whether inner classes should be flattened.

Required Associated Types§

Source

type Error: Error

The error type.

Source

type SerializeClass<'a>: Serializer<Error = Self::Error> where Self: 'a

Type returned from Serializer::serialize_class for class content serialization.

Source

type SerializeField<'a>: Serializer<Error = Self::Error> where Self: 'a

Type returned from Serializer::serialize_field for field comment serialization.

Source

type SerializeMethod<'a>: Serializer<Error = Self::Error> where Self: 'a

Type returned from Serializer::serialize_method for method arguments, variables and comment serialization.

Source

type SerializeMethodArg<'a>: Serializer<Error = Self::Error> where Self: 'a

Type returned from Serializer::serialize_method_arg for method argument comment serialization.

Source

type SerializeMethodVar<'a>: Serializer<Error = Self::Error> where Self: 'a

Type returned from Serializer::serialize_method_var for method variable comment serialization.

Required Methods§

Source

fn serialize_comment(&mut self, value: &str) -> Result<(), Self::Error>

Serializes a comment literal.

Source

fn serialize_class<Dst>( &mut self, src: &str, dst: Dst, ) -> Result<Self::SerializeClass<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Serializes a class.

Source

fn serialize_field<Dst, DstDesc>( &mut self, src: &str, desc: Option<&str>, dst: Dst, dst_desc: Option<DstDesc>, ) -> Result<Self::SerializeField<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>, DstDesc: IntoIterator<Item: AsRef<str>>,

Serializes a field.

Source

fn serialize_method<Dst, DstDesc>( &mut self, src: &str, desc: Option<&str>, dst: Dst, dst_desc: Option<DstDesc>, ) -> Result<Self::SerializeMethod<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>, DstDesc: IntoIterator<Item: AsRef<str>>,

Serializes a method.

Source

fn serialize_method_arg<Dst>( &mut self, src: Option<&str>, dst: Option<Dst>, pos: Option<usize>, lv_index: Option<usize>, ) -> Result<Self::SerializeMethodArg<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Serializes a method argument.

Source

fn serialize_method_var<Dst>( &mut self, src: Option<&str>, dst: Option<Dst>, lv_index: Option<usize>, lvt_row_index: Option<usize>, op_idx: Option<(usize, Option<usize>)>, ) -> Result<Self::SerializeMethodVar<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Serializes a method variable.

Provided Methods§

Source

fn layout_matches<'de, D>() -> bool
where D: Deserializer<'de> + ?Sized,

Whether the deserializer’s class layout matches this serializer’s class layout.

By default this compares Self::FLAT_CLASSES of the two.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> Serializer for &mut T
where T: Serializer,

Source§

const FLAT_CLASSES: bool = T::FLAT_CLASSES

Source§

type Error = <T as Serializer>::Error

Source§

type SerializeClass<'a> = <T as Serializer>::SerializeClass<'a> where Self: 'a

Source§

type SerializeField<'a> = <T as Serializer>::SerializeField<'a> where Self: 'a

Source§

type SerializeMethod<'a> = <T as Serializer>::SerializeMethod<'a> where Self: 'a

Source§

type SerializeMethodArg<'a> = <T as Serializer>::SerializeMethodArg<'a> where Self: 'a

Source§

type SerializeMethodVar<'a> = <T as Serializer>::SerializeMethodVar<'a> where Self: 'a

Source§

fn layout_matches<'de, D>() -> bool
where D: Deserializer<'de> + ?Sized,

Source§

fn serialize_comment(&mut self, value: &str) -> Result<(), Self::Error>

Source§

fn serialize_class<Dst>( &mut self, src: &str, dst: Dst, ) -> Result<Self::SerializeClass<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Source§

fn serialize_field<Dst, DstDesc>( &mut self, src: &str, desc: Option<&str>, dst: Dst, dst_desc: Option<DstDesc>, ) -> Result<Self::SerializeField<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>, DstDesc: IntoIterator<Item: AsRef<str>>,

Source§

fn serialize_method<Dst, DstDesc>( &mut self, src: &str, desc: Option<&str>, dst: Dst, dst_desc: Option<DstDesc>, ) -> Result<Self::SerializeMethod<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>, DstDesc: IntoIterator<Item: AsRef<str>>,

Source§

fn serialize_method_arg<Dst>( &mut self, src: Option<&str>, dst: Option<Dst>, pos: Option<usize>, lv_index: Option<usize>, ) -> Result<Self::SerializeMethodArg<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Source§

fn serialize_method_var<Dst>( &mut self, src: Option<&str>, dst: Option<Dst>, lv_index: Option<usize>, lvt_row_index: Option<usize>, op_idx: Option<(usize, Option<usize>)>, ) -> Result<Self::SerializeMethodVar<'_>, Self::Error>
where Dst: IntoIterator<Item: AsRef<str>>,

Implementors§

Source§

impl<Err> Serializer for Impossible<Err>
where Err: Error,

Source§

const FLAT_CLASSES: bool = false

Source§

type Error = Err

Source§

type SerializeClass<'a> = Impossible<Err> where Self: 'a

Source§

type SerializeField<'a> = Impossible<Err> where Self: 'a

Source§

type SerializeMethod<'a> = Impossible<Err> where Self: 'a

Source§

type SerializeMethodArg<'a> = Impossible<Err> where Self: 'a

Source§

type SerializeMethodVar<'a> = Impossible<Err> where Self: 'a

Source§

impl<Err> Serializer for Skip<Err>
where Err: Error,

Source§

const FLAT_CLASSES: bool = false

Source§

type Error = Err

Source§

type SerializeClass<'a> = Skip<Err> where Self: 'a

Source§

type SerializeField<'a> = Skip<Err> where Self: 'a

Source§

type SerializeMethod<'a> = Skip<Err> where Self: 'a

Source§

type SerializeMethodArg<'a> = Skip<Err> where Self: 'a

Source§

type SerializeMethodVar<'a> = Skip<Err> where Self: 'a