pub struct StagingLog { /* private fields */ }Expand description
The loose intermediate representation: order-free ingestion, dangling references allowed, schema grows as observed.
Implementations§
Source§impl StagingLog
impl StagingLog
pub fn new() -> Self
Sourcepub fn from_ocel(ocel: Ocel) -> Self
pub fn from_ocel(ocel: Ocel) -> Self
Re-stage an existing log so further data can merge into it (the basis for incremental sync). Schemas are seeded from the declarations, so attribute types survive the round trip.
Once a log has passed the gate, from_ocel(log).into_ocel()
reproduces it unchanged.
Sourcepub fn add_event(&mut self, event: StagingEvent)
pub fn add_event(&mut self, event: StagingEvent)
Add an event (any order; its object references may not exist yet).
Sourcepub fn upsert_object(&mut self, id: &str, object_type: &str)
pub fn upsert_object(&mut self, id: &str, object_type: &str)
Ensure an object exists with the given type. Repeated calls merge; a later non-empty type fills in a placeholder created by references.
Sourcepub fn add_object_attribute(
&mut self,
id: &str,
name: &str,
value: AttrValue,
time: DateTime<Utc>,
)
pub fn add_object_attribute( &mut self, id: &str, name: &str, value: AttrValue, time: DateTime<Utc>, )
Record a dynamic attribute observation for an object (created as a placeholder if unseen).
Sourcepub fn add_o2o(&mut self, source_id: &str, target_id: &str, qualifier: &str)
pub fn add_o2o(&mut self, source_id: &str, target_id: &str, qualifier: &str)
Record an O2O relation (either endpoint may not exist yet).
Sourcepub fn map_object_ids(&mut self, f: impl Fn(&str) -> String)
pub fn map_object_ids(&mut self, f: impl Fn(&str) -> String)
Re-key every object id; E2O and O2O references follow. Old ids
mapping to the same new id merge: attribute observations and
relations append, the first non-empty object type wins. Identity
resolution is applying an alias table; anonymization is applying a
hash — both are instances of this.
Sourcepub fn map_events(&mut self, f: impl FnMut(&mut StagingEvent))
pub fn map_events(&mut self, f: impl FnMut(&mut StagingEvent))
Rewrite every event in place (rename types, edit attributes, re-point relations). The event schema is rebuilt from the mapped events, so a renamed type replaces its old entry instead of leaving it behind.
Sourcepub fn retain_events(&mut self, pred: impl FnMut(&StagingEvent) -> bool)
pub fn retain_events(&mut self, pred: impl FnMut(&StagingEvent) -> bool)
Keep only events matching the predicate. The event schema is rebuilt, so a type whose last event is dropped disappears from the log.
Sourcepub fn into_ocel(self) -> Result<Ocel, Vec<Violation>>
pub fn into_ocel(self) -> Result<Ocel, Vec<Violation>>
The validation gate: convert into a spec-conformant Ocel.
Late attribute observations are re-checked against the final schema
(values whose type degraded to string are stringified), then everything
is delegated to ocel::OcelBuilder — dangling references, duplicate
ids, and placeholder objects that never received a type surface as
Violations.
§Errors
Returns every Violation found when the staged data does not form a
valid OCEL 2.0 log.