pub struct MessageBuilder { /* private fields */ }Expand description
Builder for Message. Collapses the historical
new / with_id / from_value / without_change_capture four-way
constructor split into a single fluent shape.
use dataflow_rs::Message;
use serde_json::json;
// Minimal: serde_json payload, default UUID id, capture on.
let m = Message::builder()
.payload_json(&json!({"order": {"total": 1500}}))
.build();
assert!(m.id().len() > 0);
assert!(m.capture_changes());Implementations§
Source§impl MessageBuilder
impl MessageBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an empty builder. Equivalent to MessageBuilder::default.
Sourcepub fn id(self, id: impl Into<String>) -> Self
pub fn id(self, id: impl Into<String>) -> Self
Caller-supplied id (typically a correlation id from upstream). Defaults to a freshly-generated UUID v7.
Sourcepub fn payload(self, payload: Arc<OwnedDataValue>) -> Self
pub fn payload(self, payload: Arc<OwnedDataValue>) -> Self
Already-owned payload Arc — zero serde_json walk, refcount-only
share. Mutually exclusive with Self::payload_json; whichever is
called last wins.
Sourcepub fn payload_json(self, payload: &JsonValue) -> Self
pub fn payload_json(self, payload: &JsonValue) -> Self
Construct the payload from a serde_json::Value. Goes through the
OwnedDataValue::from(&Value) bridge (one deep walk).
Sourcepub fn capture_changes(self, on: bool) -> Self
pub fn capture_changes(self, on: bool) -> Self
When false, built-in functions skip per-write Change capture —
audit-trail entries are still recorded but their changes list is
empty. Defaults to true.
Trait Implementations§
Source§impl Default for MessageBuilder
impl Default for MessageBuilder
Source§fn default() -> MessageBuilder
fn default() -> MessageBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MessageBuilder
impl RefUnwindSafe for MessageBuilder
impl Send for MessageBuilder
impl Sync for MessageBuilder
impl Unpin for MessageBuilder
impl UnsafeUnpin for MessageBuilder
impl UnwindSafe for MessageBuilder
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