Skip to main content

lta/get_traffic_incidents/
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::TrafficIncident;
12use super::parts::{
13    GetTrafficIncidentsInput, GetTrafficIncidentsResponse, get_traffic_incidents_parts,
14};
15/// Returns incidents currently happening on the roads, such as Accidents, Vehicle Breakdowns, Road Blocks, Traffic Diversions etc.
16/// **Update freq**: 2 min
17pub fn encode_get_traffic_incidents(
18    input: GetTrafficIncidentsInput,
19) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
20    let parts = get_traffic_incidents_parts(input)?;
21    satay_runtime::into_empty_request(parts)
22}
23pub fn decode_get_traffic_incidents_response<B: AsRef<[u8]>>(
24    response: satay_runtime::ResponseParts<B>,
25) -> Result<GetTrafficIncidentsResponse, satay_runtime::Error> {
26    let status = response.status;
27    match status.as_u16() {
28        200 => {
29            let body = response.body;
30            let value = satay_runtime::from_projected_json_slice::<Vec<TrafficIncident>>(
31                body.as_ref(),
32                "value",
33                None,
34            )?;
35            Ok(GetTrafficIncidentsResponse::Ok(value))
36        }
37        _ => {
38            let body = response.body;
39            Ok(GetTrafficIncidentsResponse::UnexpectedStatus(
40                status,
41                body.as_ref().to_vec(),
42            ))
43        }
44    }
45}