rustls_cert_file_reader/
format.rs1use std::str::FromStr;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7pub enum Format {
8 PEM,
10 DER,
13}
14
15#[derive(Debug, thiserror::Error)]
17#[error("unknown format: {0}")]
18pub struct FormatParseError(pub String);
19
20impl FromStr for Format {
21 type Err = FormatParseError;
22
23 fn from_str(s: &str) -> Result<Self, Self::Err> {
24 Ok(match s {
25 "pem" => Self::PEM,
26 "der" => Self::DER,
27 other => return Err(FormatParseError(other.to_owned())),
28 })
29 }
30}