Struct tokio_resol_vbus::TcpClientHandshake
source · pub struct TcpClientHandshake { /* private fields */ }
Expand description
Handles the client-side of the VBus-over-TCP handshake.
Examples
This example connects to a RESOL DL2 at “192.168.5.81”, provides the
password for authorization and then send the DATA command. After that
the socket transmits raw VBus data and can be used with e.g.
LiveDataStream
.
use tokio::prelude::*;
use tokio::net::TcpStream;
use tokio_resol_vbus::{Error, TcpClientHandshake};
let addr = "192.168.5.81:7053".parse().expect("Unable to parse address");
let handler = TcpStream::connect(&addr)
.map_err(Error::new)
.and_then(TcpClientHandshake::start)
.and_then(|hs| hs.send_pass_command("vbus"))
.and_then(|hs| hs.send_data_command())
.and_then(|socket| {
// use the socket
})
.map_err(|err| eprintln!("{}", err));
tokio::run(handler);
Implementations§
source§impl TcpClientHandshake
impl TcpClientHandshake
sourcepub fn start(socket: TcpStream) -> impl Future<Item = Self, Error = Error>
pub fn start(socket: TcpStream) -> impl Future<Item = Self, Error = Error>
Start the VBus-over-TCP handshake as the client side connecting to a server.
sourcepub fn into_inner(self) -> TcpStream
pub fn into_inner(self) -> TcpStream
Consume self
and return the underlying TcpStream
.
sourcepub fn send_connect_command(
self,
via_tag: &str
) -> impl Future<Item = Self, Error = Error>
pub fn send_connect_command(
self,
via_tag: &str
) -> impl Future<Item = Self, Error = Error>
Send the CONNECT <via_tag>
command to the server and wait for a positive reply.
sourcepub fn send_pass_command(
self,
password: &str
) -> impl Future<Item = Self, Error = Error>
pub fn send_pass_command(
self,
password: &str
) -> impl Future<Item = Self, Error = Error>
Send the PASS <password>
command to the server and wait for a positive reply.
sourcepub fn send_channel_command(
self,
channel: u8
) -> impl Future<Item = Self, Error = Error>
pub fn send_channel_command(
self,
channel: u8
) -> impl Future<Item = Self, Error = Error>
Send the CHANNEL <channel>
command to the server and wait for a positive reply.
sourcepub fn send_data_command(self) -> impl Future<Item = TcpStream, Error = Error>
pub fn send_data_command(self) -> impl Future<Item = TcpStream, Error = Error>
Send the DATA
command to the server and wait for a positive reply.
sourcepub fn send_quit_command(self) -> impl Future<Item = (), Error = Error>
pub fn send_quit_command(self) -> impl Future<Item = (), Error = Error>
Send the QUIT
command to the server and wait for a positive reply.