pub struct AlignedRecordSequenceBuilder<R, I> { /* private fields */ }
Expand description

A builder capable of serializing a sequence of aligned records.

An AlignedRecordSequenceBuilder is instantiated with an Iterator that provides AlignedRecordBuilders to be serialized. The item produced by the iterator can be any type which implements Borrow<R> for R: AlignedRecordBuilder.

AlignedRecordSequenceBuilder implements InnerPacketBuilder.

Implementations§

source§

impl<R, I> AlignedRecordSequenceBuilder<R, I>

source

pub fn new(start_pos: usize, records: I) -> Self

Creates a new AlignedRecordSequenceBuilder with given records and start_pos.

records must produce the same sequence of values from every iteration, even if cloned. See RecordSequenceBuilder for more details.

Alignment is calculated relative to the beginning of a virtual space of bytes. If non-zero, start_pos instructs the serializer to consider the buffer passed to serialize_into to start at the byte start_pos within this virtual space, and to calculate alignment and padding accordingly. For example, in the IPv6 Hop-by-Hop extension header, a fixed header of two bytes precedes that extension header’s options, but alignment is calculated relative to the beginning of the extension header, not relative to the beginning of the options. Thus, when constructing an AlignedRecordSequenceBuilder to serialize those options, start_pos would be 2.

source§

impl<R, I> AlignedRecordSequenceBuilder<R, I>where R: AlignedRecordBuilder, I: Iterator + Clone, I::Item: Borrow<R>,

source

pub fn serialized_len(&self) -> usize

Returns the total length, in bytes, of the serialized records contained within self.

Note that this length includes all padding required to ensure that all records satisfy their alignment requirements.

source

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: Debug, I: Debug> Debug for AlignedRecordSequenceBuilder<R, I>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R, I> RefUnwindSafe for AlignedRecordSequenceBuilder<R, I>where I: RefUnwindSafe, R: RefUnwindSafe,

§

impl<R, I> Send for AlignedRecordSequenceBuilder<R, I>where I: Send, R: Send,

§

impl<R, I> Sync for AlignedRecordSequenceBuilder<R, I>where I: Sync, R: Sync,

§

impl<R, I> Unpin for AlignedRecordSequenceBuilder<R, I>where I: Unpin, R: Unpin,

§

impl<R, I> UnwindSafe for AlignedRecordSequenceBuilder<R, I>where I: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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.