amtrak_api/
lib.rs

1//! # Amtrak Rust API
2//!
3//! Amtrak Rust API allows the caller to query the Amtrak API for information
4//! about trains and stations in its network.
5//!
6//! Please check [`Client`] for the various endpoints this API allows you to
7//! call into.
8//!
9//! Note: This library is not affiliated with Amtrak in any way and is an
10//! unofficial implementation of the public facing API. Amtrak is a registered
11//! trademark of the National Railroad Passenger Corporation.
12//!
13//! # Example usage
14//! Here is an example of querying trains that have stopped at or will stop at a
15//! specific station.
16//!
17//! ```rust
18//! use amtrak_api::Client;
19//!
20//! const STATION_CODE: &str = "PHL";
21//!
22//! #[tokio::main]
23//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
24//!     Client::new()
25//!         .station(STATION_CODE)
26//!         .await?
27//!         .values()
28//!         .for_each(|station| {
29//!             println!(
30//!                 "Current train scheduled for station \"{}\": {}",
31//!                 station.name,
32//!                 station.trains.join(", ")
33//!             );
34//!         });
35//!
36//!     Ok(())
37//! }
38//! ```
39
40mod client;
41mod errors;
42mod responses;
43
44pub use client::Client;
45pub use errors::Error;
46pub use responses::{Station, Train, TrainState, TrainStatus};