Skip to main content

RawInput

Struct RawInput 

Source
pub struct RawInput<'a> { /* private fields */ }
Expand description

The encoded input of a value.

This is a well-known borrowing extension (see ext) which carries the encoding of a value between formats and Raw values:

  • formats emit it for values that are requested as raw values (the values of Raw types). They validate the value and pass on its input instead of its events.
  • Raw values emit it when they are serialized and the serializer writes the format as it is (see State::declare_raw_format).

It knows its format, so it’s parsed into its value where it ends up in something that does not know it (for instance when a recording that holds it is serialized).

Implementations§

Source§

impl<'a> RawInput<'a>

Source

pub unsafe fn new<B: Into<Cow<'a, [u8]>>>( bytes: B, format: &'static RawFormatInfo, ) -> RawInput<'a>

Creates the input of a value.

§Safety

The input must be a single, valid value of the format. If the format is text, it must be valid UTF-8. Serializers of the format write the input as it is.

Descriptions of formats can be created by anybody (with the identity of any format) and requests for raw values can be for any format: formats must check that the description has the identity of their own format (see State::take_raw_request) rather than rely on where it comes from or on its data.

Source

pub fn as_bytes(&self) -> &[u8] ⓘ

Returns the encoded value.

Source

pub fn as_str(&self) -> Option<&str>

Returns the encoded value as text if the format is text.

Source

pub fn format(&self) -> &'static RawFormatInfo

Returns the format of the value.

Source

pub fn is<F: RawFormat>(&self) -> bool

Returns true if the value is of the format F.

Source

pub fn is_format(&self, id: &'static RawFormatId) -> bool

Returns true if the value is of the format with the identity.

Serializers check with this whether they write a value as it is (unlike is, this does not refer to the functions of the format).

Source

pub fn into_owned(self) -> RawInput<'static>

Detaches the input from the data it borrows.

Source

pub fn record(&self) -> Result<RecordBuf<'_>, Error>

Records the value.

Source

pub fn replay<'x>( &'x self, sink: SinkHandle<'_, 'x>, state: &mut State, ) -> Result<(), Error>

Replays the value into a sink.

The value is parsed, the sink can borrow its data.

Source

pub fn deserialize<'x, T: Deserialize<'x>>(&'x self) -> Result<T, Error>

Deserializes the value.

The value can borrow from the input (and the data it borrows).

Trait Implementations§

Source§

impl BorrowedExtension for RawInput<'static>

Source§

type Value<'a> = RawInput<'a>

The type of the values of this extension.
Source§

fn name<'v>(_value: &'v RawInput<'_>) -> &'v str

Returns the human readable name of the extension type. Read more
Source§

fn fallback<'v>(value: &'v RawInput<'_>) -> Atom<'v>

Lowers the value into the core data model. Read more
Source§

fn to_static(value: &RawInput<'_>) -> RawInput<'static>

Detaches a value from the data it borrows. Read more
Source§

fn shorten<'s, 'l: 's>(value: &'s RawInput<'l>) -> &'s RawInput<'s>

Shortens the lifetime of a value. Read more
Source§

impl<'a> Clone for RawInput<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RawInput<'_>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RawInput<'_>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for RawInput<'a>

§

impl<'a> !UnwindSafe for RawInput<'a>

§

impl<'a> Freeze for RawInput<'a>

§

impl<'a> Send for RawInput<'a>

§

impl<'a> Sync for RawInput<'a>

§

impl<'a> Unpin for RawInput<'a>

§

impl<'a> UnsafeUnpin for RawInput<'a>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.