Expand description
§async-resol-vbus.rs
A Rust library for processing RESOL VBus data asynchronously.
§Features
- Allows discovery of VBus-over-TCP devices in a local network
- Connect to or provide VBus-over-TCP services
§Planned, but not yet implemented features
- none (yet)
§Examples
use std::fs::File;
use async_std::{
net::{SocketAddr, TcpStream},
prelude::*,
};
use resol_vbus::{DataSet, RecordingWriter};
use async_resol_vbus::{Result, LiveDataStream, TcpClientHandshake};
fn main() -> Result<()> {
async_std::task::block_on(async {
// Create an recording file and hand it to a `RecordingWriter`
let file = File::create("test.vbus")?;
let mut rw = RecordingWriter::new(file);
// Parse the address of the DL2 to connect to
let addr = "192.168.13.45:7053".parse::<SocketAddr>()?;
let stream = TcpStream::connect(addr).await?;
let mut hs = TcpClientHandshake::start(stream).await?;
hs.send_pass_command("vbus").await?;
let stream = hs.send_data_command().await?;
let (reader, writer) = (&stream, &stream);
let mut stream = LiveDataStream::new(reader, writer, 0, 0x0020);
while let Some(data) = stream.receive_any_data(60000).await? {
println!("{}", data.id_string());
// Add `Data` value into `DataSet` to be stored
let mut data_set = DataSet::new();
data_set.timestamp = data.as_ref().timestamp;
data_set.add_data(data);
// Write the `DataSet` into the `RecordingWriter` for permanent storage
rw.write_data_set(&data_set)
.expect("Unable to write data set");
}
Ok(())
})
}
Modules§
- chrono
- Chrono: Date and Time for Rust
- live_
data_ decoder - Functions in this module can be used to decode byte slices of data conforming to the
VBus protocol specification into the respective
Data
variants. - live_
data_ encoder - Functions in the module can be used to convert a
Data
variant into the respective live representation according to the VBus protocol specification. - recording_
decoder - Functions in this module allow to decode a byte stream conforming to the VBus Recording File Format.
- recording_
encoder - Functions in the module can be used to convert a
Data
variant into the respective recorded representation according to the VBus Recording File Format. - specification
- This module provides the
Specification
and its associated types to allow interpretation of the fields contained within theframe_data
payload ofPacket
values. - specification_
file - A module that parses the contents of a VBus Specification File Version 1 (VSF1).
- utils
- A module containing utitlities functions for processing VBus data.
Structs§
- Blob
Buffer - A size-adating buffer to store bytes in. The buffer grows when data is stored into it. The contents can then be consumed which results in the buffer dropping the consumed data before new data are appended.
- Blob
Reader - A buffering reader that allows to borrow the internal buffer.
- DataSet
- A
DataSet
contains a set of unique (non-identical)Data
values. - Datagram
- The
Datagram
type stores information according to the VBus protocol version 2.x. - Device
Discovery - Allows discovery of VBus-over-TCP devices in a local network.
- Device
Information - A struct containing information about a VBus-over-TCP device.
- Error
- A common error type.
- File
List Reader - Chains multiple files together in a single
Read
object. - Header
- All VBus data types consist of a
Header
element. - Live
Data Buffer - A size-adapting buffer that supports decoding VBus live data. See
BlobBuffer
for details. - Live
Data Reader - Allows reading
Data
variants from aRead
trait object. - Live
Data Recording Reader - A
RecordingReader
for type 0x88 live data recordings. - Live
Data Recording Writer - A
RecordingWriter
for type 0x88 live data recordings. - Live
Data Stream - A
Stream
/Sink
wrapper for RESOL VBusData
items encoded in the live / wire representation. - Live
Data Writer - Allows writing the live represenation of
Data
variants to aWrite
trait object. - Packet
- The
Packet
type stores information according to the VBus protocol version 1.x. - Packet
Field Id - A tuple of identification information about a field in a
Packet
value. - Packet
Id - A tuple of identification information about a
Packet
value. - Recording
Reader - Allows reading
Data
variants from aRead
trait object. - Recording
Writer - Allows writing the recorded representation of
DataSet
values to aWrite
trait object. - Specification
- The
Specification
type contains information about known devices and packets. - Specification
File - Contains the information from a VSF1 file.
- TcpClient
Handshake - Handles the client-side of the VBus-over-TCP handshake.
- TcpServer
Handshake - Handles the server-side of the VBus-over-TCP handshake.
- Telegram
- The
Telegram
type stores information according to the VBus protocol version 3.x.
Enums§
- Data
Data
is a type that contains one of the supported VBus protocol data variants.- Language
- Languages supported by VSF1 specification.
- Stream
Blob Length - Provides information whether a slice of bytes contains a valid blob of data.
Traits§
- IdHash
- A trait to generate an identification hash for any of the VBus data types.
- ToPacket
Field Id - A trait to get a
PacketFieldId
for a given value. - ToPacket
Id - A trait to get a
PacketId
for a given value.
Functions§
- id_hash
- Calculate the identification hash for a given VBus data value.
Type Aliases§
- Result
- A common result type.