stcp_scraper/destinations/
mod.rs

1use serde::{Deserialize, Serialize};
2
3use crate::{Error, response::StcpResponse, Code};
4
5mod fetch;
6mod parse;
7
8#[derive(Deserialize, Serialize, Debug, PartialEq)]
9pub struct Destination {
10    #[serde(rename = "descr_dir")]
11    pub direction_description: String,
12
13    #[serde(rename = "descr")]
14    pub description: String,
15
16    #[serde(rename = "dir")]
17    pub direction_index: u8,
18}
19
20type DestinationsResponse = StcpResponse<Destination>;
21
22pub fn fetch_destinations(line: &Code) -> Result<Vec<Destination>, Error> {
23    let json = fetch::fetch_destinations(line)?;
24
25    let destinations = parse::parse_destinations(&json)?;
26
27    Ok(destinations.records)
28}