DataSet

Struct DataSet 

Source
pub struct DataSet {
    pub timestamp: DateTime<Utc>,
    /* private fields */
}
Expand description

A DataSet contains a set of unique (non-identical) Data values.

§Examples

use std::io::Read;

use resol_vbus::{DataSet, RecordingReader, Result};

fn print_data_ids<R: Read>(r: R) -> Result<()> {
    let mut rr = RecordingReader::new(r);

    let mut cumultative_data_set = DataSet::new();

    while let Some(data_set) = rr.read_data_set()? {
        let timestamp = data_set.timestamp;

        cumultative_data_set.add_data_set(data_set);

        println!("{}:", timestamp);
        for data in cumultative_data_set.iter() {
            println!("    - {}", data.id_string());
        }
    }

    Ok(())
}

Fields§

§timestamp: DateTime<Utc>

The timestamp that corresponds to the contained set of Data values.

Implementations§

Source§

impl DataSet

Source

pub fn new() -> DataSet

Construct an empty DataSet.

Source

pub fn from_data(timestamp: DateTime<Utc>, set: Vec<Data>) -> DataSet

Construct a DataSet from a list of Data values.

Source

pub fn len(&self) -> usize

Return the amount of Data values contained in this DataSet.

Source

pub fn is_empty(&self) -> bool

Return whether this DataSet is empty.

Source

pub fn as_data_slice(&self) -> &[Data]

Return the Data values contained in this DataSet.

Source

pub fn add_data(&mut self, data: Data)

Add a Data value, replacing any identical existing one.

Source

pub fn add_data_set(&mut self, data_set: DataSet)

Add all Data values from one DataSet into another.

Source

pub fn remove_all_data(&mut self)

Remove all Data values.

Source

pub fn remove_data_older_than(&mut self, min_timestamp: DateTime<Utc>)

Remove Data values with timestamps older than min_timestamp.

Source

pub fn clear_all_packets(&mut self)

Find all Packet values and set their frame_count to zero effectively hiding their frame_data payload.

Source

pub fn clear_packets_older_than(&mut self, min_timestamp: DateTime<Utc>)

Find all Packet values with timestamps older than min_timestamp and set their frame_count to zero effectively hiding their frame_data payload.

Source

pub fn iter(&self) -> Iter<'_, Data>

Returns an iterator over the Data values.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, Data>

Returns an iterator over the Data values.

Source

pub fn sort(&mut self)

Sort the Data values contained in this DataSet.

Source

pub fn sort_by<F>(&mut self, f: F)
where F: FnMut(&Data, &Data) -> Ordering,

Sort the Data values contained in this DataSet.

Source

pub fn sort_by_id_slice(&mut self, ids: &[PacketId])

Sort the Data values contained in this DataSet by a list of known PacketId values.

Trait Implementations§

Source§

impl AsRef<[Data]> for DataSet

Source§

fn as_ref(&self) -> &[Data]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Clone for DataSet

Source§

fn clone(&self) -> DataSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DataSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DataSet

Source§

fn default() -> DataSet

Returns the “default value” for a type. Read more
Source§

impl IdHash for DataSet

Source§

fn id_hash<H: Hasher>(&self, h: &mut H)

Creates an identification hash for this VBus data value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.