Crates.io | tdms |
lib.rs | tdms |
version | 0.3.0 |
source | src |
created_at | 2022-06-05 01:26:00.841102 |
updated_at | 2023-01-29 02:31:04.620291 |
description | A LabView TDMS file parser written in Rust |
homepage | |
repository | https://github.com/DnOberon/tdms |
max_upload_size | |
id | 599997 |
size | 125,893 |
tdms
is a LabVIEW TDMS file parser library written in Rust. This is meant to be a general purpose library for reading and performing any calculation work on data contained in those files.
Note: This library is a work in progress. While I do not expect the current function signatures and library structure to change, you could experience difficulties due to early adoption. Functionality is currently limited. Raw data channel iterators will be added slowly and a list will be kept indicating which are available and which are under construction
Vec<u8>
only at the present time)log
api - users of the library must choose and initialize the implementation, such as env-logger
Here is a list of all supported iterators for TDMS data types. If completely unlisted, then that type is not supported yet. Check back frequently as this list will grow quickly.
Data Type | Standard | Interleaved | DAQmx |
---|---|---|---|
Double Float | ✓ | ✓ - untested | ✗ |
Single Float | ✓ - untested | ✓ - untested | ✗ |
Single Float with unit | ✓ - untested | ✓ - untested | ✗ |
Double Float with unit | ✓ - untested | ✓ - untested | ✗ |
Complex Single Float | ✓ - untested | ✓ - untested | ✗ |
Complex Double Float | ✓ - untested | ✓ - untested | ✗ |
I8 | ✓ - untested | ✓ - untested | ✗ |
I32 | ✓ - untested | ✓ - untested | ✗ |
I64 | ✓ - untested | ✓ - untested | ✗ |
U8 | ✓ - untested | ✓ - untested | ✗ |
U16 | ✓ - untested | ✓ - untested | ✗ |
U32 | ✓ - untested | ✓ - untested | ✗ |
U64 | ✓ - untested | ✓ - untested | ✗ |
Boolean | ✓ - untested | ✓ - untested | ✗ |
Timestamp (returns tuple) | ✓ - untested | ✓ - untested | ✗ |
Single Float | ✓ - untested | ✓ - untested | ✗ |
Single Float | ✓ - untested | ✓ - untested | ✗ |
Single Float | ✓ - untested | ✓ - untested | ✗ |
String | ✓ - untested | ✗ | ✗ |
extern crate tdms;
use std::path::Path;
use tdms::data_type::TdmsDataType;
use tdms::TDMSFile;
fn main() {
// open and parse the TDMS file, passing in metadata false will mean the entire file is
// read into memory, not just the metadata
let file = match TDMSFile::from_path(Path::new("data/standard.tdms")) {
Ok(f) => f,
Err(e) => panic!("{:?}", e),
};
// fetch groups
let groups = file.groups();
for group in groups {
// fetch an IndexSet of the group's channels
let channels = file.channels(&group);
let mut i = 0;
for (_, channel) in channels {
// once you know the channel's full path (group + channel) you can ask for the full
// channel object. In order to fetch a channel you must call the proper channel func
// depending on your data type. Currently this feature is unimplemented but the method
// of calling this is set down for future changes
let full_channel = match channel.data_type {
// the returned full channel is an iterator over raw data
TdmsDataType::DoubleFloat(_) => file.clone().channel_data_double_float(channel),
_ => {
panic!("{}", "channel for data type unimplemented")
}
};
let mut full_channel_iterator = match full_channel {
Ok(i) => i,
Err(e) => {
panic!("{:?}", e)
}
};
println!("{:?}", full_channel_iterator.count());
i += 1;
}
}
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.