Skip to content

Commit

Permalink
feat: Implement FromStr for AuthMechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
duesee committed Dec 19, 2023
1 parent 91c801e commit 032c61e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions imap-types/src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::{
borrow::Cow,
fmt::{Display, Formatter},
str::FromStr,
};

#[cfg(feature = "arbitrary")]
Expand All @@ -14,6 +15,7 @@ use serde::{Deserialize, Serialize};

use crate::{
core::{impl_try_from, Atom},
error::ValidationError,
secret::Secret,
};

Expand Down Expand Up @@ -143,6 +145,14 @@ impl<'a> AsRef<str> for AuthMechanism<'a> {
}
}

impl FromStr for AuthMechanism<'static> {
type Err = ValidationError;

fn from_str(s: &str) -> Result<Self, Self::Err> {
AuthMechanism::try_from(s.to_string())
}
}

/// An (unknown) authentication mechanism.
///
/// It's guaranteed that this type can't represent any mechanism from [`AuthMechanism`].
Expand Down

0 comments on commit 032c61e

Please sign in to comment.