pub enum Macro {
Literal(Box<[u8]>),
Variable {
letter: Variable,
num_parts: u32,
reverse: bool,
escape: bool,
delimiters: u64,
},
List(Box<[Macro]>),
None,
}Expand description
A parsed SPF macro string (RFC 7208, Section 7.1).
Appears as the domain-spec of mechanisms, in the redirect= and exp=
modifiers, and as the explanation text fetched from the exp= target.
Variants§
Literal(Box<[u8]>)
Literal text, copied verbatim.
Variable
A %{...} macro expansion.
Fields
List(Box<[Macro]>)
A concatenation of literals and variables.
None
No macro string was given; Macro::eval returns the supplied default.
Implementations§
Source§impl Macro
impl Macro
Sourcepub fn eval<'z, 'x: 'z>(
&'z self,
vars: &'x Variables<'x>,
default: &'x str,
fqdn: bool,
) -> Cow<'z, str>
pub fn eval<'z, 'x: 'z>( &'z self, vars: &'x Variables<'x>, default: &'x str, fqdn: bool, ) -> Cow<'z, str>
Expands the macro string using vars (RFC 7208, Section 7.3).
Returns default for Macro::None. When fqdn is true, a
trailing . is appended to a list expansion, and to a variable
expansion that applies a transformer, unless it already ends in one.
Literals, and variables expanded verbatim, are returned unchanged.
Invalid UTF-8 expands to an empty string.
Sourcepub fn needs_ptr(&self) -> bool
pub fn needs_ptr(&self) -> bool
Returns true when the macro string references the p macro letter
(Variable::ValidatedDomain).
Trait Implementations§
impl Eq for Macro
impl StructuralPartialEq for Macro
Auto Trait Implementations§
impl Freeze for Macro
impl RefUnwindSafe for Macro
impl Send for Macro
impl Sync for Macro
impl Unpin for Macro
impl UnsafeUnpin for Macro
impl UnwindSafe for Macro
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more