use crate::PemError;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum PemLabel {
PrivateKey,
EcPrivateKey,
PublicKey,
}
impl PemLabel {
pub const fn as_str(self) -> &'static str {
match self {
Self::PrivateKey => "PRIVATE KEY",
Self::EcPrivateKey => "EC PRIVATE KEY",
Self::PublicKey => "PUBLIC KEY",
}
}
pub(crate) fn parse(input: &str) -> Result<Self, PemError> {
match input {
"PRIVATE KEY" => Ok(Self::PrivateKey),
"EC PRIVATE KEY" => Ok(Self::EcPrivateKey),
"PUBLIC KEY" => Ok(Self::PublicKey),
_ => Err(PemError::UnsupportedLabel),
}
}
}