pub struct Instance { /* private fields */ }Expand description
Represents a concrete instance of an Entity with specific field values.
Instances allow defining specific data objects in the DSL that can be referenced in policies and flows.
§Examples
use sea_core::primitives::Instance;
use serde_json::json;
let mut vendor = Instance::new_with_namespace("vendor_123", "Vendor", "default");
vendor.set_field("name", json!("Acme Corp"));
vendor.set_field("credit_limit", json!(50000));
assert_eq!(vendor.entity_type(), "Vendor");
assert_eq!(vendor.get_field("name"), Some(&json!("Acme Corp")));Implementations§
Source§impl Instance
impl Instance
Sourcepub fn new(name: impl Into<String>, entity_type: impl Into<String>) -> Self
pub fn new(name: impl Into<String>, entity_type: impl Into<String>) -> Self
Creates a new Instance (default namespace).
pub fn new_with_namespace( name: impl Into<String>, entity_type: impl Into<String>, namespace: impl Into<String>, ) -> Self
pub fn id(&self) -> &ConceptId
pub fn name(&self) -> &str
pub fn entity_type(&self) -> &str
pub fn namespace(&self) -> &str
pub fn set_field(&mut self, key: impl Into<String>, value: Value)
pub fn get_field(&self, key: &str) -> Option<&Value>
Sourcepub fn fields_mut(&mut self) -> &mut HashMap<String, Value>
pub fn fields_mut(&mut self) -> &mut HashMap<String, Value>
Returns a mutable reference to fields for bulk updates.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Instance
impl<'de> Deserialize<'de> for Instance
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
impl StructuralPartialEq for Instance
Auto Trait Implementations§
impl Freeze for Instance
impl RefUnwindSafe for Instance
impl Send for Instance
impl Sync for Instance
impl Unpin for Instance
impl UnwindSafe for Instance
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