Skip to main content

MessageProcessor

Trait MessageProcessor 

Source
pub trait MessageProcessor:
    Send
    + Sync
    + 'static {
    type Output: Send + Clone + Sync + 'static + Debug;

    // Required method
    fn process_message(
        &mut self,
        message: ResponseMessage,
    ) -> Option<Self::Output>;

    // Provided method
    fn on_message_received(&mut self, raw: Bytes, message: &ResponseMessage) { ... }
}
Expand description

Trait for processing incoming Betfair streaming ResponseMessage objects into user-defined outputs.

Implementers can filter or transform messages and control which messages are forwarded to the client sink.

Required Associated Types§

Source

type Output: Send + Clone + Sync + 'static + Debug

The processed message type produced by process_message

Required Methods§

Source

fn process_message(&mut self, message: ResponseMessage) -> Option<Self::Output>

Process an incoming ResponseMessage.

Returns Some(Output) to forward a processed message, or None to drop it.

Provided Methods§

Source

fn on_message_received(&mut self, raw: Bytes, message: &ResponseMessage)

Called with the raw JSON bytes and a reference to the parsed message before Self::process_message.

Override this to inspect, log, or forward the original JSON from Betfair before the parsed message is consumed by the processor.

raw is a reference-counted bytes::Bytes buffer — cloning it is O(1) and avoids copying the underlying data, making it cheap to store or forward.

The default implementation is a no-op.

Implementors§