Skip to main content

PublishTransform

Trait PublishTransform 

Source
pub trait PublishTransform<C = ()>: Send + Sync {
    // Required method
    fn apply(&self, out: &mut Outgoing<'_>, cx: &PublishContext<'_, C>);
}
Expand description

A static, compile-time publish transform: mutates an Outgoing before it is sent, with read access to the originating delivery through PublishContext.

The publish-side counterpart to the consume-side Layer: zero-cost composition, no dyn dispatch. Baked onto a TypedPublisher with TypedPublisher::transform. Use for per-destination transforms that belong to the publisher itself - a Confluent / Avro envelope, a fixed content-type header, or stamping the delivery’s trace / correlation id onto the reply (read it from cx). The C parameter is the originating handler’s context type; a transform that ignores the context is generic over it (mounts on any handler). For cross-cutting observation across every publish (metrics), use the app-wide PublishLayer via RustStream::publish_layer instead; the per-publisher transforms run first (closest to the value), then the app-wide publish pipeline, then the send.

Required Methods§

Source

fn apply(&self, out: &mut Outgoing<'_>, cx: &PublishContext<'_, C>)

Transforms out in place before it is sent, reading the delivery through cx.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§