pub struct Spf<T> { /* private fields */ }Expand description
Base struct for an Spf of any type.
Implementations§
Source§impl Spf<String>
impl Spf<String>
Sourcepub fn new(s: &str) -> Result<Self, SpfError>
pub fn new(s: &str) -> Result<Self, SpfError>
Creates a Spf<String> from the passed str reference.
This is basically a rapper around FromStr which has been implemented for Spf<String>
Sourcepub fn built(&self) -> bool
pub fn built(&self) -> bool
Check if the Spf record was created from crate::SpfBuilder<Builder> or from &str
let spf = "v=spf1 -all".parse::<Spf<String>>().unwrap();
assert!(!spf.built());Sourcepub fn redirect(&self) -> Option<&Mechanism<String>>
pub fn redirect(&self) -> Option<&Mechanism<String>>
Give access to the redirect modifier if present
Sourcepub fn all(&self) -> Option<&Mechanism<String>>
pub fn all(&self) -> Option<&Mechanism<String>>
Give access to the all mechanism if it is present.
Sourcepub fn validate(&self) -> Result<(), SpfErrors>
pub fn validate(&self) -> Result<(), SpfErrors>
Validation for Spf<String>
§Examples
use decon_spf::{Spf, SpfError, SpfErrors};
let spf = "v=spf1 -all".parse::<Spf<String>>().unwrap();
assert!(spf.validate().is_ok());
let spf = "v=spf1 redirect=_spf.example.com -all".parse::<Spf<String>>().unwrap();
assert!(spf.validate().is_err());
let spf: SpfErrors = spf.validate().unwrap_err();
println!("{}", spf.source());
for e in spf.errors() {
println!("{}",e);
}§Returns
Either Ok or a SpfErrors containing any SpfError
§Errors:
- Hard Errors
- Soft Errors
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Spf<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Spf<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl From<Spf<String>> for SpfBuilder<Builder>
Available on crate feature builder only.Converts a Spf<String> into a SpfBuilder`struct.
impl From<Spf<String>> for SpfBuilder<Builder>
Available on crate feature
builder only.Converts a Spf<String> into a SpfBuilder`struct.
Source§impl FromStr for Spf<String>
Implement parse for Spf<String>
impl FromStr for Spf<String>
Implement parse for Spf<String>
Source§impl<T> IntoIterator for Spf<T>
impl<T> IntoIterator for Spf<T>
impl<T> StructuralPartialEq for Spf<T>
Auto Trait Implementations§
impl<T> Freeze for Spf<T>where
T: Freeze,
impl<T> RefUnwindSafe for Spf<T>where
T: RefUnwindSafe,
impl<T> Send for Spf<T>where
T: Send,
impl<T> Sync for Spf<T>where
T: Sync,
impl<T> Unpin for Spf<T>where
T: Unpin,
impl<T> UnwindSafe for Spf<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more