ErnBuilder

Struct ErnBuilder 

Source
pub struct ErnBuilder<State> { /* private fields */ }
Expand description

A type-safe builder for constructing ERN instances.

ErnBuilder uses a state-driven approach to ensure that ERN components are added in the correct order and with proper validation. The generic State parameter tracks which component should be added next, providing compile-time guarantees that ERNs are constructed correctly.

§Example

let ern = ErnBuilder::new()
    .with::<Domain>("my-app")?
    .with::<Category>("users")?
    .with::<Account>("tenant123")?
    .with::<EntityRoot>("profile")?
    .with::<Part>("settings")?
    .build()?;

Implementations§

Source§

impl ErnBuilder<()>

Implementation of ErnBuilder for the initial state.

Source

pub fn new() -> ErnBuilder<Domain>

Creates a new ERN builder to start the construction process.

This is always the first step when creating an ERN.

§Example
let builder = ErnBuilder::new();
Source§

impl ErnBuilder<Part>

Implementation for the Part state, allowing finalization of the ERN.

Source

pub fn build(self) -> Result<Ern, ErnError>

Finalizes the building process and constructs the ERN.

This method is available after at least one Part has been added.

§Returns
  • Ok(Ern) - The fully constructed ERN
  • Err(ErnError) - If any validation fails
Source§

impl ErnBuilder<Parts>

Implementation for the Parts state, allowing finalization of the ERN.

Source

pub fn build(self) -> Result<Ern, ErnError>

Finalizes the building process and constructs the ERN.

This method is available after multiple Parts have been added.

§Returns
  • Ok(Ern) - The fully constructed ERN
  • Err(ErnError) - If any validation fails
Source§

impl<Component: ErnComponent + Hash + Clone + PartialEq + Eq> ErnBuilder<Component>

Generic implementation for all component states.

Source

pub fn with<N>( self, part: impl Into<String>, ) -> Result<ErnBuilder<N::NextState>, ErnError>
where N: ErnComponent<NextState = Component::NextState> + Hash,

Adds the next component to the ERN, transitioning to the appropriate state.

The type parameter N determines which component is being added and ensures components are added in the correct order.

§Arguments
  • part - The string value for this component
§Returns
  • Ok(ErnBuilder<NextState>) - The builder in its next state
  • Err(ErnError) - If the component value is invalid

Auto Trait Implementations§

§

impl<State> Freeze for ErnBuilder<State>

§

impl<State> RefUnwindSafe for ErnBuilder<State>
where State: RefUnwindSafe,

§

impl<State> Send for ErnBuilder<State>
where State: Send,

§

impl<State> Sync for ErnBuilder<State>
where State: Sync,

§

impl<State> Unpin for ErnBuilder<State>
where State: Unpin,

§

impl<State> UnwindSafe for ErnBuilder<State>
where State: 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<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> Same for T

Source§

type Output = T

Should always be Self
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.