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§
Required Methods§
Sourcefn process_message(&mut self, message: ResponseMessage) -> Option<Self::Output>
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§
Sourcefn on_message_received(&mut self, raw: Bytes, message: &ResponseMessage)
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.