6 releases (breaking)

Uses old Rust 2015

0.5.1 Mar 29, 2020
0.5.0 Mar 9, 2020
0.4.0 Jul 23, 2019
0.3.0 Apr 21, 2019
0.1.0 Jan 6, 2019
Download history 4/week @ 2022-06-11 11/week @ 2022-06-18 11/week @ 2022-06-25 10/week @ 2022-07-02 10/week @ 2022-07-09 16/week @ 2022-07-16 19/week @ 2022-07-23 7/week @ 2022-07-30 12/week @ 2022-08-06 9/week @ 2022-08-13 6/week @ 2022-08-20 10/week @ 2022-08-27 11/week @ 2022-09-03 27/week @ 2022-09-10 7/week @ 2022-09-17 10/week @ 2022-09-24

55 downloads per month
Used in 2 crates

BSD-3-Clause

41KB
922 lines


lib.rs:

An Embedded Time Series Database

This library provides a low-intensity time series database meant to be embedded inside of an application.

From the signature of the series

pub struct Series<T: Clone + Recordable + DeserializeOwned + Serialize> {

you can know that you must parameterize the series over the data type that you want to store, which must also have several traits implemented.

#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
struct BikeTrip {
datetime: DateTime<Utc>,
distance: Distance,
duration: Duration,
comments: String,
}

impl Recordable for BikeTrip {
fn timestamp(&self) -> DateTime<Utc> {
self.datetime
}
fn tags(&self) -> Vec<String> {
Vec::new()
}
}

Recordable requires implementations for timestamp and tags, both of which can be used for searching for records, and both of which may be used for indexing in the future.

The series can only store a single data type, but you can always store multiple data types by wrapping them into a single enum.

Open the series:

let mut ts: Series<BikeTrip> = Series::open("var/bike_trips.json")
.expect("expect the time series to open correctly");

The series file will be created if it does not already exist. If it does already exist, the existing data will be read into memory and made available.

Note: all of the data is read into memory at once. For human-scale things, this probably takes up very little memory, but this software is not optimized for IoT scale deployments. Additionally, this library assumes only one process is writing to the file. Behavior from more than one process writing to the file is currently undefined.

Dependencies

~2.8–4MB
~79K SLoC