use crate::error::DatError;
use std::str::FromStr;
use strum_macros::Display;

#[repr(u8)]
#[derive(Debug, Display, Clone, Copy, Eq, PartialEq)]
pub enum SignatureAlgorithm {
    P256,
    P384,
    P521,
}

impl FromStr for SignatureAlgorithm {
    type Err = DatError;
    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s {
            "P256" => Ok(SignatureAlgorithm::P256),
            "P384" => Ok(SignatureAlgorithm::P384),
            "P521" => Ok(SignatureAlgorithm::P521),
            _ => Err(DatError::UnknownDatSignatureAlgorithm),
        }
    }
}
