Skip to main content

RawFormatInfo

Struct RawFormatInfo 

Source
pub struct RawFormatInfo { /* private fields */ }
Expand description

Describes a RawFormat at runtime.

Formats that can pass on the input of values define a static of this type. It travels with the input of values (see RawInput) so that code which does not know the format can still parse it. Formats are identified by their RawFormatId.

Implementations§

Source§

impl RawFormatInfo

Source

pub const fn new( id: &'static RawFormatId, replay: for<'de> fn(&'de [u8], &mut DeserializeDriver<'_, 'de>) -> Result<(), Error>, encode: fn(SerializeRef<'_>) -> Result<Vec<u8>, Error>, fallback: for<'v> fn(&'v [u8]) -> Atom<'v>, ) -> RawFormatInfo

Creates the description of a format.

  • id identifies the format.
  • replay parses a value and emits its events into the driver.
  • encode encodes a value.
  • fallback returns the fallback atom of an encoded value (see Extension::fallback). It must be Atom::Null for null, so that optionals are None for it, and must not be an extension value.
Source

pub const fn set_data(&mut self, data: &'static (dyn Any + Send + Sync))

Attaches data of the format to the description.

The format gets it back from the description of raw values that are requested (see data). Formats keep what only programs that use their raw values need here (like the scanner of raw values in the parser): as only raw values refer to the description, other programs do not contain it.

Source

pub fn data(&self) -> Option<&'static (dyn Any + Send + Sync)>

Returns the data of the format (see set_data).

Source

pub fn id(&self) -> &'static RawFormatId

Returns the identity of the format.

Source

pub fn name(&self) -> &'static str

Returns the name of the format.

Source

pub fn is_text(&self) -> bool

Returns true if the encoding of the format is text.

Trait Implementations§

Source§

impl Debug for RawFormatInfo

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.