pub trait MessageHeaders {
type Contract: HeadersContract;
}Expand description
Declares a message type’s typed header contract.
#[derive(Outgoing)] implements it: #[outgoing(headers = Meta)] on the type sets the
contract to WithHeaders<Meta>, and a declaration without it sets NoHeaders
(#[derive(MessageInfo)] with #[message(headers(Meta))] does the same for a type that
declares no destination). The contract types both message documentation (the AsyncAPI
headers schema of the message) and the publish builder: publish() compiles only with the
headers the contract declares (none for NoHeaders).
The two contract shapes are a closed vocabulary: HeadersContract is sealed.
§Examples
use ruststream::prelude::*;
struct ChunkMeta {
task_id: u64,
}
struct ChunkDone;
// What `#[derive(Outgoing)]` + `#[outgoing(headers = ChunkMeta)]` generates:
impl MessageHeaders for ChunkDone {
type Contract = WithHeaders<ChunkMeta>;
}Required Associated Types§
Sourcetype Contract: HeadersContract
type Contract: HeadersContract
The contract shape: NoHeaders, or WithHeaders<H> with the typed
header struct H.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".