Skip to main content

Format

Trait Format 

Source
pub trait Format {
    // Required methods
    fn map_types(&self, types: &Types) -> Result<Cow<'_, Types>, FormatError>;
    fn map_type(
        &self,
        types: &Types,
        dt: &DataType,
    ) -> Result<Cow<'_, DataType>, FormatError>;
}
Expand description

The format is used to inform Specta how the Serialize/Deserialization layer handles types.

This allows them to rewrite the collected types and encountered datatypes to apply format-specific macro attributes or behaviour.

Currently we have support for:

Required Methods§

Source

fn map_types(&self, types: &Types) -> Result<Cow<'_, Types>, FormatError>

Apply a map function to the full Types collection.

Returns Cow::Borrowed when no changes are needed, or Cow::Owned when the formatter produces a transformed collection.

Source

fn map_type( &self, types: &Types, dt: &DataType, ) -> Result<Cow<'_, DataType>, FormatError>

Map an individual DataType with access to the surrounding Types.

Returns Cow::Borrowed when no changes are needed, or Cow::Owned when the formatter produces a transformed datatype.

Implementations on Foreign Types§

Source§

impl<T: Format + ?Sized> Format for &T

Source§

fn map_types(&self, types: &Types) -> Result<Cow<'_, Types>, FormatError>

Source§

fn map_type( &self, types: &Types, dt: &DataType, ) -> Result<Cow<'_, DataType>, FormatError>

Source§

impl<T: Format + ?Sized> Format for Box<T>

Source§

fn map_types(&self, types: &Types) -> Result<Cow<'_, Types>, FormatError>

Source§

fn map_type( &self, types: &Types, dt: &DataType, ) -> Result<Cow<'_, DataType>, FormatError>

Implementors§