Crate fitparser

Source
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§

DeveloperFieldDescription
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.
FitDataField
Stores a value and it’s defined units which are set by the FIT profile during decoding
FitDataRecord
Defines a set of data derived from a FIT Data message.
ValueWithUnits
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§

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

Type Aliases§

Error
An error that can be produced during deserializing.
Result
The result of a deserialization operation.