Skip to main content

Handshake

Trait Handshake 

Source
pub trait Handshake {
    type Output;
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn framing(&self) -> Framing;
    fn receive(&mut self, input: &[u8]) -> Result<(), Self::Error>;
    fn transmit(&mut self) -> Result<Option<Vec<u8>>, Self::Error>;
    fn is_complete(&self) -> bool;
    fn finish(self) -> Result<Established<Self::Output>, Self::Error>;
}
Expand description

One authentication exchange, driven by the caller.

Required Associated Types§

Source

type Output

What a completed handshake yields besides the peer.

Source

type Error: Error + Send + Sync + 'static

Why the handshake failed. Never holds key material.

Required Methods§

Source

fn framing(&self) -> Framing

How this method divides what it sends.

Source

fn receive(&mut self, input: &[u8]) -> Result<(), Self::Error>

Gives the handshake what arrived from the peer: a chunk of the stream, or one message (see Framing).

§Errors

When the input is invalid or the peer is refused. The handshake is over after an error.

Source

fn transmit(&mut self) -> Result<Option<Vec<u8>>, Self::Error>

The next thing to send to the peer, or None when there is nothing to send until more input arrives. Call until None.

§Errors

When the handshake cannot continue.

Source

fn is_complete(&self) -> bool

Whether the exchange is over and finish can be called; it succeeds when the method verified a peer. Output still waiting in transmit must be sent first.

Source

fn finish(self) -> Result<Established<Self::Output>, Self::Error>

The verified peer and the method’s output.

§Errors

When the handshake is not complete.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§