pub struct ObjectInstance {
pub object_id: Uuid,
pub object_type_id: String,
pub external_id: String,
pub current_state: String,
pub created_at: DateTime<Utc>,
pub completed_at: Option<DateTime<Utc>>,
pub company_code: String,
pub attributes: HashMap<String, ObjectAttributeValue>,
pub is_anomaly: bool,
pub anomaly_type: Option<String>,
}Expand description
A business object instance in OCPM.
Fields§
§object_id: UuidUnique object identifier
object_type_id: StringObject type reference
external_id: StringExternal ID (e.g., “PO-1000-0000000001”)
current_state: StringCurrent lifecycle state
created_at: DateTime<Utc>Creation timestamp
completed_at: Option<DateTime<Utc>>Completion timestamp (if terminal state reached)
company_code: StringCompany code
attributes: HashMap<String, ObjectAttributeValue>Object attributes
is_anomaly: boolIs this object marked as anomalous
anomaly_type: Option<String>Anomaly type if applicable
Implementations§
Source§impl ObjectInstance
impl ObjectInstance
Sourcepub fn new(object_type_id: &str, external_id: &str, company_code: &str) -> Self
pub fn new(object_type_id: &str, external_id: &str, company_code: &str) -> Self
Create a new object instance.
Sourcepub fn with_id(self, id: Uuid) -> Self
pub fn with_id(self, id: Uuid) -> Self
Create with a specific UUID (for deterministic generation).
Sourcepub fn with_state(self, state: &str) -> Self
pub fn with_state(self, state: &str) -> Self
Set the initial state.
Sourcepub fn with_created_at(self, created_at: DateTime<Utc>) -> Self
pub fn with_created_at(self, created_at: DateTime<Utc>) -> Self
Set creation timestamp.
Sourcepub fn with_attribute(self, key: &str, value: ObjectAttributeValue) -> Self
pub fn with_attribute(self, key: &str, value: ObjectAttributeValue) -> Self
Add an attribute.
Sourcepub fn transition(&mut self, new_state: &str)
pub fn transition(&mut self, new_state: &str)
Transition to a new state.
Sourcepub fn mark_anomaly(&mut self, anomaly_type: &str)
pub fn mark_anomaly(&mut self, anomaly_type: &str)
Mark as anomalous.
Sourcepub fn is_completed(&self) -> bool
pub fn is_completed(&self) -> bool
Check if the object is in a terminal state.
Sourcepub fn get_string(&self, key: &str) -> Option<&str>
pub fn get_string(&self, key: &str) -> Option<&str>
Get a string attribute value.
Sourcepub fn get_decimal(&self, key: &str) -> Option<Decimal>
pub fn get_decimal(&self, key: &str) -> Option<Decimal>
Get a decimal attribute value.
Trait Implementations§
Source§impl Clone for ObjectInstance
impl Clone for ObjectInstance
Source§fn clone(&self) -> ObjectInstance
fn clone(&self) -> ObjectInstance
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 ObjectInstance
impl Debug for ObjectInstance
Source§impl<'de> Deserialize<'de> for ObjectInstance
impl<'de> Deserialize<'de> for ObjectInstance
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 ObjectInstance
impl RefUnwindSafe for ObjectInstance
impl Send for ObjectInstance
impl Sync for ObjectInstance
impl Unpin for ObjectInstance
impl UnwindSafe for ObjectInstance
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