use super::{ContentType, DeletionRecoveryLevel};
use std::{
convert::{AsRef, From, Infallible},
fmt::{Display, Formatter},
str::FromStr,
};
impl<'a> From<&'a ContentType> for &'a str {
fn from(e: &'a ContentType) -> Self {
match e {
ContentType::Pem => "application/x-pem-file",
ContentType::Pfx => "application/x-pkcs12",
ContentType::UnknownValue(s) => s.as_ref(),
}
}
}
impl FromStr for ContentType {
type Err = Infallible;
fn from_str(s: &str) -> ::core::result::Result<Self, <Self as FromStr>::Err> {
Ok(match s {
"application/x-pem-file" => ContentType::Pem,
"application/x-pkcs12" => ContentType::Pfx,
_ => ContentType::UnknownValue(s.to_string()),
})
}
}
impl AsRef<str> for ContentType {
fn as_ref(&self) -> &str {
match self {
ContentType::Pem => "application/x-pem-file",
ContentType::Pfx => "application/x-pkcs12",
ContentType::UnknownValue(s) => s.as_str(),
}
}
}
impl Display for ContentType {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
match self {
ContentType::Pem => f.write_str("application/x-pem-file"),
ContentType::Pfx => f.write_str("application/x-pkcs12"),
ContentType::UnknownValue(s) => f.write_str(s.as_str()),
}
}
}
impl<'a> From<&'a DeletionRecoveryLevel> for &'a str {
fn from(e: &'a DeletionRecoveryLevel) -> Self {
match e {
DeletionRecoveryLevel::CustomizedRecoverable => "CustomizedRecoverable",
DeletionRecoveryLevel::CustomizedRecoverableProtectedSubscription => {
"CustomizedRecoverable+ProtectedSubscription"
}
DeletionRecoveryLevel::CustomizedRecoverablePurgeable => {
"CustomizedRecoverable+Purgeable"
}
DeletionRecoveryLevel::Purgeable => "Purgeable",
DeletionRecoveryLevel::Recoverable => "Recoverable",
DeletionRecoveryLevel::RecoverableProtectedSubscription => {
"Recoverable+ProtectedSubscription"
}
DeletionRecoveryLevel::RecoverablePurgeable => "Recoverable+Purgeable",
DeletionRecoveryLevel::UnknownValue(s) => s.as_ref(),
}
}
}
impl FromStr for DeletionRecoveryLevel {
type Err = Infallible;
fn from_str(s: &str) -> ::core::result::Result<Self, <Self as FromStr>::Err> {
Ok(match s {
"CustomizedRecoverable" => DeletionRecoveryLevel::CustomizedRecoverable,
"CustomizedRecoverable+ProtectedSubscription" => {
DeletionRecoveryLevel::CustomizedRecoverableProtectedSubscription
}
"CustomizedRecoverable+Purgeable" => {
DeletionRecoveryLevel::CustomizedRecoverablePurgeable
}
"Purgeable" => DeletionRecoveryLevel::Purgeable,
"Recoverable" => DeletionRecoveryLevel::Recoverable,
"Recoverable+ProtectedSubscription" => {
DeletionRecoveryLevel::RecoverableProtectedSubscription
}
"Recoverable+Purgeable" => DeletionRecoveryLevel::RecoverablePurgeable,
_ => DeletionRecoveryLevel::UnknownValue(s.to_string()),
})
}
}
impl AsRef<str> for DeletionRecoveryLevel {
fn as_ref(&self) -> &str {
match self {
DeletionRecoveryLevel::CustomizedRecoverable => "CustomizedRecoverable",
DeletionRecoveryLevel::CustomizedRecoverableProtectedSubscription => {
"CustomizedRecoverable+ProtectedSubscription"
}
DeletionRecoveryLevel::CustomizedRecoverablePurgeable => {
"CustomizedRecoverable+Purgeable"
}
DeletionRecoveryLevel::Purgeable => "Purgeable",
DeletionRecoveryLevel::Recoverable => "Recoverable",
DeletionRecoveryLevel::RecoverableProtectedSubscription => {
"Recoverable+ProtectedSubscription"
}
DeletionRecoveryLevel::RecoverablePurgeable => "Recoverable+Purgeable",
DeletionRecoveryLevel::UnknownValue(s) => s.as_str(),
}
}
}
impl Display for DeletionRecoveryLevel {
fn fmt(&self, f: &mut Formatter<'_>) -> ::std::fmt::Result {
match self {
DeletionRecoveryLevel::CustomizedRecoverable => f.write_str("CustomizedRecoverable"),
DeletionRecoveryLevel::CustomizedRecoverableProtectedSubscription => {
f.write_str("CustomizedRecoverable+ProtectedSubscription")
}
DeletionRecoveryLevel::CustomizedRecoverablePurgeable => {
f.write_str("CustomizedRecoverable+Purgeable")
}
DeletionRecoveryLevel::Purgeable => f.write_str("Purgeable"),
DeletionRecoveryLevel::Recoverable => f.write_str("Recoverable"),
DeletionRecoveryLevel::RecoverableProtectedSubscription => {
f.write_str("Recoverable+ProtectedSubscription")
}
DeletionRecoveryLevel::RecoverablePurgeable => f.write_str("Recoverable+Purgeable"),
DeletionRecoveryLevel::UnknownValue(s) => f.write_str(s.as_str()),
}
}
}