pub struct Id(/* private fields */);Expand description
A stable, globally unique identifier for a GML object.
Corresponds to the gml:id XML attribute (OGC 07-036 §7.2.4.5).
An Id is a non-empty string; it can be constructed from arbitrary
bytes or strings by hashing them with SHA-256, or generated as a
random UUID v4.
Implementations§
Source§impl Id
impl Id
Sourcepub fn from_hashed_bytes(val: impl AsRef<[u8]>) -> Self
pub fn from_hashed_bytes(val: impl AsRef<[u8]>) -> Self
Constructs an Id by hashing bytes using SHA-256.
The resulting id is a 64-character uppercase hex string.
§Examples
use egml_core::model::base::Id;
let id = Id::from_hashed_bytes(b"hello");
assert_eq!(id.as_str().len(), 64);Sourcepub fn from_hashed_string(val: &str) -> Self
pub fn from_hashed_string(val: &str) -> Self
Constructs an Id by hashing a string using SHA-256.
Two calls with equal strings always produce the same id.
§Examples
use egml_core::model::base::Id;
let id_a = Id::from_hashed_string("object-42");
let id_b = Id::from_hashed_string("object-42");
assert_eq!(id_a, id_b);Sourcepub fn from_hashed_u64(val: u64) -> Self
pub fn from_hashed_u64(val: u64) -> Self
Constructs an Id by hashing a u64 using SHA-256 (little-endian bytes).
Sourcepub fn generate_uuid_v4() -> Self
pub fn generate_uuid_v4() -> Self
Generates a random UUID v4 as an Id.
§Examples
use egml_core::model::base::Id;
let id = Id::generate_uuid_v4();
assert!(!id.as_str().is_empty());Sourcepub fn generate_uuid_v7() -> Self
pub fn generate_uuid_v7() -> Self
Generates a time-ordered UUID v7 as an Id.
v7 encodes a millisecond-precision Unix timestamp in the high bits, making ids lexicographically sortable by creation time — preferable over v4 when ids are stored in a database index.
§Examples
use egml_core::model::base::Id;
let a = Id::generate_uuid_v7();
let b = Id::generate_uuid_v7();
assert!(a.as_str() <= b.as_str());Sourcepub fn generate_uuid_v5(namespace: &Uuid, name: &str) -> Self
pub fn generate_uuid_v5(namespace: &Uuid, name: &str) -> Self
Generates a deterministic UUID v5 from a namespace and a name.
Two calls with the same namespace and name always produce the same
id. Use the predefined namespace constants on Uuid (e.g.
Uuid::NAMESPACE_URL) or supply a custom one.
§Examples
use egml_core::model::base::Id;
use uuid::Uuid;
let id_a = Id::generate_uuid_v5(&Uuid::NAMESPACE_URL, "https://example.com/object-1");
let id_b = Id::generate_uuid_v5(&Uuid::NAMESPACE_URL, "https://example.com/object-1");
assert_eq!(id_a, id_b);Trait Implementations§
impl Eq for Id
Source§impl Ord for Id
impl Ord for Id
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Id
impl PartialOrd for Id
impl StructuralPartialEq for Id
Auto Trait Implementations§
impl Freeze for Id
impl RefUnwindSafe for Id
impl Send for Id
impl Sync for Id
impl Unpin for Id
impl UnsafeUnpin for Id
impl UnwindSafe for Id
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.