Trait HandshakeImpl

Source
pub(super) trait HandshakeImpl: HasHandshakeState {
    // Required method
    fn handshake_impl(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>;

    // Provided method
    fn call_handshake_impl(
        &mut self,
        input: &[u8],
    ) -> (usize, Result<ImplNextStep>) { ... }
}
Available on crate features proxy-handshake or client-handshake only.
Expand description

Handshakes: SocksClientHandshake or SocksProxyHandshake

Required Methods§

Source

fn handshake_impl(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>

Actual implementation, to be provided

Does not need to handle setting the state to Failed on error. But does need to handle setting the state to Done if applicable.

May return the error from the Reader, in Error::Decode. (For example,. Error::Decode(tor_bytes::Error::Incomplete) if the message was incomplete and reading more data would help.)

Provided Methods§

Source

fn call_handshake_impl(&mut self, input: &[u8]) -> (usize, Result<ImplNextStep>)

Helper, used by public API implementations to call handshake_impl.

Deals with:

  • Setting up the Reader
  • Determining the amount drained.
  • Avoiding infinite loops (detect nothing drained, nothing replied)

Return value is (drain, Result<ImplNextStep>).

Implementors§

Source§

impl HandshakeImpl for SocksClientHandshake

Available on crate feature client-handshake only.
Source§

impl HandshakeImpl for SocksProxyHandshake

Available on crate feature proxy-handshake only.