pub struct Message {
pub context: OwnedDataValue,
/* private fields */
}Expand description
A message flowing through the dataflow engine.
Construct via Message::builder for the full API, or use the shortcuts
Message::new (already-owned Arc<OwnedDataValue> payload — the perf
path) and Message::from_value (bridges from serde_json::Value).
context is held as an OwnedDataValue tree (not serde_json::Value)
so the JSONLogic evaluator can borrow it into its arena via
OwnedDataValue::to_arena with a single deep walk in, and project the
result back via DataValue::to_owned with a single deep walk out — no
serde_json::Value round-trip in the hot path. The on-the-wire JSON
shape is preserved by datavalue’s native Serialize / Deserialize
impls.
Every other field is encapsulated — read via id(), payload(),
audit_trail(), errors(), capture_changes(); mutate errors via
Message::add_error; mutate context via crate::TaskContext::set.
Direct mutation of audit_trail is engine-internal.
Fields§
§context: OwnedDataValueUnified context containing data, metadata, and temp_data keys.
Always an OwnedDataValue::Object; the engine populates the three
top-level keys at construction. Public for read access (tests do
message.context["data"]["x"] lookups); inside handlers prefer
crate::TaskContext::set which records audit-trail changes.
Implementations§
Source§impl Message
impl Message
Sourcepub fn builder() -> MessageBuilder
pub fn builder() -> MessageBuilder
Start building a message. The recommended constructor — chains
.id(...), .payload(...) / .payload_json(...), and
.capture_changes(...) calls, then .build().
Sourcepub fn new(payload: Arc<OwnedDataValue>) -> Self
pub fn new(payload: Arc<OwnedDataValue>) -> Self
Construct a message from an already-owned payload Arc. The perf
path: zero serde_json::Value walk, one Arc refcount bump per
message. Use this from a hot loop with a payload Arc shared across
messages (e.g. a benchmark harness or an HTTP handler that receives
already-parsed payloads).
Sourcepub fn from_value(payload: &JsonValue) -> Self
pub fn from_value(payload: &JsonValue) -> Self
Construct a message from a serde_json::Value payload. Convenience
for code that already speaks serde_json; goes through the
OwnedDataValue::from(&Value) bridge (one deep walk).
Sourcepub fn from_json_str(payload: &str) -> Result<Self>
pub fn from_json_str(payload: &str) -> Result<Self>
Construct a message from a JSON payload string. Parses with
serde_json and bridges into OwnedDataValue. Returns
DataflowError::Deserialization on parse failure.
Sourcepub fn has_errors(&self) -> bool
pub fn has_errors(&self) -> bool
Check if message has errors
Sourcepub fn id(&self) -> &str
pub fn id(&self) -> &str
Message id (UUID v7 string by default; caller-supplied if set via
MessageBuilder::id).
Sourcepub fn payload(&self) -> &OwnedDataValue
pub fn payload(&self) -> &OwnedDataValue
Original payload as the engine received it. Immutable for the
lifetime of the message — the engine reads it through this Arc and
copies into context only as needed by handlers.
Sourcepub fn payload_arc(&self) -> &Arc<OwnedDataValue>
pub fn payload_arc(&self) -> &Arc<OwnedDataValue>
The shared payload Arc itself. Useful when forwarding the same
payload to multiple messages without recloning the underlying
OwnedDataValue tree.
Sourcepub fn audit_trail(&self) -> &[AuditTrail]
pub fn audit_trail(&self) -> &[AuditTrail]
Audit-trail entries recorded by the engine, one per task that ran
(skipped tasks are absent unless Trace mode is on).
Sourcepub fn errors(&self) -> &[ErrorInfo]
pub fn errors(&self) -> &[ErrorInfo]
Errors collected while processing — both validation failures and
task errors that the workflow swallowed via continue_on_error.
Sourcepub fn capture_changes(&self) -> bool
pub fn capture_changes(&self) -> bool
Whether per-write Change capture is on. When false, audit-trail
entries are still emitted but their changes lists are empty —
the bulk-pipeline fast path.
Sourcepub fn data(&self) -> &OwnedDataValue
pub fn data(&self) -> &OwnedDataValue
Get a reference to the data field in context. Returns
&OwnedDataValue::Null if missing (matches serde_json::Value’s
Index fallback semantics).
Sourcepub fn metadata(&self) -> &OwnedDataValue
pub fn metadata(&self) -> &OwnedDataValue
Get a reference to the metadata field in context.
Sourcepub fn temp_data(&self) -> &OwnedDataValue
pub fn temp_data(&self) -> &OwnedDataValue
Get a reference to the temp_data field in context.