Struct former::exposed::CollectionFormer

source ·
pub struct CollectionFormer<E, Definition>
where Definition: FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,
{ /* private fields */ }
Expand description

A builder structure for constructing collections with a fluent and flexible interface.

Implementations§

source§

impl<E, Definition> CollectionFormer<E, Definition>
where Definition: FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,

source

pub fn begin( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: <Definition as FormerDefinition>::End ) -> CollectionFormer<E, Definition>

Begins the construction process of a collection with optional initial storage and context, setting up an on_end completion handler to finalize the collection’s construction.

source

pub fn begin_coercing<IntoEnd>( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: IntoEnd ) -> CollectionFormer<E, Definition>
where IntoEnd: Into<<Definition as FormerDefinition>::End>,

Provides a variation of the begin method allowing for coercion of the end handler, facilitating ease of integration with different end conditions.

source

pub fn end(self) -> <Definition as FormerDefinition>::Formed

Finalizes the building process, returning the formed or a context incorporating it.

source

pub fn form(self) -> <Definition as FormerDefinition>::Formed

Alias for the end method to align with typical builder pattern terminologies.

source

pub fn replace( self, storage: <Definition as FormerDefinition>::Storage ) -> CollectionFormer<E, Definition>

Replaces the current storage with a provided storage, allowing for resetting or redirection of the building process.

source§

impl<E, Storage, Formed, Definition> CollectionFormer<E, Definition>
where Definition: FormerDefinition<Context = (), Storage = Storage, Formed = Formed>, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,

source

pub fn new( end: <Definition as FormerDefinition>::End ) -> CollectionFormer<E, Definition>

Constructs a new CollectionFormer instance, starting with an empty storage. This method serves as the entry point for the builder pattern, facilitating the creation of a new collection.

source

pub fn new_coercing<IntoEnd>(end: IntoEnd) -> CollectionFormer<E, Definition>
where IntoEnd: Into<<Definition as FormerDefinition>::End>,

Variant of the new method allowing for end condition coercion, providing flexibility in specifying different types of end conditions dynamically.

source§

impl<E, Definition> CollectionFormer<E, Definition>
where Definition: FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,

source

pub fn add<IntoElement>( self, entry: IntoElement ) -> CollectionFormer<E, Definition>
where IntoElement: Into<E>,

Appends an entry to the end of the storage, expanding the internal collection.

Trait Implementations§

source§

impl<E, Definition> Debug for CollectionFormer<E, Definition>
where Definition: FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,

source§

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

Formats the value using the given formatter. Read more
source§

impl<E, Definition> Default for CollectionFormer<E, Definition>
where E: Default, Definition: Default + FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E> + Default, <Definition as FormerDefinition>::Context: Default, <Definition as FormerDefinition>::End: Default,

source§

fn default() -> CollectionFormer<E, Definition>

Returns the “default value” for a type. Read more
source§

impl<E, Definition> FormerBegin<Definition> for CollectionFormer<E, Definition>
where Definition: FormerDefinition, <Definition as FormerDefinition>::Storage: CollectionAdd<Entry = E>,

source§

fn former_begin( storage: Option<<Definition as FormerDefinition>::Storage>, context: Option<<Definition as FormerDefinition>::Context>, on_end: <Definition as FormerDefinition>::End ) -> CollectionFormer<E, Definition>

Launches the subforming process with an initial storage and context, setting up an on_end completion handler. Read more

Auto Trait Implementations§

§

impl<E, Definition> Freeze for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: Freeze, <Definition as FormerDefinition>::Context: Freeze, <Definition as FormerDefinition>::End: Freeze,

§

impl<E, Definition> RefUnwindSafe for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: RefUnwindSafe, <Definition as FormerDefinition>::Context: RefUnwindSafe, <Definition as FormerDefinition>::End: RefUnwindSafe,

§

impl<E, Definition> Send for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: Send, <Definition as FormerDefinition>::Context: Send, <Definition as FormerDefinition>::End: Send,

§

impl<E, Definition> Sync for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: Sync, <Definition as FormerDefinition>::Context: Sync, <Definition as FormerDefinition>::End: Sync,

§

impl<E, Definition> Unpin for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: Unpin, <Definition as FormerDefinition>::Context: Unpin, <Definition as FormerDefinition>::End: Unpin,

§

impl<E, Definition> UnwindSafe for CollectionFormer<E, Definition>
where <Definition as FormerDefinition>::Storage: UnwindSafe, <Definition as FormerDefinition>::Context: UnwindSafe, <Definition as FormerDefinition>::End: UnwindSafe,

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<S> AssignWithType for S

source§

fn assign_with_type<T, IntoT>(&mut self, component: IntoT)
where IntoT: Into<T>, S: Assign<T, IntoT>,

Sets the value of a component by its type. 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<C, E> EntryToVal<C> for E
where C: Collection<Entry = E>,

§

type Val = <C as Collection>::Val

The type of values stored in the collection. This might be distinct from Entry in complex collections. For example, in a HashMap, while Entry might be a ( key, value ) tuple, Val might only be the value part.
source§

fn entry_to_val(self) -> <E as EntryToVal<C>>::Val

Converts an entry into a value representation specific to the type of collection. This conversion is crucial for handling operations on entries, especially when they need to be treated or accessed as individual values, such as retrieving the value part from a key-value pair in a hash map.
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, U> TryFrom<U> for T
where 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 T
where 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.
source§

impl<C, Val> ValToEntry<C> for Val
where C: CollectionValToEntry<Val>,

source§

fn val_to_entry(self) -> <C as CollectionValToEntry<Val>>::Entry

Invokes the val_to_entry function of the CollectionValToEntry trait to convert the value to an entry.

§

type Entry = <C as CollectionValToEntry<Val>>::Entry

Represents the type of entry that corresponds to the value within the collection.