Skip to main content

lta/get_bus_arrival/
json.rs

1// @generated by satay. Do not edit by hand.
2#![allow(
3    clippy::doc_markdown,
4    clippy::missing_errors_doc,
5    clippy::must_use_candidate,
6    clippy::needless_pass_by_value,
7    clippy::return_self_not_must_use,
8    clippy::single_match_else
9)]
10
11use super::super::types::BusArrivalResponse;
12use super::parts::{GetBusArrivalInput, GetBusArrivalResponse, get_bus_arrival_parts};
13/// Returns real-time Bus Arrival information of Bus Services at a queried Bus Stop, including
14/// - Estimated Arrival Time
15/// - Estimated Current Location
16/// - Estimated Current Load.
17///
18/// **Update freq**: 20s
19pub fn encode_get_bus_arrival(
20    input: GetBusArrivalInput,
21) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
22    let parts = get_bus_arrival_parts(input)?;
23    satay_runtime::into_empty_request(parts)
24}
25pub fn decode_get_bus_arrival_response<B: AsRef<[u8]>>(
26    response: satay_runtime::ResponseParts<B>,
27) -> Result<GetBusArrivalResponse, satay_runtime::Error> {
28    let status = response.status;
29    match status.as_u16() {
30        200 => {
31            let body = response.body;
32            let value = satay_runtime::from_json_slice::<BusArrivalResponse>(body.as_ref())?;
33            Ok(GetBusArrivalResponse::Ok(value))
34        }
35        _ => {
36            let body = response.body;
37            Ok(GetBusArrivalResponse::UnexpectedStatus(
38                status,
39                body.as_ref().to_vec(),
40            ))
41        }
42    }
43}