Expand description
§FitParser
fitparser
is a utility to parse an ANT FIT file based on a given profile into a more
useful form for consuming applications. To that end the serde
framework is used to allow the data to be serialized into any format supported by serde. This
library currently does not support writing FIT files.
§Example
Open a file or pass in any other object that implements the Read
trait. A vector of data records is returned if deserialization is
successful. See the fit_to_json
example for a command line utility
that parses FIT files and exports them as JSON.
use fitparser;
use fitparser::de::{DecodeOption, from_reader_with_options};
use std::fs::File;
use std::io::prelude::*;
println!("Parsing FIT files using Profile version: {:?}", fitparser::profile::VERSION);
let mut fp = File::open("tests/fixtures/Activity.fit")?;
for data in fitparser::from_reader(&mut fp)? {
// print the data in FIT file
println!("{:#?}", data);
}
// Optionally ignore CRC validation
let opts = [DecodeOption::SkipHeaderCrcValidation,
DecodeOption::SkipDataCrcValidation].iter().map(|o| *o).collect();
let mut fp = File::open("tests/fixtures/Activity.fit")?;
for data in from_reader_with_options(&mut fp, &opts)? {
// print the data in FIT file
println!("{:#?}", data);
}
Re-exports§
pub use de::from_bytes;
pub use de::from_reader;
Modules§
- de
- Deserialize a stream of FIT file data into the serde data model by parsing the file and applying the packaged FIT profile to the data.
- profile
- Defines the FIT profile used to convert raw parser output into final values that can be interpreted without using the FIT profile.
Structs§
- Developer
Field Description - Developer fields are fields with properties that are not already defined by the SDK, but instead the definition is part of the fit file, for more flexiblity. Since their properties are dynamically defined and cannot be looked up statically we need to store these properties. This is what the DeveloperFieldDescription struct is for.
- FitData
Field - Stores a value and it’s defined units which are set by the FIT profile during decoding
- FitData
Record - Defines a set of data derived from a FIT Data message.
- Value
With Units - Describes a field value along with its defined units (if any), this struct is useful for
serializing data in a key-value store where the key is either the name or definition number
since it can be created from a
FitDataField
with minimal data cloning.
Enums§
- Error
Kind - The kind of error that can be produced during deserialization. TODO: Handle errors produced by nom cleanly
- Value
- Contains arbitrary data in the defined format.