14 个版本
0.3.1 | 2021 年 7 月 31 日 |
---|---|
0.3.0 | 2021 年 7 月 31 日 |
0.2.3 | 2021 年 5 月 17 日 |
0.2.0 | 2021 年 4 月 6 日 |
0.1.5 | 2021 年 3 月 22 日 |
在 网络编程 中排名第 1390
每月下载量 62
用于 timemachine
57KB
830 代码行
napchart-rs
对 https://napchart.com API 的强类型 Rust 接口。
目前 napchart 的公共 API 非常简单,但这个工具将允许你使用它!
用法
添加到你的 Cargo.toml
[dependencies]
napchart = "0.3"
示例
从头创建新的 napchart
示例: 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");
下载 napchart
示例图表: 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);
将 napchart 作为快照上传
示例输出: 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());
依赖项
~5–20MB
~270K SLoC