Skip to main content

TypedMiddleware

Trait TypedMiddleware 

Source
pub trait TypedMiddleware<Role, Phase, Message, State> {
    type Error;

    // Required method
    async fn intercept_typed(
        &mut self,
        state: &mut State,
        message: Message,
    ) -> Result<Message, Self::Error>;
}
Expand description

Async middleware whose role, protocol phase, and legal message set are type indexed.

Message should be a phase-specific message type generated by pg_proto_fsm::protocol. Such values can only be obtained after a decoded wire message has been projected into a legal transition for Phase, so an implementation cannot return a replacement from another role or phase.

Required Associated Types§

Source

type Error

An error which prevents the message from continuing through the chain.

Required Methods§

Source

async fn intercept_typed( &mut self, state: &mut State, message: Message, ) -> Result<Message, Self::Error>

Observes, mutates, or replaces one phase-legal message and may await while borrowing both the handler and caller-defined state.

§Errors

Returns a policy-defined error to stop message processing.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

impl<Role, Phase, Message, State, Error, F> TypedMiddleware<Role, Phase, Message, State> for F
where F: for<'a> AsyncFnMut(&'a mut State, Message) -> Result<Message, Error>,

Source§

type Error = Error

Source§

impl<Role, Phase, Message, State, First, Second> TypedMiddleware<Role, Phase, Message, State> for Then<First, Second>
where First: TypedMiddleware<Role, Phase, Message, State>, Second: TypedMiddleware<Role, Phase, Message, State>,

Source§

type Error = ChainError<<First as TypedMiddleware<Role, Phase, Message, State>>::Error, <Second as TypedMiddleware<Role, Phase, Message, State>>::Error>

Source§

impl<Role, Phase, Message, State, Wire, Handler> TypedMiddleware<Role, Phase, Message, State> for WireAdapter<Wire, Handler>
where Message: Into<Wire> + TryFrom<Wire, Error = Wire>, Handler: MessageMiddleware<Wire, State>,

Source§

type Error = WireAdapterError<<Handler as MessageMiddleware<Wire, State>>::Error, Wire>

Source§

impl<Role, Phase, Message, State> TypedMiddleware<Role, Phase, Message, State> for Identity