Crates.io | openmensa-rs |
lib.rs | openmensa-rs |
version | 0.4.0 |
source | src |
created_at | 2019-11-10 21:11:34.82732 |
updated_at | 2021-06-03 18:56:20.628302 |
description | A library to interact with the openmensa api |
homepage | |
repository | https://github.com/jwuensche/openmensa-rs |
max_upload_size | |
id | 180102 |
size | 54,662 |
rust library to interact with the openmensa api
This library provides a way to build request to the openmensa api and deserialize into rust structures.
Provided are requests for Canteen
, Meal
and Day
.
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);
}
If you want to get all information and specify no further constraints for your requests, you can use the provided shorthands req_canteens
, req_days
and req_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());
}
All you have to do is add in your Cargo.toml
under dependencies
[dependencies]
openmensa-rs = "^0"
If you have any troubles using this library or you find any problems feel free to open an issue. Explaining your problem and if possible provide a short code snippet.
Johannes Wünsche
:octocat:
@jwuensche
:elephant:@fredowald@mastodon.social
:bird:@Fredowald
This README template is based on group works with fin-ger.
Give a :star: if this project helped you!