[][src]Struct tokio_resol_vbus::TcpServerHandshake

pub struct TcpServerHandshake { /* fields omitted */ }

Handles the server-side of the VBus-over-TCP handshake.


This example simulates a RESOL DL2 by accepting TCP connections on port 7053, requiring the client to provide a password and then switch the connection into raw VBus data mode.

use tokio::prelude::*;
use tokio::net::TcpListener;
use tokio_resol_vbus::TcpServerHandshake;

let addr = "".parse().expect("Unable to parse address");
let listener = TcpListener::bind(&addr).expect("Unable to bind listener");

let server = listener
    .map_err(|err| eprintln!("{}", err))
    .for_each(|socket| {
        let conn = TcpServerHandshake::start(socket)
            .and_then(|hs| hs.receive_pass_command_and_verify_password(|password| {
                if password == "vbus" {
                } else {
            .and_then(|(hs, _)| hs.receive_data_command())
            .and_then(|socket| {
                // do something with the socket
            .map_err(|err| eprintln!("Server error: {}", err));



impl TcpServerHandshake

Start the VBus-over-TCP handshake as the client side connecting to a server.

Consume self and return the underlying TcpStream.

Receive a command and verify it and its provided arguments. The command reception is repeated as long as the verification fails.

The preferred way to receive commands documented in the VBus-over-TCP specification is through the receive_xxx_command and receive_xxx_command_and_verify_yyy methods which use the receive_command method internally.

This method takes a validator function that is called with the received command and its optional arguments. The validator returns a Future that can resolve into an std::result::Result<T, &'static str>. It can either be:

  • Ok(value) if the validation succeeded. The value is used to resolve the receive_command Future.
  • Err(reply) if the validation failed. The reply is send back to the client and the command reception is repeated.

Wait for a CONNECT <via_tag> command. The via tag argument is returned.

Wait for a CONNECT <via_tag> command.

Wait for a PASS <password> command.

Wait for a PASS <password> command and validate the provided password.

Wait for a CHANNEL <channel> command.

Wait for CHANNEL <channel> command and validate the provided channel

Wait for a DATA command.

Trait Implementations

impl Debug for TcpServerHandshake

Auto Trait Implementations

Blanket Implementations

impl<T> From for T

impl<T, U> Into for T where
    U: From<T>, 

impl<T, U> TryFrom for T where
    T: From<U>, 

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized

impl<T> BorrowMut for T where
    T: ?Sized

impl<T, U> TryInto for T where
    U: TryFrom<T>, 

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized

impl<T> Erased for T