[−][src]Struct async_resol_vbus::Datagram
The Datagram
type stores information according to the VBus protocol version 2.x.
Datagrams are used to issue simple commands with limited amount of payload (like e.g. getting or setting a parameter).
The "identity" of Datagram
values
As described in the corresponding section of the Header
struct VBus data types use
some of their fields as part of their "identity". In addition to the fields used by the
Header
type the Datagram
type also respects the command
and (under some conditions) the
param16
fields. That means that two Datagram
with differing timestamp
, param32
and
(under some conditions) param16
fields are still considered "identical", if the other fields
match.
Fields
header: Header
The shared Header
of all VBus protocol types.
command: u16
The command of this Datagram
.
param16: i16
The 16-bit parameter attached to this Datagram
.
param32: i32
The 32-bit parameter attached to this Datagram
.
Methods
impl Datagram
[src]
pub fn id_string(&self) -> String
[src]
Creates an identification string for this Datagram
.
The string contains all fields that count towards the "identity" of the Datagram
:
channel
destination_address
source_address
protocol_version
command
param16
(ifcommand
equals 0x0900)
Examples
use resol_vbus::{Header, Datagram}; use resol_vbus::utils::utc_timestamp; let dgram1 = Datagram { header: Header { timestamp: utc_timestamp(1485688933), channel: 0x11, destination_address: 0x1213, source_address: 0x1415, protocol_version: 0x26, }, command: 0x1718, param16: 0x191a, param32: 0x1b1c1d1e, }; let dgram2 = Datagram { header: Header { timestamp: utc_timestamp(1485688933), channel: 0x11, destination_address: 0x1213, source_address: 0x1415, protocol_version: 0x26, }, command: 0x0900, param16: 0x191a, param32: 0x1b1c1d1e, }; assert_eq!("11_1213_1415_26_1718_0000", dgram1.id_string()); assert_eq!("11_1213_1415_26_0900_191A", dgram2.id_string());
Trait Implementations
impl AsRef<Header> for Datagram
[src]
impl Clone for Datagram
[src]
impl Debug for Datagram
[src]
impl From<Datagram> for Data
[src]
impl IdHash for Datagram
[src]
fn id_hash<H>(&self, h: &mut H) where
H: Hasher,
[src]
H: Hasher,
Returns an identification hash for this Datagram
.
The hash contains all fields that count towards the "identity" of the Datagram
:
channel
destination_address
source_address
protocol_version
command
param16
(ifcommand
equals 0x0900)
Examples
use resol_vbus::{Header, Datagram, id_hash}; use resol_vbus::utils::utc_timestamp; let dgram = Datagram { header: Header { timestamp: utc_timestamp(1485688933), channel: 0x11, destination_address: 0x1213, source_address: 0x1415, protocol_version: 0x26, }, command: 0x1718, param16: 0x191a, param32: 0x1b1c1d1e, }; assert_eq!(2264775891674525017, id_hash(&dgram));
Auto Trait Implementations
impl RefUnwindSafe for Datagram
impl Send for Datagram
impl Sync for Datagram
impl Unpin for Datagram
impl UnwindSafe for Datagram
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,