pub trait MsgHandler {
    // Required method
    fn handle_msg(
        &mut self,
        conversation: ConversationInHandler<'_, '_, '_>,
        msg: AnyRelayMsg
    ) -> Result<MetaCellDisposition>;
}
Available on crate feature send-control-msg only.
Expand description

An object that checks whether incoming control messages are acceptable on a circuit, and delivers them to a client if so.

The handler is supplied to ClientCirc::start_conversation. It is used to check any incoming message whose stream ID is 0, and which would otherwise not be accepted on a given circuit.

(The messages that tor-proto will handle on its own, and not deliver, are are DESTROY, DATA, SENDME, …) Ordinarily, any unexpected control message will cause the circuit to exit with an error.

Required Methods§

source

fn handle_msg( &mut self, conversation: ConversationInHandler<'_, '_, '_>, msg: AnyRelayMsg ) -> Result<MetaCellDisposition>

Check whether this message is an acceptable one to receive in reply to our command, and handle it if so.

Typically, this handler should perform only simple checks, before delivering the message to another task via some kind of channel if further processing is needed.

In particular, if the circuit might be in use for anything else (eg there might be concurrent data flow) the implementor should avoid any expensive computations or highly contended locks, to avoid blocking the circuit reactor.

If this function returns an error, the circuit will be closed.

Implementors§