pub struct EntityRoot { /* private fields */ }Expand description
Represents the root component in an Entity Resource Name (ERN).
The root component is a unique identifier for the base resource in the ERN hierarchy.
It uses the mti crate’s MagicTypeId with UUID v7 algorithm to generate
time-ordered, unique identifiers that enable k-sortability.
When using EntityRoot, each call to create a new root with the same name will
generate a different ID, as it incorporates the current timestamp. This makes
EntityRoot suitable for resources that should be ordered by creation time.
For content-addressable, deterministic IDs, use SHA1Name instead.
Implementations§
Source§impl EntityRoot
impl EntityRoot
Sourcepub fn name(&self) -> &MagicTypeId
pub fn name(&self) -> &MagicTypeId
Returns a reference to the underlying MagicTypeId.
This is useful when you need to access the raw identifier for comparison or sorting operations.
§Example
let root1 = EntityRoot::new("resource1".to_string())?;
let root2 = EntityRoot::new("resource2".to_string())?;
// Compare roots by their MagicTypeId
let comparison = root1.name().cmp(root2.name());Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns the string representation of this root’s identifier.
§Example
let root = EntityRoot::new("profile".to_string())?;
let id_str = root.as_str();
// The string will contain the original name followed by a timestamp-based suffix
assert!(id_str.starts_with("profile_"));Sourcepub fn new(value: String) -> Result<EntityRoot, ErnError>
pub fn new(value: String) -> Result<EntityRoot, ErnError>
Creates a new EntityRoot with the given value.
This method generates a time-ordered, unique identifier using the UUID v7 algorithm.
Each call to this method with the same input value will generate a different ID,
as it incorporates the current timestamp. This makes EntityRoot suitable for
resources that should be ordered by creation time.
§Arguments
value- The string value to use as the base for the entity root ID
§Validation Rules
- Value cannot be empty
- Value must be between 1 and 255 characters
§Returns
Ok(EntityRoot)- If validation passesErr(ErnError)- If validation fails
§Example
let root = EntityRoot::new("profile".to_string())?;
// The ID will contain the original name followed by a timestamp-based suffix
assert!(root.to_string().starts_with("profile_"));Trait Implementations§
Source§impl AsRef<MagicTypeId> for EntityRoot
impl AsRef<MagicTypeId> for EntityRoot
Source§fn as_ref(&self) -> &MagicTypeId
fn as_ref(&self) -> &MagicTypeId
Source§impl Clone for EntityRoot
impl Clone for EntityRoot
Source§fn clone(&self) -> EntityRoot
fn clone(&self) -> EntityRoot
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for EntityRoot
impl Debug for EntityRoot
Source§impl Default for EntityRoot
impl Default for EntityRoot
Source§fn default() -> EntityRoot
fn default() -> EntityRoot
Source§impl Display for EntityRoot
impl Display for EntityRoot
Source§impl ErnComponent for EntityRoot
impl ErnComponent for EntityRoot
Source§impl From<MagicTypeId> for EntityRoot
impl From<MagicTypeId> for EntityRoot
Source§fn from(value: MagicTypeId) -> EntityRoot
fn from(value: MagicTypeId) -> EntityRoot
Source§impl FromStr for EntityRoot
Implementation of FromStr for EntityRoot to create an entity root from a string.
impl FromStr for EntityRoot
Implementation of FromStr for EntityRoot to create an entity root from a string.
Source§fn from_str(s: &str) -> Result<EntityRoot, <EntityRoot as FromStr>::Err>
fn from_str(s: &str) -> Result<EntityRoot, <EntityRoot as FromStr>::Err>
Creates an EntityRoot from a string.
This method generates a time-ordered, unique identifier using the UUID v7 algorithm. Each call to this method with the same input string will generate a different ID, as it incorporates the current timestamp.
§Arguments
s- The string value to use as the base for the entity root ID
§Returns
Ok(EntityRoot)- If validation passesErr(ErnError)- If validation fails
Source§impl Hash for EntityRoot
impl Hash for EntityRoot
Source§impl PartialEq for EntityRoot
impl PartialEq for EntityRoot
Source§impl PartialOrd for EntityRoot
impl PartialOrd for EntityRoot
impl Eq for EntityRoot
impl StructuralPartialEq for EntityRoot
Auto Trait Implementations§
impl Freeze for EntityRoot
impl RefUnwindSafe for EntityRoot
impl Send for EntityRoot
impl Sync for EntityRoot
impl Unpin for EntityRoot
impl UnsafeUnpin for EntityRoot
impl UnwindSafe for EntityRoot
Blanket Implementations§
Source§impl<T> ActonMessage for T
impl<T> ActonMessage for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.