Struct Struct

Source
pub struct Struct<'w, 'k, W: Write> {
    ser: ElementSerializer<'w, 'k, W>,
    children: String,
}
Expand description

A serializer for struct variants, which serializes the struct contents inside of wrapping tags (<${tag}>...</${tag}>).

Serialization of each field depends on it representation:

  • attributes written directly to the higher serializer
  • elements buffered into internal buffer and at the end written into higher serializer

Fields§

§ser: ElementSerializer<'w, 'k, W>§children: String

Buffer to store serialized elements

Implementations§

Source§

impl<'w, 'k, W: Write> Struct<'w, 'k, W>

Source

fn write_field<T>(&mut self, key: &str, value: &T) -> Result<(), DeError>
where T: ?Sized + Serialize,

Source

fn write_attribute<T>( &mut self, key: XmlName<'_>, value: &T, ) -> Result<(), DeError>
where T: ?Sized + Serialize,

Writes value as an attribute

Source

fn write_element<T>(&mut self, key: &str, value: &T) -> Result<(), DeError>
where T: ?Sized + Serialize,

Writes value either as a text content, or as an element.

If key has a magic value TEXT_KEY, then value serialized as a simple type.

If key has a magic value VALUE_KEY, then value serialized as a content without wrapping in tags, otherwise it is wrapped in <${key}>...</${key}>.

Trait Implementations§

Source§

impl<'w, 'k, W: Write> SerializeStruct for Struct<'w, 'k, W>

Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = DeError

Must match the Error type of our Serializer.
Source§

fn serialize_field<T>( &mut self, key: &'static str, value: &T, ) -> Result<(), Self::Error>
where T: ?Sized + Serialize,

Serialize a struct field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a struct.
Source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct field has been skipped. Read more
Source§

impl<'w, 'k, W: Write> SerializeStructVariant for Struct<'w, 'k, W>

Source§

type Ok = ()

Must match the Ok type of our Serializer.
Source§

type Error = DeError

Must match the Error type of our Serializer.
Source§

fn serialize_field<T>( &mut self, key: &'static str, value: &T, ) -> Result<(), Self::Error>
where T: ?Sized + Serialize,

Serialize a struct variant field.
Source§

fn end(self) -> Result<Self::Ok, Self::Error>

Finish serializing a struct variant.
Source§

fn skip_field(&mut self, key: &'static str) -> Result<(), Self::Error>

Indicate that a struct variant field has been skipped. Read more

Auto Trait Implementations§

§

impl<'w, 'k, W> Freeze for Struct<'w, 'k, W>

§

impl<'w, 'k, W> RefUnwindSafe for Struct<'w, 'k, W>
where W: RefUnwindSafe,

§

impl<'w, 'k, W> Send for Struct<'w, 'k, W>
where W: Send,

§

impl<'w, 'k, W> Sync for Struct<'w, 'k, W>
where W: Sync,

§

impl<'w, 'k, W> Unpin for Struct<'w, 'k, W>

§

impl<'w, 'k, W> !UnwindSafe for Struct<'w, 'k, W>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.