Struct PathBuilder

Source
pub struct PathBuilder<const MCL: usize, const MCC: usize, const MPL: usize> { /* private fields */ }
Expand description

A helper struct for creating a Path with exactly one memory allocation. Requires total length and component count to be known in advance.

Enforces that each component has a length of at most MCL (max_component_length), that each path has at most MCC (max_component_ccount) components, and that the total size in bytes of all components is at most MPL (max_path_length).

Implementations§

Source§

impl<const MCL: usize, const MCC: usize, const MPL: usize> PathBuilder<MCL, MCC, MPL>

Source

pub fn new( total_length: usize, component_count: usize, ) -> Result<Self, InvalidPathError>

Creates a builder for a path of known total length and component count. The component data must be filled in before building.

Source

pub fn new_from_prefix( target_total_length: usize, target_component_count: usize, reference: &Path<MCL, MCC, MPL>, prefix_component_count: usize, ) -> Result<Self, InvalidPathError>

Creates a builder for a path of known total length and component count, efficiently prefilled with the first prefix_component_count components of a given reference path. Panics if there are not enough components in the reference. The missing component data must be filled in before building.

Source

pub async fn append_component_from_bulk_producer<P>( &mut self, component_length: usize, p: &mut P, ) -> Result<(), DecodeError<P::Final, P::Error, Blame>>
where P: BulkProducer<Item = u8>,

Appends data for a component of known length by reading data from a BulkProducer of bytes. Panics if component_length > MCL.

Source

pub fn append_component(&mut self, component: Component<'_, MCL>)

Appends the data for the next component.

Source

pub fn build(self) -> Path<MCL, MCC, MPL>

Turn this builder into an immutable Path.

Panics if the number of components or the total length does not match what was claimed in PathBuilder::new.

Auto Trait Implementations§

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> Freeze for PathBuilder<MCL, MCC, MPL>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> RefUnwindSafe for PathBuilder<MCL, MCC, MPL>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> Send for PathBuilder<MCL, MCC, MPL>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> Sync for PathBuilder<MCL, MCC, MPL>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> Unpin for PathBuilder<MCL, MCC, MPL>

§

impl<const MCL: usize, const MCC: usize, const MPL: usize> UnwindSafe for PathBuilder<MCL, MCC, MPL>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.