Skip to main content

OutMessages

Derive Macro OutMessages 

Source
#[derive(OutMessages)]
Expand description

Derives a declared message set (OutMessages in the core crate) from an enum whose variants each wrap one message model. The enum is a type-level declaration: it is never constructed, its variants’ inner types are the set.

Naming the enum as the third Out argument (Out<impl Publisher, Marker, SendSet>) declares that the handler publishes exactly those models: the publish builder compiles for each of them (and for nothing else), and the generated AsyncAPI document lists them as the handler’s send operations. Each model declares where it goes with #[derive(Outgoing)].

Do not combine with #[derive(Outgoing)] on the same enum: a type is a message or a set, and the two derives produce conflicting impls.

ⓘ
#[derive(OutMessages)]
enum ConvertSends {
    Progress(Progress),
    Done(ChunkDone),
}

#[subscriber("chunks.raw")]
async fn convert(
    chunk: &Chunk,
    Out(out): Out<impl Publisher, Events, ConvertSends>,
) -> HandlerOutcome { /* out.message(&Progress { .. }).publish() */ }