Firehose API wrapper in Rust/Go

Hello, some years ago I had access to firehose and wrote a #golang wrapper (GitHub - keltia/flightaware-go: Quick conversion of a barebone Flightaware client & API from Ruby to Go.). Now, I’m back to working with it and am looking to implement another API wrapper but now in #Rust.

In Go, I didn’t really care about the various field types and used String everywhere. I’d like to avoid doing the same in Rust as it has more interesting possibilties through the serde & serde_json crates.

Has anyone already worked in that direction or should I develop my own stuff anyway? I’d rather label my fields with the proper type (i32 for timestamps or an enum for orig) instead of wrapping everything as a string.

BTW the inconsistency in naming fields is a bit annoying as well to be honest (timeType vs facility_name).

Any idea?
Thanks.

Found the serde_with crate to deal with this. Every non-string field is using its own type and serde_as does the conversion as needed.

use serde_with::{serde_as, DisplayFromStr};

#[serde_as]
#[derive(Debug, Deserialize)]
pub struct Keepalive {
    /// PITR resume value
    #[serde_as(as = "DisplayFromStr")]
    pub pitr: i32,
    /// Time of keepalive generation
    #[serde(rename = "serverTime")]
    #[serde_as(as = "DisplayFromStr")]
    pub server_time: i32,
    /// Message Type ("keepalive")
    #[serde(rename = "type")]
    pub ktype: String,
}