rmv-core 1.0.0

Configuration, retries, stop resolution and connection status for the RMV API
Documentation

rmv-core

The core of the rmv CLI and MCP server for the timetable and realtime API of the Rhein-Main-Verkehrsverbund (RMV).

Part of rmv.

On top of the hafas client it adds what is specific to RMV:

  • the configuration (config.toml and RMV_* variables) with the access key,
  • bounded retries of transient errors,
  • stop resolution: an ID is used as it is, a name only if it names one stop,
  • the status of a connection (ok, delayed, no_realtime, unreachable, cancelled) with its reasons,
  • the output model shared by the CLI and the MCP server.
use rmv_core::{Config, DeparturesQuery, Error, Rmv};

async fn departures() -> Result<(), Error> {
    let config = Config::load(&|name| std::env::var(name).ok())?;
    let rmv = Rmv::new(&config, "my-tool/1.0")?;
    let board = rmv
        .departures(&DeparturesQuery {
            stop: "Frankfurt (Main) Hauptwache".to_owned(),
            count: 10,
            ..DeparturesQuery::default()
        })
        .await?;
    for departure in &board.departures {
        println!("{:?} {}", departure.line, departure.stop.time.scheduled);
    }
    Ok(())
}

The access key

Every request needs an access key of RMV Open Data. Without one, Rmv::new fails with Error::AccessIdMissing and no request is made. The key never shows in Debug output, error messages or logs.

Retries

A request is repeated only after a connection error, a timeout or an HTTP status 500, 502, 503 or 504: at most retries times (default 2), with a growing wait and within timeout_seconds for all attempts together. Errors of the API itself, like a used-up quota, are never repeated. Every repetition counts against the quota of the key.

Modes

Mode RMV product classes
HIGHSPEED_RAIL 1
LONG_DISTANCE 2
REGIONAL_RAIL 4
SUBURBAN 8
SUBWAY 16
TRAM 32
BUS 64, 128
ODM 512
RAIL 1, 2, 4, 8

Terms of use

The data comes from the RMV and is subject to its terms of use. Every result carries the attribution.

License

Apache-2.0