Skip to main content

MessageInfo

Derive Macro MessageInfo 

Source
#[derive(MessageInfo)]
{
    // Attributes available to this derive:
    #[message]
}
Expand description

Derives MessageInfo metadata: the type name, its doc comment, and its header contract.

The optional #[message(headers(Meta))] attribute declares the type’s typed header contract (see MessageHeaders in the core crate): Meta is serialized into the header map on the typed publish path and lifted into the message’s AsyncAPI headers schema. Without the attribute the type declares no typed headers.

The derive describes a message the service receives, or replies with. A message the handler sends through an Out slot declares where it goes as well, so it derives Outgoing instead - only that derive makes the type a declared message set (see OutMessages in the core crate) the third Out argument can name.

ⓘ
/// An order placed by a customer.
#[derive(MessageInfo)]
struct Order { id: u32 }
// Order::NAME == "Order", Order::DESCRIPTION == Some("An order placed by a customer.")

#[derive(Message, Serialize)]
#[message(headers(ChunkMeta))]
struct ChunkDone { output_key: String }