pub struct RecordSequenceBuilder<R, I> { /* private fields */ }
Expand description
A builder capable of serializing a sequence of records.
A RecordSequenceBuilder
is instantiated with an Iterator
that provides
RecordBuilder
s to be serialized. The item produced by the iterator can
be any type which implements Borrow<R>
for R: RecordBuilder
.
RecordSequenceBuilder
implements InnerPacketBuilder
.
Implementations§
Source§impl<R, I> RecordSequenceBuilder<R, I>
impl<R, I> RecordSequenceBuilder<R, I>
Sourcepub fn new(records: I) -> Self
pub fn new(records: I) -> Self
Creates a new RecordSequenceBuilder
with the given records
.
records
must produce the same sequence of values from every iteration,
even if cloned. Serialization is typically performed with two passes on
records
: one to calculate the total length in bytes (serialized_len
)
and another one to serialize to a buffer (serialize_into
). Violating
this rule may result in panics or malformed serialized record sequences.
Source§impl<R, I> RecordSequenceBuilder<R, I>
impl<R, I> RecordSequenceBuilder<R, I>
Sourcepub fn serialized_len(&self) -> usize
pub fn serialized_len(&self) -> usize
Returns the total length, in bytes, of the serialized encoding of the
records contained within self
.
Sourcepub fn serialize_into(&self, buffer: &mut [u8])
pub fn serialize_into(&self, buffer: &mut [u8])
Serializes all the records contained within self
into the given
buffer.
§Panics
serialize_into
expects that buffer
has enough bytes to serialize the
contained records (as obtained from serialized_len
), otherwise it’s
considered a violation of the API contract and the call may panic.
Trait Implementations§
Source§impl<R: Clone, I: Clone> Clone for RecordSequenceBuilder<R, I>
impl<R: Clone, I: Clone> Clone for RecordSequenceBuilder<R, I>
Source§fn clone(&self) -> RecordSequenceBuilder<R, I>
fn clone(&self) -> RecordSequenceBuilder<R, I>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<R, I> InnerPacketBuilder for RecordSequenceBuilder<R, I>
impl<R, I> InnerPacketBuilder for RecordSequenceBuilder<R, I>
Source§fn serialize(&self, buffer: &mut [u8])
fn serialize(&self, buffer: &mut [u8])
Source§fn into_serializer(self) -> InnerSerializer<Self, EmptyBuf>where
Self: Sized,
fn into_serializer(self) -> InnerSerializer<Self, EmptyBuf>where
Self: Sized,
Source§fn into_serializer_with<B: ShrinkBuffer>(
self,
buffer: B,
) -> InnerSerializer<Self, B>where
Self: Sized,
fn into_serializer_with<B: ShrinkBuffer>(
self,
buffer: B,
) -> InnerSerializer<Self, B>where
Self: Sized,
InnerPacketBuilder
into a Serializer
with a buffer
that can be used for serialization. Read moreAuto Trait Implementations§
impl<R, I> Freeze for RecordSequenceBuilder<R, I>where
I: Freeze,
impl<R, I> RefUnwindSafe for RecordSequenceBuilder<R, I>where
I: RefUnwindSafe,
R: RefUnwindSafe,
impl<R, I> Send for RecordSequenceBuilder<R, I>
impl<R, I> Sync for RecordSequenceBuilder<R, I>
impl<R, I> Unpin for RecordSequenceBuilder<R, I>
impl<R, I> UnwindSafe for RecordSequenceBuilder<R, I>where
I: UnwindSafe,
R: UnwindSafe,
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)