pub struct Trait {
pub id: TraitId,
pub name: String,
pub version: u32,
pub data: TraitData,
pub metadata: HashMap<String, String>,
}Expand description
A trait represents immutable domain state
Fields§
§id: TraitIdUnique identifier for this trait
name: StringName of the trait
version: u32Version of the trait
data: TraitDataThe actual trait data
metadata: HashMap<String, String>Metadata about the trait
Implementations§
Source§impl Trait
impl Trait
Sourcepub fn new(name: impl Into<String>, data: TraitData) -> Self
pub fn new(name: impl Into<String>, data: TraitData) -> Self
Create a new trait with the given name and data
Sourcepub fn with_metadata(
name: impl Into<String>,
data: TraitData,
metadata: HashMap<String, String>,
) -> Self
pub fn with_metadata( name: impl Into<String>, data: TraitData, metadata: HashMap<String, String>, ) -> Self
Create a new trait with metadata
Sourcepub fn with_capacity(
name: impl Into<String>,
data: TraitData,
metadata_capacity: usize,
) -> Self
pub fn with_capacity( name: impl Into<String>, data: TraitData, metadata_capacity: usize, ) -> Self
Create a new trait with pre-allocated capacity
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 new_version(&self, data: TraitData) -> Self
pub fn new_version(&self, data: TraitData) -> Self
Create a new version of this trait
Sourcepub fn metadata_count(&self) -> usize
pub fn metadata_count(&self) -> usize
Get metadata count
Sourcepub fn reserve_metadata(&mut self, additional: usize)
pub fn reserve_metadata(&mut self, additional: usize)
Reserve capacity for metadata
Sourcepub fn clear_metadata(&mut self)
pub fn clear_metadata(&mut self)
Clear all metadata
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Trait
impl<'de> Deserialize<'de> for Trait
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Trait
impl RefUnwindSafe for Trait
impl Send for Trait
impl Sync for Trait
impl Unpin for Trait
impl UnwindSafe for Trait
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