1use crate::PemError;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq)]
9pub enum PemLabel {
10 PrivateKey,
12 EcPrivateKey,
14 PublicKey,
16}
17
18impl PemLabel {
19 pub const fn as_str(self) -> &'static str {
21 match self {
22 Self::PrivateKey => "PRIVATE KEY",
23 Self::EcPrivateKey => "EC PRIVATE KEY",
24 Self::PublicKey => "PUBLIC KEY",
25 }
26 }
27
28 pub(crate) fn parse(input: &str) -> Result<Self, PemError> {
29 match input {
30 "PRIVATE KEY" => Ok(Self::PrivateKey),
31 "EC PRIVATE KEY" => Ok(Self::EcPrivateKey),
32 "PUBLIC KEY" => Ok(Self::PublicKey),
33 _ => Err(PemError::UnsupportedLabel),
34 }
35 }
36}