Struct alkahest::advanced::Deserializer
source · pub struct Deserializer<'de> { /* private fields */ }
Expand description
Deserializer from raw bytes. Provides methods for deserialization of values.
Implementations§
source§impl<'de> Deserializer<'de>
impl<'de> Deserializer<'de>
sourcepub const fn new(
stack: usize,
input: &'de [u8]
) -> Result<Self, DeserializeError>
pub const fn new( stack: usize, input: &'de [u8] ) -> Result<Self, DeserializeError>
Creates new deserializer from input buffer.
Errors
Returns DeserializeError::OutOfBounds
if
stack
is greater than input.len()
.
sourcepub const fn new_unchecked(stack: usize, input: &'de [u8]) -> Self
pub const fn new_unchecked(stack: usize, input: &'de [u8]) -> Self
Creates new deserializer from input buffer without bounds checking.
sourcepub fn read_bytes(&mut self, len: usize) -> Result<&'de [u8], DeserializeError>
pub fn read_bytes(&mut self, len: usize) -> Result<&'de [u8], DeserializeError>
Reads specified number of bytes from the input buffer. Returns slice of bytes. Advances the input buffer.
Errors
Returns DeserializeError
if not enough bytes on stack.
sourcepub fn read_byte(&mut self) -> Result<u8, DeserializeError>
pub fn read_byte(&mut self) -> Result<u8, DeserializeError>
Reads specified number of bytes from the input buffer. Returns slice of bytes. Advances the input buffer.
Errors
Returns DeserializeError
if stack is empty.
sourcepub fn read_byte_array<const N: usize>(
&mut self
) -> Result<[u8; N], DeserializeError>
pub fn read_byte_array<const N: usize>( &mut self ) -> Result<[u8; N], DeserializeError>
Reads specified number of bytes from the input buffer. Returns slice of bytes. Advances the input buffer.
Errors
Returns DeserializeError
if not enough bytes on stack.
sourcepub fn read_all_bytes(self) -> &'de [u8]
pub fn read_all_bytes(self) -> &'de [u8]
Reads the rest of the input buffer as bytes.
sourcepub fn read_value<F, T>(&mut self, last: bool) -> Result<T, DeserializeError>where
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn read_value<F, T>(&mut self, last: bool) -> Result<T, DeserializeError>where F: Formula + ?Sized, T: Deserialize<'de, F>,
Reads and deserializes field from the input buffer. Advances the input buffer.
Errors
Returns DeserializeError
if deserialization fails.
sourcepub fn read_back_value<F, T>(&mut self) -> Result<T, DeserializeError>where
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn read_back_value<F, T>(&mut self) -> Result<T, DeserializeError>where F: Formula + ?Sized, T: Deserialize<'de, F>,
Reads and deserializes field from the back of input buffer. Advances the input buffer.
Errors
Returns DeserializeError
if deserialization fails.
sourcepub fn read_in_place<F, T>(
&mut self,
place: &mut T,
last: bool
) -> Result<(), DeserializeError>where
F: Formula + ?Sized,
T: Deserialize<'de, F> + ?Sized,
pub fn read_in_place<F, T>( &mut self, place: &mut T, last: bool ) -> Result<(), DeserializeError>where F: Formula + ?Sized, T: Deserialize<'de, F> + ?Sized,
Reads and deserializes field from the input buffer in-place.
Errors
Returns DeserializeError
if deserialization fails.
sourcepub fn deref<F>(self) -> Result<Deserializer<'de>, DeserializeError>where
F: Formula + ?Sized,
pub fn deref<F>(self) -> Result<Deserializer<'de>, DeserializeError>where F: Formula + ?Sized,
Reads and deserializes reference from the input buffer.
Errors
Returns DeserializeError
if reference is out of bounds
or has address larger that self.
sourcepub fn into_sized_iter<F, T>(self) -> DeIter<'de, F, T, IterSized> ⓘwhere
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn into_sized_iter<F, T>(self) -> DeIter<'de, F, T, IterSized> ⓘwhere F: Formula + ?Sized, T: Deserialize<'de, F>,
Converts deserializer into iterator over deserialized values with specified formula. The formula must be sized and size must match.
Panics
Panics if formula is not sized.
sourcepub fn into_unsized_iter<F, T>(self) -> DeIter<'de, F, T> ⓘwhere
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn into_unsized_iter<F, T>(self) -> DeIter<'de, F, T> ⓘwhere F: Formula + ?Sized, T: Deserialize<'de, F>,
Converts deserializer into iterator over deserialized values with specified formula.
sourcepub fn into_sized_array_iter<F, T>(
self,
len: usize
) -> DeIter<'de, F, T, IterSized> ⓘwhere
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn into_sized_array_iter<F, T>( self, len: usize ) -> DeIter<'de, F, T, IterSized> ⓘwhere F: Formula + ?Sized, T: Deserialize<'de, F>,
Converts deserializer into iterator over deserialized values with specified formula. The formula must be sized and size must match.
Panics
Panics if formula is not sized.
sourcepub fn into_unsized_array_iter<F, T>(self, len: usize) -> DeIter<'de, F, T> ⓘwhere
F: Formula + ?Sized,
T: Deserialize<'de, F>,
pub fn into_unsized_array_iter<F, T>(self, len: usize) -> DeIter<'de, F, T> ⓘwhere F: Formula + ?Sized, T: Deserialize<'de, F>,
Converts deserializer into iterator over deserialized values with specified formula.
Trait Implementations§
source§impl<'de> Clone for Deserializer<'de>
impl<'de> Clone for Deserializer<'de>
source§fn clone(&self) -> Deserializer<'de>
fn clone(&self) -> Deserializer<'de>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<'de> RefUnwindSafe for Deserializer<'de>
impl<'de> Send for Deserializer<'de>
impl<'de> Sync for Deserializer<'de>
impl<'de> Unpin for Deserializer<'de>
impl<'de> UnwindSafe for Deserializer<'de>
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
source§impl<'de, F, T> Deserialize<'de, As<F>> for Twhere
F: BareFormula + ?Sized,
T: Deserialize<'de, F>,
impl<'de, F, T> Deserialize<'de, As<F>> for Twhere F: BareFormula + ?Sized, T: Deserialize<'de, F>,
source§fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(deserializer: Deserializer<'de>) -> Result<T, DeserializeError>
source§fn deserialize_in_place(
&mut self,
deserializer: Deserializer<'de>
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, deserializer: Deserializer<'de> ) -> Result<(), DeserializeError>
self
with data from the input
. Read moresource§impl<'de, F, T> Deserialize<'de, Ref<F>> for Twhere
F: BareFormula + ?Sized,
T: Deserialize<'de, F> + ?Sized,
impl<'de, F, T> Deserialize<'de, Ref<F>> for Twhere F: BareFormula + ?Sized, T: Deserialize<'de, F> + ?Sized,
source§fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
fn deserialize(de: Deserializer<'de>) -> Result<T, DeserializeError>
source§fn deserialize_in_place(
&mut self,
de: Deserializer<'de>
) -> Result<(), DeserializeError>
fn deserialize_in_place( &mut self, de: Deserializer<'de> ) -> Result<(), DeserializeError>
self
with data from the input
. Read more