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.
impl ErnBuilder<()>
Implementation of ErnBuilder for the initial state.
Sourcepub fn new() -> ErnBuilder<Domain>
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.
impl ErnBuilder<Part>
Implementation for the Part state, allowing finalization of the ERN.
Source§impl ErnBuilder<Parts>
Implementation for the Parts state, allowing finalization of the ERN.
impl ErnBuilder<Parts>
Implementation for the Parts state, allowing finalization of the ERN.
Source§impl<Component: ErnComponent + Hash + Clone + PartialEq + Eq> ErnBuilder<Component>
Generic implementation for all component states.
impl<Component: ErnComponent + Hash + Clone + PartialEq + Eq> ErnBuilder<Component>
Generic implementation for all component states.
Sourcepub fn with<N>(
self,
part: impl Into<String>,
) -> Result<ErnBuilder<N::NextState>, ErnError>
pub fn with<N>( self, part: impl Into<String>, ) -> Result<ErnBuilder<N::NextState>, ErnError>
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 stateErr(ErnError)- If the component value is invalid