pub struct Flow { /* private fields */ }Expand description
Represents a transfer of a resource between two entities.
Flows are the “MOVEMENT” in enterprise models - they capture the transfer of resources from one entity to another.
§Examples
use sea_core::primitives::{Entity, Resource, Flow};
use sea_core::units::unit_from_string;
use rust_decimal::Decimal;
let warehouse = Entity::new_with_namespace("Warehouse".to_string(), "default".to_string());
let factory = Entity::new_with_namespace("Factory".to_string(), "default".to_string());
let product = Resource::new_with_namespace("Widget", unit_from_string("units"), "default".to_string());
let flow = Flow::new(
product.id().clone(),
warehouse.id().clone(),
factory.id().clone(),
Decimal::from(100)
);
assert_eq!(flow.quantity(), Decimal::from(100));Implementations§
Source§impl Flow
impl Flow
Sourcepub fn new(
resource_id: ConceptId,
from_id: ConceptId,
to_id: ConceptId,
quantity: Decimal,
) -> Self
pub fn new( resource_id: ConceptId, from_id: ConceptId, to_id: ConceptId, quantity: Decimal, ) -> Self
Creates a new Flow using the default namespace.
Sourcepub fn new_with_namespace(
resource_id: ConceptId,
from_id: ConceptId,
to_id: ConceptId,
quantity: Decimal,
namespace: impl Into<String>,
) -> Self
pub fn new_with_namespace( resource_id: ConceptId, from_id: ConceptId, to_id: ConceptId, quantity: Decimal, namespace: impl Into<String>, ) -> Self
Creates a new Flow with namespace.
pub fn id(&self) -> &ConceptId
pub fn resource_id(&self) -> &ConceptId
pub fn from_id(&self) -> &ConceptId
pub fn to_id(&self) -> &ConceptId
pub fn quantity(&self) -> Decimal
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<'de> Deserialize<'de> for Flow
impl<'de> Deserialize<'de> for Flow
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 Flow
Auto Trait Implementations§
impl Freeze for Flow
impl RefUnwindSafe for Flow
impl Send for Flow
impl Sync for Flow
impl Unpin for Flow
impl UnwindSafe for Flow
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