Skip to main content

FlowCtrlHooks

Trait FlowCtrlHooks 

Source
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>>;
}
Expand description

Methods that can be called on a StreamFlowCtrl.

We use a trait so that we can use enum_dispatch on the inner StreamFlowCtrlEnum enum.

Required Methods§

Source

fn can_send<M: RelayMsg>(&self, msg: &M) -> bool

Whether this stream is ready to send msg.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

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§