feat: initial API and docs

This commit is contained in:
Ninjdai 2025-07-30 16:55:07 +02:00
parent 79be4eb543
commit 5d709d658b
16 changed files with 3169 additions and 342 deletions

16
src/utils/serde.rs Normal file
View file

@ -0,0 +1,16 @@
use serde::{de, Deserialize, Deserializer};
use std::{fmt, str::FromStr};
pub fn empty_string_as_none<'de, D, T>(de: D) -> Result<Option<T>, D::Error>
where
D: Deserializer<'de>,
T: FromStr,
T::Err: fmt::Display,
{
let opt = Option::<String>::deserialize(de)?;
match opt.as_deref() {
None | Some("") => Ok(None),
Some(s) => FromStr::from_str(s).map_err(de::Error::custom).map(Some),
}
}