dvb/
lib.rs

1//! An unofficial crate to query publicly accessible API methods for Dresden's public transport system.
2//!
3//! Currently the endpoints are supported:
4//!
5//! ## Station
6//! `http://widgets.vvo-online.de/abfahrtsmonitor/Haltestelle.do`
7//!
8
9mod common;
10pub mod error;
11mod time;
12
13pub mod lines;
14pub mod monitor;
15pub mod poi;
16pub mod point;
17pub mod route;
18pub mod trip;
19
20pub use crate::{
21    common::{DvbResponse, Mot},
22    error::Result,
23    time::DvbTime,
24};
25
26use crate::{
27    monitor::DepartureMonitor,
28    point::{Found, Params, point_finder},
29};
30
31/// Search for stops by name using the VVO PointFinder API.
32///
33/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = true`.
34/// For more advanced queries, use [`point::point_finder`] directly.
35///
36/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
37pub async fn find_stops(query: &str) -> Result<DvbResponse<Found>> {
38    point_finder(&Params {
39        query,
40        stops_only: true,
41        ..Default::default()
42    })
43    .await
44}
45
46/// Search for nearby and assigned stops using the VVO PointFinder API.
47///
48/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = false` and `assigedstops = true`.
49/// For more advanced queries, use [`point::point_finder`] directly.
50///
51/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
52pub async fn find_nearby_stops(query: &str) -> Result<DvbResponse<Found>> {
53    point_finder(&Params {
54        query,
55        stops_only: false,
56        assigedstops: true,
57        ..Default::default()
58    })
59    .await
60}
61
62/// Search for points of interest (POIs) using the VVO PointFinder API.
63///
64/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = false`.
65/// For more advanced queries, use [`point::point_finder`] directly.
66///
67/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
68pub async fn find_pois(query: &str) -> Result<DvbResponse<Found>> {
69    point_finder(&Params {
70        query,
71        stops_only: false,
72        ..Default::default()
73    })
74    .await
75}
76
77/// Get upcoming departures for a stop using the VVO Departure Monitor API.
78///
79/// This is a convenience wrapper for [`monitor::departure_monitor`] with default parameters.
80/// For more advanced queries (e.g., filtering by mode of transport, custom limits, etc.), use [`monitor::departure_monitor`] directly.
81///
82/// Endpoint: `https://webapi.vvo-online.de/dm`
83pub async fn monitor_departures(stopid: &str) -> Result<DvbResponse<DepartureMonitor>> {
84    let monitor = monitor::departure_monitor(monitor::Params {
85        stopid,
86        mot: None,
87        limit: Some(15),
88        ..Default::default()
89    })
90    .await?;
91
92    Ok(monitor)
93}