valorant_api 0.3.14

A library for interacting with the ingame Valorant-API.
Documentation
use std::fmt::Display;
use std::str::FromStr;

use serde::{Deserialize, Serialize};

#[derive(Serialize, Deserialize, Debug, PartialEq, Eq, Hash, Clone, Copy)]
pub enum Site {
    A,
    B,
    C,
}

impl Display for Site {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Site::A => write!(f, "A"),
            Site::B => write!(f, "B"),
            Site::C => write!(f, "C"),
        }
    }
}

impl FromStr for Site {
    type Err = String;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "A" => Ok(Site::A),
            "B" => Ok(Site::B),
            "C" => Ok(Site::C),
            _ => Err(format!("{s} is not a valid site")),
        }
    }
}