Skip to main content

Outgoing

A message type names its header contract, so publishing it does not compile without the headers.

#[outgoing(headers = Meta)] makes the contract part of the message type, the type's MessageHeaders contract. Its publish does not compile without .with_headers(&meta). The manual form implements MessageHeaders by hand and names the contract as its Contract; a type with none names NoHeaders. An Out slot lists the types it may publish in #[publishes(..)], and each keeps its own contract, as on the Slots page. The handler on the Headers page publishes a ChunkDone through such a slot.

Example​

/// A chunk: publishing one does not compile without its `ChunkMeta`.
#[derive(Debug, PartialEq, Serialize, Deserialize, Outgoing)]
#[outgoing(name = "chunks", headers = ChunkMeta)]
struct Chunk {
size: u64,
}

/// A finished chunk: publishing one does not compile without its `DoneMeta`.
#[derive(Debug, PartialEq, Serialize, Deserialize, Outgoing)]
#[outgoing(name = "chunks.done", headers = DoneMeta)]
struct ChunkDone {
output_key: String,
}
/// The slot the converter publishes through, and what it may publish.
#[derive(OutSlot)]
#[publishes(ChunkDone)]
struct Events;