pub(crate) trait FlowCtrlHooks {
// Required methods
fn can_send<M: RelayMsg>(&self, msg: &M) -> bool;
fn about_to_send(&mut self, msg: &AnyRelayMsg) -> Result<()>;
fn put_for_incoming_sendme(&mut self, msg: UnparsedRelayMsg) -> Result<()>;
fn handle_incoming_xon(&mut self, msg: UnparsedRelayMsg) -> Result<()>;
fn handle_incoming_xoff(&mut self, msg: UnparsedRelayMsg) -> Result<()>;
fn maybe_send_xon(
&mut self,
rate: XonKbpsEwma,
buffer_len: usize,
) -> Result<Option<Xon>>;
fn maybe_send_xoff(&mut self, buffer_len: usize) -> Result<Option<Xoff>>;
fn inbound_queue_max_len(&self) -> usize;
}Expand description
Methods that can be called on a StreamFlowCtrl.
We use a trait so that we can use enum_dispatch on the inner StreamFlowCtrlInner enum.
Required Methods§
Sourcefn about_to_send(&mut self, msg: &AnyRelayMsg) -> Result<()>
fn about_to_send(&mut self, msg: &AnyRelayMsg) -> Result<()>
Inform the flow control code that we’re about to send msg.
Returns an error if the message should not be sent,
and the circuit should be closed.
Sourcefn put_for_incoming_sendme(&mut self, msg: UnparsedRelayMsg) -> Result<()>
fn put_for_incoming_sendme(&mut self, msg: UnparsedRelayMsg) -> Result<()>
Handle an incoming sendme.
On success, return the number of cells left in the window.
On failure, return an error: the caller should close the stream or circuit with a protocol error.
Takes the UnparsedRelayMsg so that we don’t even try to decode it if we’re not using the
correct type of flow control.
Sourcefn handle_incoming_xon(&mut self, msg: UnparsedRelayMsg) -> Result<()>
fn handle_incoming_xon(&mut self, msg: UnparsedRelayMsg) -> Result<()>
Handle an incoming XON message.
Takes the UnparsedRelayMsg so that we don’t even try to decode it if we’re not using the
correct type of flow control.
Sourcefn handle_incoming_xoff(&mut self, msg: UnparsedRelayMsg) -> Result<()>
fn handle_incoming_xoff(&mut self, msg: UnparsedRelayMsg) -> Result<()>
Handle an incoming XOFF message.
Takes the UnparsedRelayMsg so that we don’t even try to decode it if we’re not using the
correct type of flow control.
Sourcefn maybe_send_xon(
&mut self,
rate: XonKbpsEwma,
buffer_len: usize,
) -> Result<Option<Xon>>
fn maybe_send_xon( &mut self, rate: XonKbpsEwma, buffer_len: usize, ) -> Result<Option<Xon>>
Check if we should send an XON message.
If we should, then returns the XON message that should be sent. Returns an error if XON/XOFF messages aren’t supported for this type of flow control.
Sourcefn maybe_send_xoff(&mut self, buffer_len: usize) -> Result<Option<Xoff>>
fn maybe_send_xoff(&mut self, buffer_len: usize) -> Result<Option<Xoff>>
Check if we should send an XOFF message.
If we should, then returns the XOFF message that should be sent. Returns an error if XON/XOFF messages aren’t supported for this type of flow control.
Sourcefn inbound_queue_max_len(&self) -> usize
fn inbound_queue_max_len(&self) -> usize
The max queue length that should be used for stream messages incoming from the Tor network.
This is the queue length between the user-facing stream reader (DataReader)
and the circuit reactor.
If the queue would ever exceed this many messages, the stream should be closed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".