[][src]Crate async_resol_vbus

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 the frame_data payload of Packet 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

BlobBuffer

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.

BlobReader

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.

DeviceDiscovery

Allows discovery of VBus-over-TCP devices in a local network.

DeviceInformation

A struct containing information about a VBus-over-TCP device.

Error

A common error type.

FileListReader

Chains multiple files together in a single Read object.

Header

All VBus data types consist of a Header element.

LiveDataBuffer

A size-adapting buffer that supports decoding VBus live data. See BlobBuffer for details.

LiveDataReader

Allows reading Data variants from a Read trait object.

LiveDataRecordingReader

A RecordingReader for type 0x88 live data recordings.

LiveDataRecordingWriter

A RecordingWriter for type 0x88 live data recordings.

LiveDataStream

A Stream/Sink wrapper for RESOL VBus Data items encoded in the live / wire representation.

LiveDataWriter

Allows writing the live represenation of Data variants to a Write trait object.

Packet

The Packet type stores information according to the VBus protocol version 1.x.

PacketFieldId

A tuple of identification information about a field in a Packet value.

PacketId

A tuple of identification information about a Packet value.

RecordingReader

Allows reading Data variants from a Read trait object.

RecordingWriter

Allows writing the recorded representation of DataSet values to a Write trait object.

Specification

The Specification type contains information about known devices and packets.

SpecificationFile

Contains the information from a VSF1 file.

TcpClientHandshake

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

TcpServerHandshake

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.

StreamBlobLength

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.

ToPacketFieldId

A trait to get a PacketFieldId for a given value.

ToPacketId

A trait to get a PacketId for a given value.

Functions

id_hash

Calculate the identification hash for a given VBus data value.

Type Definitions

Result

A common result type.

Result

A common result type.