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
impl RawFormatInfo
Sourcepub 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
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.
ididentifies the format.replayparses a value and emits its events into the driver.encodeencodes a value.fallbackreturns the fallback atom of an encoded value (seeExtension::fallback). It must beAtom::Nullfor null, so that optionals areNonefor it, and must not be an extension value.
Sourcepub const fn set_data(&mut self, data: &'static (dyn Any + Send + Sync))
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.
Sourcepub fn data(&self) -> Option<&'static (dyn Any + Send + Sync)>
pub fn data(&self) -> Option<&'static (dyn Any + Send + Sync)>
Returns the data of the format (see set_data).
Sourcepub fn id(&self) -> &'static RawFormatId
pub fn id(&self) -> &'static RawFormatId
Returns the identity of the format.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for RawFormatInfo
impl !UnwindSafe for RawFormatInfo
impl Freeze for RawFormatInfo
impl Send for RawFormatInfo
impl Sync for RawFormatInfo
impl Unpin for RawFormatInfo
impl UnsafeUnpin for RawFormatInfo
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more