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§

Modules§

  • 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.
  • Defines the FIT profile used to convert raw parser output into final values that can be interpreted without using the FIT profile.

Structs§

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

  • The kind of error that can be produced during deserialization. TODO: Handle errors produced by nom cleanly
  • Contains arbitrary data in the defined format.

Type Aliases§

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