Crate sonnerie_api[][src]

This is a simple client API for Sonnerie, a timeseries database.

It lets you do a variety of insertions and reads.

Example

extern crate sonnerie_api;
fn main() -> std::io::Result<()>
{
    let stream = std::net::TcpStream::connect("localhost:5599")?;
    let mut client = sonnerie_api::Client::new(stream)?;
    // read a series (a read transaction is automatically created and closed)
    // start a write transaction
    client.begin_write()?;
    client.create_series("fibonacci", "u")?;
    client.add_value(
        "fibonacci",
        &"2018-01-06T00:00:00".parse().unwrap(),
        13.0,
    )?;
    let results: Vec<(sonnerie_api::NaiveDateTime, Vec<sonnerie_api::OwnedColumn>)> =
        client.read_series("fibonacci")?;
    for row in &results
    {
        // interpret each column as an integer
        for col in &row.1 { let _: u32 = col.from(); }
    }
    // save the transaction
    client.commit()?;
    Ok(())
}

Structs

Client

Sonnerie Client API

Column

This is a reference to a column's value. You can call from to convert it to a concrete type.

NaiveDateTime

ISO 8601 combined date and time without timezone.

OwnedColumn

Same as Column, except can be moved and is heavier weight.

ProtocolError

Error for when client could not understand the server

RowAdder

A function returned by Client::add_rows.

Traits

FromValue

This trait is implemented for the numeric types that Sonnerie supports.

ToValue

Functions

max_time

The maximum timestamp allowed by Sonnerie.