Skip to main content

MessageBuilder

Struct MessageBuilder 

Source
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

Source

pub fn new() -> Self

Create an empty builder. Equivalent to MessageBuilder::default.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn build(self) -> Message

Finalize. Defaults: id = UUID v7, payload = OwnedDataValue::Null, capture_changes = true.

Trait Implementations§

Source§

impl Default for MessageBuilder

Source§

fn default() -> MessageBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.