pub struct Object {
pub id: ObjectId,
pub name: String,
pub object_type: String,
pub traits: HashMap<String, Trait>,
pub metadata: HashMap<String, String>,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}Expand description
An object is an identity container that composes traits
Fields§
§id: ObjectIdUnique identifier for this object
name: StringName of the object
object_type: StringType of the object
traits: HashMap<String, Trait>Traits associated with this object
metadata: HashMap<String, String>Metadata about the object
created_at: DateTime<Utc>Creation timestamp
updated_at: DateTime<Utc>Last update timestamp
Implementations§
Source§impl Object
impl Object
Sourcepub fn new(name: impl Into<String>, object_type: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, object_type: impl Into<String>) -> Self
Create a new object with the given name and type
Sourcepub fn with_traits(
name: impl Into<String>,
object_type: impl Into<String>,
traits: Vec<Trait>,
) -> Self
pub fn with_traits( name: impl Into<String>, object_type: impl Into<String>, traits: Vec<Trait>, ) -> Self
Create a new object with initial traits
Sourcepub fn with_capacity(
name: impl Into<String>,
object_type: impl Into<String>,
trait_capacity: usize,
metadata_capacity: usize,
) -> Self
pub fn with_capacity( name: impl Into<String>, object_type: impl Into<String>, trait_capacity: usize, metadata_capacity: usize, ) -> Self
Create a new object with pre-allocated capacity
Sourcepub fn object_type(&self) -> &str
pub fn object_type(&self) -> &str
Get the object type
Sourcepub fn add_traits(&mut self, traits: impl IntoIterator<Item = Trait>)
pub fn add_traits(&mut self, traits: impl IntoIterator<Item = Trait>)
Add multiple traits efficiently
Sourcepub fn add_traits_bulk(&mut self, traits: impl IntoIterator<Item = Trait>)
pub fn add_traits_bulk(&mut self, traits: impl IntoIterator<Item = Trait>)
Add multiple traits without timestamp updates (for bulk operations)
Sourcepub fn add_trait_internal(&mut self, trait_obj: Trait)
pub fn add_trait_internal(&mut self, trait_obj: Trait)
Add a trait without timestamp update (for internal operations)
Sourcepub fn remove_trait(&mut self, trait_name: &str) -> Option<Trait>
pub fn remove_trait(&mut self, trait_name: &str) -> Option<Trait>
Remove a trait from this object
Sourcepub fn get_trait_mut(&mut self, trait_name: &str) -> Option<&mut Trait>
pub fn get_trait_mut(&mut self, trait_name: &str) -> Option<&mut Trait>
Get a trait by name (mutable)
Sourcepub fn get_trait_data(&self, trait_name: &str) -> Option<&TraitData>
pub fn get_trait_data(&self, trait_name: &str) -> Option<&TraitData>
Get trait data by name (zero-copy access)
Sourcepub fn get_trait_data_mut(&mut self, trait_name: &str) -> Option<&mut TraitData>
pub fn get_trait_data_mut(&mut self, trait_name: &str) -> Option<&mut TraitData>
Get trait data by name (mutable, zero-copy access)
Sourcepub fn has_traits(&self, trait_names: &[&str]) -> bool
pub fn has_traits(&self, trait_names: &[&str]) -> bool
Check if the object has multiple traits (efficient batch check)
Sourcepub fn has_any_traits(&self) -> bool
pub fn has_any_traits(&self) -> bool
Check if the object has any traits
Sourcepub fn get_metadata(&self, key: &str) -> Option<&String>
pub fn get_metadata(&self, key: &str) -> Option<&String>
Get a metadata value
Sourcepub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn set_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Set a metadata value
Sourcepub fn created_at(&self) -> DateTime<Utc>
pub fn created_at(&self) -> DateTime<Utc>
Get the creation timestamp
Sourcepub fn updated_at(&self) -> DateTime<Utc>
pub fn updated_at(&self) -> DateTime<Utc>
Get the last update timestamp
Sourcepub fn trait_names(&self) -> Vec<&String>
pub fn trait_names(&self) -> Vec<&String>
Get trait names as a vector
Sourcepub fn trait_count(&self) -> usize
pub fn trait_count(&self) -> usize
Get the number of traits
Sourcepub fn metadata_count(&self) -> usize
pub fn metadata_count(&self) -> usize
Get the number of metadata entries
Sourcepub fn reserve_traits(&mut self, additional: usize)
pub fn reserve_traits(&mut self, additional: usize)
Reserve capacity for traits
Sourcepub fn reserve_metadata(&mut self, additional: usize)
pub fn reserve_metadata(&mut self, additional: usize)
Reserve capacity for metadata