pub struct ULogData { /* private fields */ }Expand description
Container for a single data row
Implementations§
Source§impl ULogData
impl ULogData
pub fn new(data: Vec<u8>, formats: Vec<String>) -> Self
Sourcepub fn items(&self) -> Vec<String>
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);Sourcepub fn iter(&self) -> ULogDataIter<'_> ⓘ
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§
Auto Trait Implementations§
impl Freeze for ULogData
impl RefUnwindSafe for ULogData
impl Send for ULogData
impl Sync for ULogData
impl Unpin for ULogData
impl UnwindSafe for ULogData
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more