Skip to main content

ForwardHandler

Trait ForwardHandler 

Source
pub(crate) trait ForwardHandler: ControlHandler {
    type BuildSpec: HasRelayIds;
    type CircChanMsg: TryFrom<AnyChanMsg, Error = Error>;
    type CircEvent;

    // Required methods
    async fn handle_meta_msg<R: Runtime>(
        &mut self,
        runtime: &R,
        early: bool,
        hopnum: Option<HopNum>,
        msg: UnparsedRelayMsg,
        relay_cell_format: RelayCellFormat,
    ) -> StdResult<(), ReactorError>;
    async fn handle_forward_cell<R: Runtime>(
        &mut self,
        hop_mgr: &mut HopMgr<R>,
        cell: Self::CircChanMsg,
    ) -> StdResult<Option<ForwardCellDisposition>, ReactorError>;
    fn handle_event(
        &mut self,
        event: Self::CircEvent,
    ) -> StdResult<Option<BackwardReactorCmd>, ReactorError>;
    async fn outbound_chan_ready(&mut self) -> Result<()>;
}
Expand description

Trait for customizing the behavior of the forward reactor.

Used for plugging in the implementation-dependent (client vs relay) parts of the implementation into the generic one.

Required Associated Types§

Source

type BuildSpec: HasRelayIds

Type that explains how to build an outgoing channel.

Source

type CircChanMsg: TryFrom<AnyChanMsg, Error = Error>

The subclass of ChanMsg that can arrive on this type of circuit.

Source

type CircEvent

An opaque event type.

The ForwardReactor polls an MPSC stream yielding CircEvents from the main loop. Each event is passed to Self::handle_event for handling.

Required Methods§

Source

async fn handle_meta_msg<R: Runtime>( &mut self, runtime: &R, early: bool, hopnum: Option<HopNum>, msg: UnparsedRelayMsg, relay_cell_format: RelayCellFormat, ) -> StdResult<(), ReactorError>

Handle a non-SENDME RELAY message on this circuit with stream ID 0.

Source

async fn handle_forward_cell<R: Runtime>( &mut self, hop_mgr: &mut HopMgr<R>, cell: Self::CircChanMsg, ) -> StdResult<Option<ForwardCellDisposition>, ReactorError>

Handle a forward (TODO terminology) cell.

The cell is

  • moving from the client towards the exit, if we’re a relay
  • moving from the guard towards us, if we’re a client

Returns an error if the cell should cause the reactor to shut down, or a ForwardCellDisposition specifying how it should be handled.

Returns None if the cell was handled internally by this handler.

Source

fn handle_event( &mut self, event: Self::CircEvent, ) -> StdResult<Option<BackwardReactorCmd>, ReactorError>

Handle an implementation-specific circuit event.

Returns a command for the backward reactor.

Source

async fn outbound_chan_ready(&mut self) -> Result<()>

Wait until the outbound channel, if there is one, is ready to accept more cells.

Resolves immediately if there is no outbound channel. Blocks if there is a pending outbound channel.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§