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
impl Message
Sourcepub fn new(name: impl Into<String>, kind: MessageKind, payload: Vec<u8>) -> Self
pub fn new(name: impl Into<String>, kind: MessageKind, payload: Vec<u8>) -> Self
Create a transport message.
Sourcepub fn with_metadata(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Add metadata.
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Get the message name.
The name flows unmodified into broker routing primitives (NATS subject
suffix, Kafka topic, RabbitMQ routing/binding key). A . is a routing
segment separator on topic transports, so it changes routing
granularity rather than being an opaque label — see
validate_message_name.
Sourcepub fn validate_name(&self) -> Result<(), MessageNameError>
pub fn validate_name(&self) -> Result<(), MessageNameError>
Validate this message’s name for use as a transport routing identifier.
Delegates to validate_message_name:
rejects empty, over-long, control-character-bearing, or wildcard-bearing
(*/#/>) names. Publish boundaries call this before a name becomes a
subject/topic/routing key; the inbound Knative ingress calls it on the
ce-type it reads off the wire.
Sourcepub fn correlation_id(&self) -> Option<&str>
pub fn correlation_id(&self) -> Option<&str>
Get the correlation id, if present.
Sourcepub fn causation_id(&self) -> Option<&str>
pub fn causation_id(&self) -> Option<&str>
Get the causation id, if present.
Sourcepub fn payload_json<T: DeserializeOwned>(&self) -> Result<T, PayloadDecodeError>
pub fn payload_json<T: DeserializeOwned>(&self) -> Result<T, PayloadDecodeError>
Decode the raw payload as JSON.
Sourcepub fn payload_bitcode<T: DeserializeOwned>(
&self,
) -> Result<T, PayloadDecodeError>
pub fn payload_bitcode<T: DeserializeOwned>( &self, ) -> Result<T, PayloadDecodeError>
Decode the raw payload as bitcode.
Security caveat: bitcode is a compact binary format that is not hardened
against hostile input. Only decode bitcode from trusted producers — do
not use it for payloads arriving on a public bus or other untrusted
ingress, where a malformed/adversarial buffer could trigger excessive
allocation or a panic. Prefer payload_json for
untrusted input.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<&OutboxMessage> for Message
impl From<&OutboxMessage> for Message
Source§fn from(outbox: &OutboxMessage) -> Self
fn from(outbox: &OutboxMessage) -> Self
Map a durable outbox row to a canonical transport message.
id← outbox message id (the stable durable id);name←event_type;kind←Commandwhen a point-to-pointdestinationis set, elseEvent;payload← raw codec bytes,content_type=application/octet-stream;metadata← the outbox metadata (correlation/causation/trace/auth) plus framework-derived keys under the reservedSOURCED_METADATA_PREFIXnamespace (payload codec, destination, source-aggregate context) so decode/routing context can never be shadowed by a user metadata key.
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> AggregateBuilder for T
impl<T> AggregateBuilder for T
fn aggregate<A: Aggregate>(self) -> AggregateRepository<Self, A>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Queueable for T
impl<T> Queueable for T
Source§fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
fn queued(self) -> QueuedRepository<Self, InMemoryLockManager>
.aggregate::<T>() for per-aggregate serialization over the async
repository surface.