#[non_exhaustive]pub struct Metadata {
pub correlation: CorrelationMetadata,
pub trace: TraceContext,
pub routing: RoutingMetadata,
pub delivery: DeliveryMetadata,
pub tenant_id: Option<String>,
}Expand description
Canonical, typed framework metadata: the single source of truth. No value here is ever
duplicated into Headers (ADR 0004).
use reliar_core::{CorrelationId, Envelope, Message};
#[derive(serde::Serialize, serde::Deserialize)]
struct OrderCreated;
impl Message for OrderCreated {
const TYPE: &'static str = "orders.created";
const VERSION: u16 = 1;
}
let envelope = Envelope::builder(OrderCreated)
.tenant("acme")
.correlation_id(CorrelationId::parse("checkout-42")?)
.build();
// `Metadata` is reachable directly — it is the one place these values live.
assert_eq!(envelope.metadata.tenant_id.as_deref(), Some("acme"));
assert!(envelope.metadata.correlation.correlation_id.is_some());
// An un-correlated message roots its own conversation.
assert_eq!(envelope.metadata.correlation.conversation_id.as_uuid(), envelope.id.as_uuid());Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.correlation: CorrelationMetadataCorrelation and conversation identity.
trace: TraceContextW3C Trace Context, carried verbatim.
routing: RoutingMetadataTransport-independent routing hints.
delivery: DeliveryMetadataSerialization and delivery hints.
tenant_id: Option<String>The owning tenant, if this deployment is multi-tenant.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Metadata
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Metadata
Available on crate feature
serde only.Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnsafeUnpin for Metadata
impl UnwindSafe for Metadata
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