pub struct ResourceInstance { /* private fields */ }Expand description
Represents a physical instance of a resource at a specific entity location.
Instances capture the “WHERE” of resources - they represent specific physical instances of resources located at particular entities.
§Examples
use sea_core::primitives::{Entity, Resource, ResourceInstance};
use sea_core::units::unit_from_string;
let warehouse = Entity::new_with_namespace("Warehouse A".to_string(), "default".to_string());
let product = Resource::new_with_namespace("Camera", unit_from_string("units"), "default".to_string());
let camera_123 = ResourceInstance::new(
product.id().clone(),
warehouse.id().clone()
);
assert_eq!(camera_123.entity_id(), warehouse.id());Implementations§
Source§impl ResourceInstance
impl ResourceInstance
Sourcepub fn new(resource_id: ConceptId, entity_id: ConceptId) -> Self
pub fn new(resource_id: ConceptId, entity_id: ConceptId) -> Self
Creates a new ResourceInstance (default namespace).
pub fn new_with_namespace( resource_id: ConceptId, entity_id: ConceptId, namespace: impl Into<String>, ) -> Self
pub fn id(&self) -> &ConceptId
pub fn resource_id(&self) -> &ConceptId
pub fn entity_id(&self) -> &ConceptId
pub fn namespace(&self) -> &str
pub fn set_attribute(&mut self, key: impl Into<String>, value: Value)
pub fn get_attribute(&self, key: &str) -> Option<&Value>
Sourcepub fn attributes(&self) -> &HashMap<String, Value>
pub fn attributes(&self) -> &HashMap<String, Value>
Returns all attributes as a reference.
Trait Implementations§
Source§impl Clone for ResourceInstance
impl Clone for ResourceInstance
Source§fn clone(&self) -> ResourceInstance
fn clone(&self) -> ResourceInstance
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ResourceInstance
impl Debug for ResourceInstance
Source§impl<'de> Deserialize<'de> for ResourceInstance
impl<'de> Deserialize<'de> for ResourceInstance
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
Source§impl PartialEq for ResourceInstance
impl PartialEq for ResourceInstance
Source§impl Serialize for ResourceInstance
impl Serialize for ResourceInstance
impl StructuralPartialEq for ResourceInstance
Auto Trait Implementations§
impl Freeze for ResourceInstance
impl RefUnwindSafe for ResourceInstance
impl Send for ResourceInstance
impl Sync for ResourceInstance
impl Unpin for ResourceInstance
impl UnwindSafe for ResourceInstance
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