4 个版本 (重大更新)

0.4.0 2021 年 6 月 3 日
0.3.0 2021 年 6 月 3 日
0.2.0 2020 年 1 月 19 日
0.1.0 2019 年 11 月 10 日

#29 in #day

每月 23 下载次数

BSD-3-Clause

23KB
293

🥢 欢迎使用 openmensa-rs 🍴

GitHub GitHub PRs Welcome

rust 库,用于与 openmensa api 交互


基本用法 🔧

此库提供了一种构建对 openmensa api 的请求并将其反序列化为 rust 结构的方法。提供对 CanteenMealDay 的请求。

请求所有餐厅的列表

use openmensa_rs::request::CanteenRequest;

#[tokio::main]
async fn main() {
    println!("List of all canteens: ");
    let list = CanteenRequest::new().build().await;
    println!("{:?}", list);
}

请求单个餐厅的菜单

use openmensa_rs::{req_canteens, request::MealRequest};

#[tokio::main]
async fn main() {
    let list = req_canteens().await.unwrap();
    // Print out the meals offered in the first canteen
    println!("Meals in the {} canteen on the {}", list[0].name(), chrono::Utc::today());
    let meals = MealRequest::new(list[0].id(), chrono::Utc::today())
        .build()
        .await
        .unwrap();
    println!("{:?}", meals);
}

泛型请求的缩写

如果您想获取所有信息并指定请求的进一步约束,您可以使用提供的缩写 req_canteensreq_daysreq_meals

use openmensa_rs::req_canteens;

#[tokio::main]
async fn main() {
    let list = req_canteens().await.unwrap();
    println!("First canteens has id {} and is called {}", list[0].id(), list[0].name());
}

添加此软件包 📦

您只需在 Cargo.toml 中的 dependencies 下添加即可

[dependencies]
openmensa-rs = "^0"

故障排除

如果您在使用此库时遇到任何问题或发现任何问题,请随时提交一个问题。解释您的问题,如果可能的话,提供一段简短的代码片段。

作者

Johannes Wünsche

:octocat: @jwuensche
🐘 @fredowald@mastodon.social
🐦 @Fredowald

此 README 模板基于与 fin-ger 的合作。

显示您的支持

如果此项目对您有帮助,请点个 ⭐!

依赖项

~4–19MB
~262K SLoC