async_resol_vbus/
lib.rs

1// This is part of async-resol-vbus.rs.
2// Copyright (c) 2020, Daniel Wippermann.
3// See README.md and LICENSE.txt for details.
4
5//! # async-resol-vbus.rs
6//!
7//! A Rust library for processing RESOL VBus data asynchronously.
8//!
9//!
10//! ## Features
11//!
12//! - Allows discovery of VBus-over-TCP devices in a local network
13//! - Connect to or provide VBus-over-TCP services
14//!
15//!
16//! ## Planned, but not yet implemented features
17//!
18//! - none (yet)
19//!
20//!
21//! ## Examples
22//!
23//! ```no_run
24//! use std::fs::File;
25//!
26//! use async_std::{
27//!     net::{SocketAddr, TcpStream},
28//!     prelude::*,
29//! };
30//!
31//! use resol_vbus::{DataSet, RecordingWriter};
32//!
33//! use async_resol_vbus::{Result, LiveDataStream, TcpClientHandshake};
34//!
35//! fn main() -> Result<()> {
36//!     async_std::task::block_on(async {
37//!         // Create an recording file and hand it to a `RecordingWriter`
38//!         let file = File::create("test.vbus")?;
39//!         let mut rw = RecordingWriter::new(file);
40//!     
41//!         // Parse the address of the DL2 to connect to
42//!         let addr = "192.168.13.45:7053".parse::<SocketAddr>()?;
43//!
44//!         let stream = TcpStream::connect(addr).await?;
45//!
46//!         let mut hs = TcpClientHandshake::start(stream).await?;
47//!         hs.send_pass_command("vbus").await?;
48//!         let stream = hs.send_data_command().await?;
49//!
50//!         let (reader, writer) = (&stream, &stream);
51//!
52//!         let mut stream = LiveDataStream::new(reader, writer, 0, 0x0020);
53//!
54//!         while let Some(data) = stream.receive_any_data(60000).await? {
55//!             println!("{}", data.id_string());
56//!
57//!             // Add `Data` value into `DataSet` to be stored
58//!             let mut data_set = DataSet::new();
59//!             data_set.timestamp = data.as_ref().timestamp;
60//!             data_set.add_data(data);
61//!
62//!             // Write the `DataSet` into the `RecordingWriter` for permanent storage
63//!             rw.write_data_set(&data_set)
64//!                 .expect("Unable to write data set");
65//!         }
66//!
67//!         Ok(())
68//!     })
69//! }
70//! ```
71
72#![warn(missing_docs)]
73#![deny(missing_debug_implementations)]
74#![deny(warnings)]
75#![deny(future_incompatible)]
76#![deny(nonstandard_style)]
77#![deny(rust_2018_compatibility)]
78#![deny(rust_2018_idioms)]
79#![allow(clippy::if_same_then_else)]
80#![allow(clippy::large_enum_variant)]
81#![allow(clippy::needless_bool)]
82#![allow(clippy::needless_pass_by_value)]
83#![allow(clippy::trivially_copy_pass_by_ref)]
84#![allow(clippy::write_with_newline)]
85
86pub use resol_vbus::*;
87
88mod error;
89pub use error::Result;
90
91mod device_information;
92pub use device_information::DeviceInformation;
93
94mod device_discovery;
95pub use device_discovery::DeviceDiscovery;
96
97mod tcp_client_handshake;
98pub use tcp_client_handshake::TcpClientHandshake;
99
100mod tcp_server_handshake;
101pub use tcp_server_handshake::TcpServerHandshake;
102
103mod live_data_stream;
104pub use live_data_stream::LiveDataStream;