Crates.io | holidayapi_rust |
lib.rs | holidayapi_rust |
version | 0.1.7 |
source | src |
created_at | 2022-09-23 09:51:54.815234 |
updated_at | 2022-10-06 07:04:40.165037 |
description | A HolidayAPI library for Rust |
homepage | |
repository | https://github.com/TechTheAwesome/holidayapi-rust |
max_upload_size | |
id | 672372 |
size | 28,235 |
Unofficial library for Holiday API written in Rust. This repo implements interface for original HolidayAPI endpoints seen here.
This project is heavily inspired by holidayapi-node and holiday-api-rust repositories.
Add the following to your Cargo.toml
[dependencies]
holidayapi_rust = "0.1.7"
Or use cargo
cli:
$ cargo add holidayapi_rust
use holidayapi_rust::prelude::*;
let holiday_api = HolidayAPI::new("00000000-0000-0000-0000-000000000000").unwrap();
async fn main() {
// Fetch supported countries and subdivisions
let countries: Vec<Country> = holiday_api.countries().get().await.unwrap();
// Fetch supported languages
let languages: Vec<Language> = holiday_api.languages().get().await.unwrap();
// Fetch holidays with minimum parameters
let holidays: Vec<Holiday> = holiday_api.holidays("US", 2020).get().await.unwrap();
}
use holidayapi_rust::prelude::*;
let holiday_api = HolidayAPI::new(VALID_KEY).unwrap();
// Holidays
let specific_request: Vec<Holiday> = holiday_api
.holidays("jp", 2021)
.pretty(true)
.language("cn")
.public(true)
.get()
.await;
// Countries
let specific_request: Vec<Country> = holiday_api
.countries()
.search("hello world")
.country("US")
.public(true)
.get()
.await
.unwrap();
// Languages
let specific_request: Vec<Language> = holiday_api
.languages()
.search("chinese")
.pretty(true)
.get()
.await
.unwrap();
.get()
calls.