Skip to main content

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 route_changes;
19pub mod trip;
20
21pub use crate::{
22    common::{DvbResponse, Mot},
23    error::Result,
24    time::DvbTime,
25};
26
27use crate::{
28    monitor::DepartureMonitor,
29    point::{Found, Params, point_finder},
30};
31
32/// Search for stops by name using the VVO PointFinder API.
33///
34/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = true`.
35/// For more advanced queries, use [`point::point_finder`] directly.
36///
37/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
38pub async fn find_stops(query: &str) -> Result<DvbResponse<Found>> {
39    point_finder(&Params {
40        query,
41        stops_only: true,
42        ..Default::default()
43    })
44    .await
45}
46
47/// Search for nearby and assigned stops using the VVO PointFinder API.
48///
49/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = false` and `assigedstops = true`.
50/// For more advanced queries, use [`point::point_finder`] directly.
51///
52/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
53pub async fn find_nearby_stops(query: &str) -> Result<DvbResponse<Found>> {
54    point_finder(&Params {
55        query,
56        stops_only: false,
57        assigedstops: true,
58        ..Default::default()
59    })
60    .await
61}
62
63/// Search for points of interest (POIs) using the VVO PointFinder API.
64///
65/// This is a convenience wrapper for [`point::point_finder`] with `stops_only = false`.
66/// For more advanced queries, use [`point::point_finder`] directly.
67///
68/// Endpoint: `https://webapi.vvo-online.de/pointfinder`
69pub async fn find_pois(query: &str) -> Result<DvbResponse<Found>> {
70    point_finder(&Params {
71        query,
72        stops_only: false,
73        ..Default::default()
74    })
75    .await
76}
77
78/// Get upcoming departures for a stop using the VVO Departure Monitor API.
79///
80/// This is a convenience wrapper for [`monitor::departure_monitor`] with default parameters.
81/// For more advanced queries (e.g., filtering by mode of transport, custom limits, etc.), use [`monitor::departure_monitor`] directly.
82///
83/// Endpoint: `https://webapi.vvo-online.de/dm`
84pub async fn monitor_departures(stopid: &str) -> Result<DvbResponse<DepartureMonitor>> {
85    let monitor = monitor::departure_monitor(monitor::Params {
86        stopid,
87        mot: None,
88        limit: Some(15),
89        ..Default::default()
90    })
91    .await?;
92
93    Ok(monitor)
94}