Trait MetaCellHandler

Source
pub(crate) trait MetaCellHandler: Send {
    // Required methods
    fn expected_hop(&self) -> HopNum;
    fn handle_msg(
        &mut self,
        msg: UnparsedRelayMsg,
        reactor: &mut Circuit,
    ) -> Result<MetaCellDisposition>;
}
Expand description

An object that’s waiting for a meta cell (one not associated with a stream) in order to make progress.

§Background

The Reactor can’t have async functions that send and receive cells, because its job is to send and receive cells: if one of its functions tried to do that, it would just hang forever.

To get around this problem, the reactor can send some cells, and then make one of these MetaCellHandler objects, which will be run when the reply arrives.

Required Methods§

Source

fn expected_hop(&self) -> HopNum

The hop we’re expecting the message to come from. This is compared against the hop from which we actually receive messages, and an error is thrown if the two don’t match.

Source

fn handle_msg( &mut self, msg: UnparsedRelayMsg, reactor: &mut Circuit, ) -> Result<MetaCellDisposition>

Called when the message we were waiting for arrives.

Gets a copy of the Reactor in order to do anything it likes there.

If this function returns an error, the reactor will shut down.

Implementors§

Source§

impl<H, L, FWD, REV> MetaCellHandler for CircuitExtender<H, L, FWD, REV>

Source§

impl<T: MsgHandler + Send> MetaCellHandler for UserMsgHandler<T>

Available on crate feature send-control-msg only.