pub struct Parts(/* private fields */);Expand description
Represents a collection of parts in the ERN (Entity Resource Name), handling multiple segments.
Implementations§
Source§impl Parts
impl Parts
Sourcepub fn add_part<T>(self, part: T) -> Result<Self, ErnError>
pub fn add_part<T>(self, part: T) -> Result<Self, ErnError>
Adds a part to the collection, bounded by DEFAULT_MAX_PARTS.
§Arguments
part- ThePartto be added to the collection.
§Returns
Result<Parts, ErnError>- The updated Parts collection, or an error if the collection already holdsDEFAULT_MAX_PARTSparts.
Sourcepub fn add_part_with_limit<T>(
self,
part: T,
max_parts: usize,
) -> Result<Self, ErnError>
pub fn add_part_with_limit<T>( self, part: T, max_parts: usize, ) -> Result<Self, ErnError>
Adds a part to the collection, bounded by a caller-chosen maximum.
Use this when DEFAULT_MAX_PARTS is the wrong bound for your domain - deep
supervision hierarchies being the motivating case.
§Arguments
part- ThePartto be added to the collection.max_parts- The maximum number of parts this collection may hold.
§Returns
Result<Parts, ErnError>- The updated Parts collection, or an error if the collection already holdsmax_partsparts.
§Example
let mut parts = Parts::default();
for i in 0..32 {
parts = parts.add_part_with_limit(Part::new(format!("level{i}"))?, 64)?;
}
assert_eq!(parts.len(), 32);Sourcepub fn into_owned(self) -> Parts
pub fn into_owned(self) -> Parts
Converts the Parts into an owned version with ’static lifetime
Trait Implementations§
impl Eq for Parts
Source§impl ErnComponent for Parts
Implementation for the Parts component of an ERN.
impl ErnComponent for Parts
Implementation for the Parts component of an ERN.
The Parts component represents a collection of path parts in the ERN.
Its NextState is itself, allowing for multiple parts to be added.
Source§type NextState = Parts
type NextState = Parts
The type of the next component that should follow this one in the ERN structure. Read more
Source§fn prefix() -> &'static str
fn prefix() -> &'static str
Returns the prefix string that should appear before this component in an ERN. Read more
Source§fn build_root(_value: &str) -> Option<Result<EntityRoot, ErnError>>
fn build_root(_value: &str) -> Option<Result<EntityRoot, ErnError>>
Builds the ERN root component this type contributes, if it can occupy the root slot. Read more
Source§impl FromIterator<Part> for Parts
impl FromIterator<Part> for Parts
Source§impl IntoIterator for Parts
impl IntoIterator for Parts
Source§impl<'a> IntoIterator for &'a Parts
impl<'a> IntoIterator for &'a Parts
Source§impl PartialOrd for Parts
impl PartialOrd for Parts
impl StructuralPartialEq for Parts
Auto Trait Implementations§
impl Freeze for Parts
impl RefUnwindSafe for Parts
impl Send for Parts
impl Sync for Parts
impl Unpin for Parts
impl UnsafeUnpin for Parts
impl UnwindSafe for Parts
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more