12 releases

0.2.3 May 17, 2021
0.2.2 May 16, 2021
0.2.0 Apr 6, 2021
0.1.5 Mar 22, 2021
Download history 65/week @ 2021-04-03 28/week @ 2021-04-10 28/week @ 2021-04-17 4/week @ 2021-04-24 13/week @ 2021-05-01 8/week @ 2021-05-08 47/week @ 2021-05-15 3/week @ 2021-05-22 6/week @ 2021-05-29 16/week @ 2021-06-05 4/week @ 2021-06-12 3/week @ 2021-06-19 3/week @ 2021-06-26 4/week @ 2021-07-03 8/week @ 2021-07-10 19/week @ 2021-07-17

133 downloads per month
Used in timemachine

MIT license

60KB
866 lines

napchart-rs

GitHub last commit Crates.io Docs.rs

A strongly-typed rust interface to the https://napchart.com API.

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

Usage

Add to your Cargo.toml:

[dependencies]
napchart = "0.2"

Examples

Creating a new napchart from scratch

Example: https://napchart.com/snapshot/O6kunUfuL

use napchart::prelude::*;

let mut chart = Napchart::default()
    .shape(ChartShape::Circle)
    .lanes(1);
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()
    .color(ChartColor::Blue);
second_lane.add_element(120, 240).unwrap()
    .color(ChartColor::Green)
    .text("Cool green time");

Downloading a napchart

Example Chart: https://napchart.com/3tbkt

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: https://napchart.com/snapshot/TpCfggr4i

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)
    .unwrap()
    .text("Nighttime")
    .color(ChartColor::Gray);
let upload_builder = chart.upload()
    .title("readme doctest")
    .description("https://crates.io/crates/napchart");
let remote_chart = client.create_snapshot(upload_builder).unwrap();
assert!(!remote_chart.chartid.is_empty());

Dependencies

~4–8MB
~187K SLoC