pub trait InboundInterceptor:
Send
+ Sync
+ 'static {
// Required method
fn name(&self) -> &'static str;
// Provided methods
fn on_receive(
&self,
ctx: &InboundContext<'_>,
runtime_headers: &RuntimeHeaders,
headers: &mut Headers,
message: &dyn Any,
) -> Disposition { ... }
fn on_complete(
&self,
ctx: &InboundContext<'_>,
runtime_headers: &RuntimeHeaders,
headers: &Headers,
outcome: &Outcome<'_>,
) { ... }
fn on_expand_item(
&self,
ctx: &InboundContext<'_>,
headers: &Headers,
seq: u64,
item: &dyn Any,
) -> Disposition { ... }
}Expand description
An interceptor that observes or modifies inbound messages. Interceptors form an ordered pipeline executed before the handler.
Required Methods§
Provided Methods§
Sourcefn on_receive(
&self,
ctx: &InboundContext<'_>,
runtime_headers: &RuntimeHeaders,
headers: &mut Headers,
message: &dyn Any,
) -> Disposition
fn on_receive( &self, ctx: &InboundContext<'_>, runtime_headers: &RuntimeHeaders, headers: &mut Headers, message: &dyn Any, ) -> Disposition
Called before the message is delivered to the handler.
The message body is provided as &dyn Any for optional downcasting.
Sourcefn on_complete(
&self,
ctx: &InboundContext<'_>,
runtime_headers: &RuntimeHeaders,
headers: &Headers,
outcome: &Outcome<'_>,
)
fn on_complete( &self, ctx: &InboundContext<'_>, runtime_headers: &RuntimeHeaders, headers: &Headers, outcome: &Outcome<'_>, )
Called after the handler finishes. Called exactly once per delivered message.
For ask, the Outcome::AskSuccess variant carries the type-erased reply.
Sourcefn on_expand_item(
&self,
ctx: &InboundContext<'_>,
headers: &Headers,
seq: u64,
item: &dyn Any,
) -> Disposition
fn on_expand_item( &self, ctx: &InboundContext<'_>, headers: &Headers, seq: u64, item: &dyn Any, ) -> Disposition
Called for each item in a stream or feed.
- Stream (server-streaming): called when the handler emits each
reply item via
StreamSender::send(). - Feed (client-streaming): called when each input item is
delivered to the actor via
StreamReceiver.
seq is a zero-based sequence number within this stream/feed.
The item is type-erased; downcast if you know the concrete type.
Returns Disposition to control per-item flow:
Continue— deliver/forward the item normally.Drop— silently skip this item.Delay(d)— pause fordbefore forwarding (backpressure).Reject(reason)— terminate the stream with an error.Retry(d)— not meaningful for stream items; treated asDrop.