dat 1.1.0

DAT - Data Access Token
Documentation
use crate::error::DatError;

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

impl SignatureAlgorithm {
    pub fn to_str(&self) -> &'static str {
        match self {
            SignatureAlgorithm::P256 => "P256",
            SignatureAlgorithm::P384 => "P384",
            SignatureAlgorithm::P521 => "P521",
        }
    }
    pub fn from_str(s: &str) -> Result<SignatureAlgorithm, DatError> {
        match s {
            "P256" => Ok(SignatureAlgorithm::P256),
            "P384" => Ok(SignatureAlgorithm::P384),
            "P521" => Ok(SignatureAlgorithm::P521),
            _ => Err(DatError::UnknownSignAlgorithm),
        }
    }
}