valorant_api_official 0.2.2

A library for interacting with the Official Valorant API.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::str::FromStr;

use serde::{Deserialize, Deserializer};
use uuid::Uuid;

pub(crate) fn valid_uuid<'de, D: Deserializer<'de>>(d: D) -> Result<Option<Uuid>, D::Error> {
    let o: Option<String> = Option::deserialize(d)?;
    Ok(o.and_then(|s| Uuid::parse_str(&s).ok()))
}

pub(crate) fn valid_enum<'de, T: FromStr, D: Deserializer<'de>>(
    d: D,
) -> Result<Option<T>, D::Error> {
    let o: Option<String> = Option::deserialize(d)?;
    Ok(o.and_then(|s| T::from_str(&s).ok()))
}