Crate napchart[][src]

Expand description


GitHub last commit

A strongly-typed rust interface to the API.

The public napchart api is pretty barebones right now, but this will let you use it!


Add to your Cargo.toml:

napchart = "0.3"


Creating a new napchart from scratch


use napchart::prelude::*;

let mut chart = Napchart::default()
let first_lane = chart.get_lane_mut(0).unwrap();
first_lane.add_element(0, 60).unwrap()
    .text("Hour One");
first_lane.add_element(180, 240).unwrap()
    .text("Hour Four");
let second_lane = chart.add_lane();
second_lane.add_element(0, 120).unwrap()
second_lane.add_element(120, 240).unwrap()
    .text("Cool green time");

Downloading a napchart

Example Chart:

use napchart::api::BlockingClient;

let client = BlockingClient::default();
let rchart = client.get_chart("3tbkt").unwrap();
assert_eq!(rchart.chartid, String::from("3tbkt"));
assert_eq!(rchart.title, Some(String::from("State test chart")));
assert_eq!(rchart.chart.shape, napchart::ChartShape::Circle);
assert_eq!(rchart.chart.lanes_len(), 1);

Uploading a napchart as a snapshot

Example Output:

use napchart::prelude::*;
use napchart::api::BlockingClient;

let client = BlockingClient::default();
let mut chart = Napchart::default();
let lane = chart.add_lane();
lane.add_element(420, 1260)
let upload_builder = chart.upload()
    .title("readme doctest")
let remote_chart = client.create_snapshot(upload_builder).unwrap();


Api clients for

Contains aliases to the useful imports.


A single element in a napchart.

A single lane of a napchart

Additional metadata for an element.

A napchart, as seen on

A napchart downloaded from Includes extra metadata around the internal Napchart, such as the chart’s ID, title, author, update time, etc.


The colors available for chart elements

The shape of a napchart

napchart-rs error type