Crate napchart[−][src]
The napchart
crate provides strongly-typed bindings to the https://napchart.com API.
By default, only the api BlockingClient is enabled with default-features = ["blocking"]
.
An AsyncClient is also provided with crate feature async
.
The following examples will use the blocking client but the process is the same with async
except with .await
thrown in before .unwrap()
.
/get
ing a napchart
Link to chart: https://napchart.com/3tbkt.
use napchart::api::BlockingClient; let client = BlockingClient::default(); let chart = client.get("3tbkt").unwrap(); assert_eq!(chart.get_id(), Some(&String::from("3tbkt"))); assert_eq!(chart.title, Some(String::from("State test chart"))); assert_eq!(chart.shape, napchart::ChartShape::Circle); assert_eq!(chart.lanes.len(), 1);
/create
ing a new napchart
use napchart::api::BlockingClient; use napchart::Napchart; let client = BlockingClient::default(); let mut chart = Napchart::default() .title("lib.rs doctest") .description("https://crates.io/crates/napchart"); let lane = chart.add_lane(); lane.add_element(420, 1260) .unwrap() .text("Nighttime") .color("grey"); assert!(chart.get_id().is_none()); // client.create_new(&mut chart).unwrap(); // assert!(chart.get_id().is_some());
Getting an image for a napchart
use napchart::api::BlockingClient; use std::fs::File; let client = BlockingClient::default(); let mut file = File::create("/tmp/napchart_3tbkt.png").unwrap(); client.get_image("3tbkt", &mut file, (600, 600), None).unwrap();
Modules
api | The actual api clients |
Structs
ChartElement | A single napchart element |
ChartLane | A single lane of a napchart |
ElementData | Additional metadata for a ChartElement |
Napchart | A napchart, as seen on https://napchart.com/ |
Enums
ChartShape | The shape of a napchart |
ErrorKind | napchart-rs error type |