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>) { ... }
}Expand description
Handshakes: SocksClientHandshake or SocksProxyHandshake
Required Methods§
Sourcefn handshake_impl(&mut self, r: &mut Reader<'_>) -> Result<ImplNextStep>
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§
Sourcefn call_handshake_impl(&mut self, input: &[u8]) -> (usize, Result<ImplNextStep>)
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>).