yxhoo_transit/
lib.rs

1//! # yxhoo-transit
2//!
3//! A Rust client for the unofficial Yxhoo! Transit (Japan) API.
4//!
5//! ## Feature flags
6//! Exactly one HTTP client feature must be enabled.
7//!
8//! - `http-reqwest` (default)
9//! - `http-wreq`
10//! - `schemars`: Enable `JsonSchema` derives for public types.
11//!
12//! ```bash
13//! # default (reqwest)
14//! cargo test
15//!
16//! # wreq
17//! cargo test --no-default-features --features http-wreq,schemars
18//! ```
19//!
20//! ## Example
21//! ```no_run
22//! use yxhoo_transit::{suggest_places, transit, args::{TransitArgs, DateKind}};
23//!
24//! # #[tokio::main]
25//! # async fn main() -> anyhow::Result<()> {
26//! let suggestions = suggest_places("新宿").await?;
27//! println!("{:?}", suggestions);
28//!
29//! let args = TransitArgs {
30//!     from: "新宿".into(),
31//!     to: "渋谷".into(),
32//!     date: chrono::Local::now().into(),
33//!     date_kind: DateKind::DepartureTime,
34//!     rank: 1,
35//!     ..Default::default()
36//! };
37//! let result = transit(&args).await?;
38//! println!("{:?}", result);
39//! # Ok(())
40//! # }
41//! ```
42//!
43//! ## Notes
44//! This crate uses an unofficial API and may break without notice.
45pub mod args;
46mod dt_minute_tz;
47mod http;
48pub mod transit_dto;
49mod yxhoo;
50
51pub use yxhoo::{YxhooPlace, YxhooPlaceKind, YxhooSuggestResponse, suggest_places, transit};