Spf

Struct Spf 

Source
pub struct Spf<T> { /* private fields */ }
Expand description

Base struct for an Spf of any type.

Implementations§

Source§

impl Spf<String>

Source

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>

Source

pub fn is_v1(&self) -> bool

Check that version is v1

Source

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());
Source

pub fn redirect(&self) -> Option<&Mechanism<String>>

Give access to the redirect modifier if present

Source

pub fn all(&self) -> Option<&Mechanism<String>>

Give access to the all mechanism if it is present.

Source

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:
Source§

impl<T> Spf<T>
where T: Default + Debug + Display,

Source

pub fn version(&self) -> &T

Access the version attribute associated with the Spf record.

Source

pub fn lookup_count(&self) -> u8

Access the number of DNS lookups required for this Spf record.

Source

pub fn iter(&self) -> SpfIterator<'_, T>

Iterate over the Spf Mechanisms of the Spf Record. This does not return the Spf version, but iterates over the mechanisms contained within the Spf record.

Trait Implementations§

Source§

impl<T: Clone> Clone for Spf<T>

Source§

fn clone(&self) -> Spf<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Spf<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default> Default for Spf<T>

Source§

fn default() -> Spf<T>

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Spf<String>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Spf<String>> for SpfBuilder<Builder>

Available on crate feature builder only.

Converts a Spf<String> into a SpfBuilder`struct.

Source§

fn from(source: Spf<String>) -> SpfBuilder<Builder>

Converts to this type from the input type.
Source§

impl FromStr for Spf<String>

Implement parse for Spf<String>

§Errors

  • Invalid Version
  • String length exceeds 512 octets (characters)

§Soft Errors

These will be found when calling validate() on Spf<String>

Source§

type Err = SpfError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T> IntoIterator for Spf<T>

Source§

type Item = Mechanism<T>

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<<Spf<T> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<T: PartialEq> PartialEq for Spf<T>

Source§

fn eq(&self, other: &Spf<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T> Serialize for Spf<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&str> for Spf<String>

Source§

type Error = SpfError

The type returned in the event of a conversion error.
Source§

fn try_from(s: &str) -> Result<Self, Self::Error>

Performs the conversion.
Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,