Skip to main content

lta/get_traffic_images/
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::TrafficImage;
12use super::parts::{GetTrafficImagesInput, GetTrafficImagesResponse, get_traffic_images_parts};
13/// Returns links to images from traffic cameras located around Singapore, together with each camera's location coordinates.
14/// **Update freq**: 20 sec
15pub fn encode_get_traffic_images(
16    input: GetTrafficImagesInput,
17) -> Result<http::Request<Vec<u8>>, satay_runtime::Error> {
18    let parts = get_traffic_images_parts(input)?;
19    satay_runtime::into_empty_request(parts)
20}
21pub fn decode_get_traffic_images_response<B: AsRef<[u8]>>(
22    response: satay_runtime::ResponseParts<B>,
23) -> Result<GetTrafficImagesResponse, satay_runtime::Error> {
24    let status = response.status;
25    match status.as_u16() {
26        200 => {
27            let body = response.body;
28            let value = satay_runtime::from_projected_json_slice::<Vec<TrafficImage>>(
29                body.as_ref(),
30                "value",
31                None,
32            )?;
33            Ok(GetTrafficImagesResponse::Ok(value))
34        }
35        _ => {
36            let body = response.body;
37            Ok(GetTrafficImagesResponse::UnexpectedStatus(
38                status,
39                body.as_ref().to_vec(),
40            ))
41        }
42    }
43}