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
Rawtypes). They validate the value and pass on its input instead of its events. Rawvalues emit it when they are serialized and the serializer writes the format as it is (seeState::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>
impl<'a> RawInput<'a>
Sourcepub unsafe fn new<B: Into<Cow<'a, [u8]>>>(
bytes: B,
format: &'static RawFormatInfo,
) -> RawInput<'a>
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.
Sourcepub fn format(&self) -> &'static RawFormatInfo
pub fn format(&self) -> &'static RawFormatInfo
Returns the format of the value.
Sourcepub fn is_format(&self, id: &'static RawFormatId) -> bool
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).
Sourcepub fn into_owned(self) -> RawInput<'static>
pub fn into_owned(self) -> RawInput<'static>
Detaches the input from the data it borrows.
Sourcepub fn replay<'x>(
&'x self,
sink: SinkHandle<'_, 'x>,
state: &mut State,
) -> Result<(), Error>
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.
Sourcepub fn deserialize<'x, T: Deserialize<'x>>(&'x self) -> Result<T, Error>
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).