pub struct SpfBuilder { /* private fields */ }builder only.Expand description
The definition of the SpfBuilder struct which contains all information related a single SPF record.
Implementations§
Source§impl SpfBuilder
impl SpfBuilder
Source§impl SpfBuilder
impl SpfBuilder
Sourcepub fn set_v2_pra(&mut self) -> &mut Self
Available on crate feature spf2 only.
pub fn set_v2_pra(&mut self) -> &mut Self
spf2 only.Set version to spf2.0/pra
Sourcepub fn set_v2_mfrom(&mut self) -> &mut Self
Available on crate feature spf2 only.
pub fn set_v2_mfrom(&mut self) -> &mut Self
spf2 only.Set version to spf2.0/mfrom
Sourcepub fn set_v2_pra_mfrom(&mut self) -> &mut Self
Available on crate feature spf2 only.
pub fn set_v2_pra_mfrom(&mut self) -> &mut Self
spf2 only.Set version to spf2.0/pra,mfrom
Sourcepub fn set_v2_mfrom_pra(&mut self) -> &mut Self
Available on crate feature spf2 only.
pub fn set_v2_mfrom_pra(&mut self) -> &mut Self
spf2 only.Set version to spf2.0/mfrom,pra
Source§impl SpfBuilder
impl SpfBuilder
Sourcepub fn clear_mechanism(&mut self, kind: Kind)
pub fn clear_mechanism(&mut self, kind: Kind)
Clear the passed Kind which has been passed.
Sets the passed mechanism to None
§Note:
This method clears all associated Mechanism for the Kind provided.
§Example:
use decon_spf::mechanism::{Qualifier, Kind, Mechanism};
use decon_spf::SpfBuilder;
let mut spf = SpfBuilder::new();
spf.set_v1();
spf.append_mechanism(Mechanism::all_with_qualifier(Qualifier::Pass));
spf.append_mechanism(Mechanism::a(Qualifier::Pass));
spf.append_mechanism(Mechanism::ip(Qualifier::Pass,
"203.32.160.0/23".parse().unwrap()));
// Remove ip4 Mechanism
spf.clear_mechanism(Kind::IpV4);Sourcepub fn append_mechanism<T>(&mut self, mechanism: Mechanism<T>) -> &mut Selfwhere
Self: Append<T>,
pub fn append_mechanism<T>(&mut self, mechanism: Mechanism<T>) -> &mut Selfwhere
Self: Append<T>,
use decon_spf::mechanism::{Qualifier, Mechanism};
use decon_spf::SpfBuilder;
let mut spf = SpfBuilder::new();
spf.set_v1();
spf.append_mechanism(Mechanism::redirect(Qualifier::Pass,
"_spf.example.com").unwrap())
.append_mechanism(Mechanism::all_with_qualifier(Qualifier::Pass));
assert!(spf.all().is_none());§Note
When Redirect is present, All will be set to None.
Sourcepub fn is_redirect(&self) -> bool
pub fn is_redirect(&self) -> bool
True if there is a redirect present in the spf record.
Sourcepub fn redirect(&self) -> Option<&Mechanism<String>>
pub fn redirect(&self) -> Option<&Mechanism<String>>
Returns a reference to the Redirect Mechanism
Sourcepub fn includes(&self) -> Option<&Vec<Mechanism<String>>>
pub fn includes(&self) -> Option<&Vec<Mechanism<String>>>
Returns a reference to the a Vec of Mechanism<String> for Include
Sourcepub fn a(&self) -> Option<&Vec<Mechanism<String>>>
pub fn a(&self) -> Option<&Vec<Mechanism<String>>>
Returns a reference to a Vec of Mechanism<String> for A
Sourcepub fn mx(&self) -> Option<&Vec<Mechanism<String>>>
pub fn mx(&self) -> Option<&Vec<Mechanism<String>>>
Returns a reference to a Vec of Mechanism<String> for MX
Sourcepub fn ip4(&self) -> Option<&Vec<Mechanism<IpNetwork>>>
pub fn ip4(&self) -> Option<&Vec<Mechanism<IpNetwork>>>
Returns a reference to a Vec of Mechanism<IpNetwork> for IP4
Sourcepub fn ip6(&self) -> Option<&Vec<Mechanism<IpNetwork>>>
pub fn ip6(&self) -> Option<&Vec<Mechanism<IpNetwork>>>
Returns a reference to a Vec of Mechanism<IpNetwork> for IP6
Sourcepub fn exists(&self) -> Option<&Vec<Mechanism<String>>>
pub fn exists(&self) -> Option<&Vec<Mechanism<String>>>
Returns a reference to a Vec of Mechanism<String> for Exists
Trait Implementations§
Source§impl Clone for SpfBuilder
impl Clone for SpfBuilder
Source§fn clone(&self) -> SpfBuilder
fn clone(&self) -> SpfBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SpfBuilder
impl Debug for SpfBuilder
Source§impl Default for SpfBuilder
impl Default for SpfBuilder
Source§fn default() -> SpfBuilder
fn default() -> SpfBuilder
Source§impl<'de> Deserialize<'de> for SpfBuilder
impl<'de> Deserialize<'de> for SpfBuilder
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>,
Source§impl Display for SpfBuilder
impl Display for SpfBuilder
Source§impl FromStr for SpfBuilder
impl FromStr for SpfBuilder
Creates an SpfBuilder struct by parsing a string representation of Spf.
§Examples:
use decon_spf::SpfBuilder;
use decon_spf::SpfError;
// Successful
let input = "v=spf1 a mx -all";
let spf: SpfBuilder = input.parse().unwrap();
assert_eq!(spf.to_string(), input);
// Additional Space between `A` and `MX`
let invalid_input = "v=spf1 a mx -all";
let err: SpfError = invalid_input.parse::<SpfBuilder>().unwrap_err();
assert_eq!(err, SpfError::WhiteSpaceSyntaxError);
// err.to_string() -> "Spf contains two or more consecutive whitespace characters.");