# Timestamped

Timestamped is a Rust crate to wrap an artbitrary data point in a timestamp.
Each timestamp records both a Utc-localized timestamp from the `chrono` crate,
which allows serialization, deserialization, and human-readable, resolvable time
representation, as well as a `std::time::Instant`, which is used for internal
time difference comparisons.

There are many edge cases around comparing times, but this crate seeks to
address the majority of concerns while presenting a clean, elegant interface.
Suggestions and contributions are welcome!

# Examples
```rust

use timestamped::Timestamped;

fn read_sensor_a() -> f64 {
    20.0
}

#[derive(Default)]
struct ImageData {
    raw_image_data: Vec<u8>,
    source: String,
    file_path: std::path::PathBuf,
}

fn read_image_data() ->  {
    ImageData::default()
}

fn main() {
    let first_data_point = Timestamped::new(read_sensor_a());
    let image_data = Timestamped::new(read_image_data());

    println!("First data point: {:?}", first_data_point);
    println!("Image data: {:?}", image_data);

    assert!(image_data.happened_within_x_of(&first_data_point,
        std::time::Duration::from_millis(200));

    println!("The image was taken at {:?}", image_data.timestamp());
}
```
