Enum resol_vbus::Data
source · Expand description
Data
is a type that contains one of the supported VBus protocol data variants.
Examples
use std::io::Read;
use resol_vbus::{LiveDataReader, Result};
fn print_data_ids<R: Read>(r: R) -> Result<()> {
let mut ldr = LiveDataReader::new(0, r);
while let Some(data) = ldr.read_data()? {
if !data.is_packet() {
continue;
}
println!("{}: {}", data.as_header().timestamp, data.id_string());
}
Ok(())
}
Variants§
Packet(Packet)
Contains a Packet
conforming to VBus protocol version 1.x.
Datagram(Datagram)
Contains a Datagram
conforming to VBus protocol version 2.x.
Telegram(Telegram)
Contains a Telegram
conforming to VBus protocol version 3.x.
Implementations§
source§impl Data
impl Data
sourcepub fn is_datagram(&self) -> bool
pub fn is_datagram(&self) -> bool
Returns true
if the variant is a Packet
.
sourcepub fn is_telegram(&self) -> bool
pub fn is_telegram(&self) -> bool
Returns true
if the variant is a Packet
.
sourcepub fn into_packet(self) -> Packet
pub fn into_packet(self) -> Packet
Returns the Packet
value, consuming the Data
value.
Panics
The function panics if the Data
value is no Packet
variant.
sourcepub fn into_datagram(self) -> Datagram
pub fn into_datagram(self) -> Datagram
Returns the Datagram
value, consuming the Data
value.
Panics
The function panics if the Data
value is no Datagram
variant.
sourcepub fn into_telegram(self) -> Telegram
pub fn into_telegram(self) -> Telegram
Returns the Telegram
value, consuming the Data
value.
Panics
The function panics if the Data
value is no Telegram
variant.
sourcepub fn as_datagram(&self) -> &Datagram
pub fn as_datagram(&self) -> &Datagram
sourcepub fn as_telegram(&self) -> &Telegram
pub fn as_telegram(&self) -> &Telegram
Trait Implementations§
source§impl PartialEq<Data> for Data
impl PartialEq<Data> for Data
source§fn eq(&self, right: &Data) -> bool
fn eq(&self, right: &Data) -> bool
Returns true
if two Data
values are “identical”.
Each Data
variant has a set of fields that make up its “identity”. The PartialEq
trait
implementation checks those fields for equality and returns true
if all of the fields
match.
See the descriptions for the Header
, Packet
, Datagram
and Telegram
types to find
out which fields are considered in each case.
source§impl PartialOrd<Data> for Data
impl PartialOrd<Data> for Data
source§fn partial_cmp(&self, right: &Data) -> Option<Ordering>
fn partial_cmp(&self, right: &Data) -> Option<Ordering>
Compares two Data
values are “identical”.
Each Data
variant has a set of fields that make up its “identity”. The PartialOrd
trait
implementation compares those fields.
See the descriptions for the Header
, Packet
, Datagram
and Telegram
types to find
out which fields are considered in each case.
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more