Skip to main content

Message

Struct Message 

Source
pub struct Message {
    pub id: Option<String>,
    pub name: String,
    pub kind: MessageKind,
    pub payload: Vec<u8>,
    pub content_type: String,
    pub metadata: Vec<(String, String)>,
}
Expand description

Serializable transport message used by handlers.

Fields§

§id: Option<String>§name: String§kind: MessageKind§payload: Vec<u8>§content_type: String§metadata: Vec<(String, String)>

Implementations§

Source§

impl Message

Source

pub fn new(name: impl Into<String>, kind: MessageKind, payload: Vec<u8>) -> Self

Create a transport message.

Source

pub fn with_id(self, id: impl Into<String>) -> Self

Add a durable message id.

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add metadata.

Source

pub fn id(&self) -> Option<&str>

Get the durable message id, if this message has one.

Source

pub fn name(&self) -> &str

Get the message name.

Source

pub fn payload(&self) -> &[u8]

Get the raw payload bytes.

Source

pub fn metadata(&self, key: &str) -> Option<&str>

Get a metadata value by key.

Source

pub fn correlation_id(&self) -> Option<&str>

Get the correlation id, if present.

Source

pub fn causation_id(&self) -> Option<&str>

Get the causation id, if present.

Source

pub fn payload_json<T: DeserializeOwned>(&self) -> Result<T, PayloadDecodeError>

Decode the raw payload as JSON.

Source

pub fn payload_bitcode<T: DeserializeOwned>( &self, ) -> Result<T, PayloadDecodeError>

Decode the raw payload as bitcode.

Trait Implementations§

Source§

impl Clone for Message

Source§

fn clone(&self) -> Message

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Message

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Message

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<&OutboxMessage> for Message

Source§

fn from(outbox: &OutboxMessage) -> Self

Map a durable outbox row to a canonical transport message.

  • id ← outbox message id (the stable durable id);
  • nameevent_type;
  • kindCommand when a point-to-point destination is set, else Event;
  • payload ← raw codec bytes, content_type = application/octet-stream;
  • metadata ← the outbox metadata (correlation/causation/trace/auth) plus framework-derived keys under the reserved SOURCED_METADATA_PREFIX namespace (payload codec, destination, source-aggregate context) so decode/routing context can never be shadowed by a user metadata key.
Source§

impl Serialize for Message

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> AggregateBuilder for T

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Queueable for T

Source§

fn queued(self) -> QueuedRepository<Self, InMemoryAsyncLockManager>

Wrap with the default async lock manager. Pair with .aggregate::<T>() for per-aggregate serialization over the async repository surface.
Source§

fn queued_with<L: AsyncLockManager>( self, lock_manager: L, ) -> QueuedRepository<Self, L>

Wrap with a custom async lock manager.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.