#接口 #强类型 #com #API 绑定 #alpha #快照 #napchart-rs

bin+lib napchart

Rust 对 https://napchart.com API 的接口 alpha 版

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

Download history 18/week @ 2024-03-12 17/week @ 2024-03-26 38/week @ 2024-04-02

每月下载量 62
用于 timemachine

MIT 许可证

57KB
830 代码行

napchart-rs

GitHub last commit Crates.io Docs.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