dayuploads can now be int too

This commit is contained in:
LordMZTE 2020-11-11 16:16:26 +01:00
parent 12f359a6da
commit 7eb40439b0

View file

@ -1,6 +1,8 @@
use serde::de::{Error, Unexpected, Visitor};
use core::fmt::Formatter;
use serde::{Deserialize, Deserializer};
use std::convert::TryInto;
#[derive(Deserialize, Debug)]
pub struct UserResponse {
pub status: u16,
@ -36,6 +38,14 @@ where
{
v.parse().map_err(|_| E::invalid_type(Unexpected::Str(v), &"a u32"))
}
/// implementing u64 instead of 32 because it is used as fallback
fn visit_u64<E>(self, v: u64) -> Result<Self::Value, E>
where
E: Error,
{
v.try_into().map_err(|_| E::invalid_type(Unexpected::Unsigned(v), &"a u32"))
}
}
de.deserialize_str(Vis)