[−][src]Struct async_resol_vbus::Header
All VBus data types consist of a Header
element.
Just like the fact that the first 6 bytes of each VBus live byte stream are the same (SYNC to
protocol version), the Header
struct is the common type for all concrete VBus data types.
In addition to the information stored within the first 6 bytes of the VBus header (destination
and source addresses as well as the protocol version), the Header
type also stores the
VBus channel associated with this data as well as the point in time the data was received.
The "identity" of Header
values
The fields in the Header
struct can be separated into two categories:
- Fields that are used to identify the
Header
and (for concrete VBus data types) its payload:channel
source_address
destination_address
protocol_version
- Fields that are not used to identify the
Header
:timestamp
Two Header
values with different timestamp
fields are considered identical, if all of their
other fields match.
This is also respected by the id_hash
and id_string
functions. They return the same result
for VBus data values that are considered "identical", allowing some fields to differ.
Fields
timestamp: DateTime<Utc>
The timestamp when this Header
was received.
channel: u8
The channel number on which this Header
was received.
destination_address: u16
The destination address of this Header
.
source_address: u16
The source address of this Header
.
protocol_version: u8
The VBus protocol version of this Header
.
Methods
impl Header
[src]
pub fn id_string(&self) -> String
[src]
Creates the common identification string prefix for this Header
.
The string contains all fields that count towards the "identity" of the Header
:
channel
destination_address
source_address
protocol_version
Examples
use resol_vbus::{Header}; use resol_vbus::utils::utc_timestamp; let header = Header { timestamp: utc_timestamp(1485688933), channel: 0x11, destination_address: 0x1213, source_address: 0x1415, protocol_version: 0x16, }; assert_eq!("11_1213_1415_16", header.id_string());
Trait Implementations
impl AsRef<Header> for Telegram
[src]
impl AsRef<Header> for Datagram
[src]
impl AsRef<Header> for Data
[src]
impl AsRef<Header> for Packet
[src]
impl Clone for Header
[src]
impl Debug for Header
[src]
impl Default for Header
[src]
impl IdHash for Header
[src]
fn id_hash<H>(&self, h: &mut H) where
H: Hasher,
[src]
H: Hasher,
Returns an identification hash for this Header
.
The hash contains all fields that count towards the "identity" of the Header
:
channel
destination_address
source_address
protocol_version
Examples
use resol_vbus::{Header, id_hash}; use resol_vbus::utils::utc_timestamp; let header = Header { timestamp: utc_timestamp(1485688933), channel: 0x11, destination_address: 0x1213, source_address: 0x1415, protocol_version: 0x16, }; assert_eq!(8369676560183260683, id_hash(&header));
Auto Trait Implementations
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
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>,