pub struct NewlinesAccumulator<const N: usize> { /* private fields */ }
Expand description
An accumulator used to collect chunked newline data and deserialize it.
This is often useful when you receive “parts” of the message at a time, for example when draining a serial port buffer that may not contain an entire uninterrupted message.
Implementations§
Source§impl<const N: usize> NewlinesAccumulator<N>
impl<const N: usize> NewlinesAccumulator<N>
Sourcepub fn feed<'a, T>(&mut self, input: &'a [u8]) -> FeedResult<'a, T>where
T: for<'de> Deserialize<'de>,
pub fn feed<'a, T>(&mut self, input: &'a [u8]) -> FeedResult<'a, T>where
T: for<'de> Deserialize<'de>,
Appends data to the internal buffer and attempts to deserialize the accumulated data into
T
.
Sourcepub fn feed_ref<'de, 'a, T>(&'de mut self, input: &'a [u8]) -> FeedResult<'a, T>where
T: Deserialize<'de>,
pub fn feed_ref<'de, 'a, T>(&'de mut self, input: &'a [u8]) -> FeedResult<'a, T>where
T: Deserialize<'de>,
Appends data to the internal buffer and attempts to deserialize the accumulated data into
T
.
This differs from feed, as it allows the T
to reference data within the internal buffer, but
mutably borrows the accumulator for the lifetime of the deserialization.
If T
does not require the reference, the borrow of self
ends at the end of the function.
Auto Trait Implementations§
impl<const N: usize> Freeze for NewlinesAccumulator<N>
impl<const N: usize> RefUnwindSafe for NewlinesAccumulator<N>
impl<const N: usize> Send for NewlinesAccumulator<N>
impl<const N: usize> Sync for NewlinesAccumulator<N>
impl<const N: usize> Unpin for NewlinesAccumulator<N>
impl<const N: usize> UnwindSafe for NewlinesAccumulator<N>
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