ULogData

Struct ULogData 

Source
pub struct ULogData { /* private fields */ }
Expand description

Container for a single data row

Implementations§

Source§

impl ULogData

Source

pub fn new(data: Vec<u8>, formats: Vec<String>) -> Self

Source

pub fn data(&self) -> &Vec<u8>

Get the unformatted data for this item

Source

pub fn formats(&self) -> &Vec<String>

Get the data formatting for this item

Source

pub fn items(&self) -> Vec<String>

Get the list of field names in this item

§Examples
use std::fs::File;
use px4_ulog::parser::dataset::*;
let filename = format!(
    "{}/tests/fixtures/6ba1abc7-b433-4029-b8f5-3b2bb12d3b6c.ulg",
    env!("CARGO_MANIFEST_DIR")
);

let mut log_file = File::open(&filename).unwrap();
let items = log_file.get_dataset("vehicle_gps_position")
    .unwrap()
    .next()
    .unwrap()
    .items();
assert_eq!(items[0], "timestamp");
assert_eq!(items[1], "time_utc_usec");
assert_eq!(items.len(), 23);
Source

pub fn iter(&self) -> ULogDataIter<'_>

Get an iterator for data fields

The iterator value will be a tuple of (&str, DataType) where the first item will be the field name and the second the value.

§Examples
use std::fs::File;
use px4_ulog::parser::dataset::*;
let filename = format!(
    "{}/tests/fixtures/6ba1abc7-b433-4029-b8f5-3b2bb12d3b6c.ulg",
    env!("CARGO_MANIFEST_DIR")
);

let mut log_file = File::open(&filename).unwrap();
let mut dataset = log_file.get_dataset("vehicle_gps_position").unwrap();
let first_data = dataset.next().unwrap();
assert_eq!(first_data.iter().count(), 23);
Examples found in repository?
examples/gps-position.rs (line 23)
7fn main() {
8    let filename = format!(
9        "{}/tests/fixtures/6ba1abc7-b433-4029-b8f5-3b2bb12d3b6c.ulg",
10        env!("CARGO_MANIFEST_DIR")
11    );
12    let mut log_file = File::open(&filename).unwrap();
13
14    let gps_positions: Vec<ULogData> = log_file
15        .get_dataset("vehicle_gps_position")
16        .unwrap()
17        .collect();
18
19    println!("Measurements: {}", gps_positions.len());
20
21    for dataset in gps_positions.iter() {
22        println!("--------------------------");
23        for (name, val) in dataset.iter() {
24            println!("{}: {:?}", name, val);
25        }
26    }
27}

Trait Implementations§

Source§

impl Debug for ULogData

Source§

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

Formats the value using the given formatter. Read more

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> 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, 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.