Fix serialization/deserialization of status codes

This commit is contained in:
Xiretza 2024-02-02 15:25:26 +00:00
parent 15d9d21c9b
commit 057b952d11
3 changed files with 15 additions and 1 deletions

12
Cargo.lock generated
View file

@ -177,6 +177,7 @@ dependencies = [
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"serde_repr",
"strum_macros", "strum_macros",
"time", "time",
] ]
@ -733,6 +734,17 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "serde_repr"
version = "0.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b2e6b945e9d3df726b65d6ee24060aff8e3533d431f677a9695db04eff9dfdb"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "serde_urlencoded" name = "serde_urlencoded"
version = "0.7.1" version = "0.7.1"

View file

@ -11,3 +11,4 @@ reqwest = { version = "0.11", features = ["blocking", "json"]}
strum_macros = { version = "0.26.1"} strum_macros = { version = "0.26.1"}
time = { version = "0.3.32", features = ["serde", "serde-well-known"]} time = { version = "0.3.32", features = ["serde", "serde-well-known"]}
serde_json = "1.0.113" serde_json = "1.0.113"
serde_repr = "0.1.18"

View file

@ -1,4 +1,5 @@
use serde::{de::DeserializeOwned, Deserialize, Serialize}; use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use std::net::IpAddr; use std::net::IpAddr;
#[derive(Debug)] #[derive(Debug)]
@ -19,7 +20,7 @@ pub struct FroniousResponse<T> {
body: T, body: T,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize_repr, Deserialize_repr)]
#[repr(u8)] #[repr(u8)]
pub enum StatusCode { pub enum StatusCode {
Okay = 0, Okay = 0,