pub struct Variables<'x> { /* private fields */ }Expand description
The values substituted for each Variable during macro expansion
(RFC 7208, Section 7).
MessageAuthenticator::check_host
fills it from its SpfParameters; it can also be
built with Variables::new and the set_* methods to expand a
Macro with Macro::eval.
Implementations§
Source§impl<'x> Variables<'x>
impl<'x> Variables<'x>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates an empty set of variables. The t macro
(Variable::CurrentTime) expands to the current time unless it is
set explicitly.
Sourcepub fn set_ip(&mut self, value: &IpAddr)
pub fn set_ip(&mut self, value: &IpAddr)
Sets the i, v and c macros from the client IP address.
Sourcepub fn set_sender(&mut self, value: impl Into<Cow<'x, [u8]>>)
pub fn set_sender(&mut self, value: impl Into<Cow<'x, [u8]>>)
Sets the s macro and, when the value contains @, the l (local
part) and o (domain) macros.
Sourcepub fn set_helo_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
pub fn set_helo_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
Sets the h macro (HELO or EHLO domain).
Sourcepub fn set_host_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
pub fn set_host_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
Sets the r macro (domain name of the host performing the check).
Sourcepub fn set_validated_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
pub fn set_validated_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
Sets the p macro (validated domain name of the client IP).
Sourcepub fn set_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
pub fn set_domain(&mut self, value: impl Into<Cow<'x, [u8]>>)
Sets the d macro (the domain being evaluated).
Sourcepub fn get(
&self,
name: Variable,
num_parts: u32,
reverse: bool,
escape: bool,
fqdn: bool,
delimiters: u64,
) -> Cow<'_, [u8]>
pub fn get( &self, name: Variable, num_parts: u32, reverse: bool, escape: bool, fqdn: bool, delimiters: u64, ) -> Cow<'_, [u8]>
Returns the value of the variable name after applying the macro
transformers (RFC 7208, Section 7.3).
The value is split on the characters in the delimiters bitmask (bit
n stands for the byte b'+' + n), reversed when reverse is set,
truncated to the num_parts right-hand parts (0 keeps all), joined
with . and URL-encoded when escape is set. When fqdn is true
and at least one transformer applies, a trailing . is added; a value
without transformers is returned verbatim.
Trait Implementations§
impl<'x> Eq for Variables<'x>
impl<'x> StructuralPartialEq for Variables<'x>
Auto Trait Implementations§
impl<'x> Freeze for Variables<'x>
impl<'x> RefUnwindSafe for Variables<'x>
impl<'x> Send for Variables<'x>
impl<'x> Sync for Variables<'x>
impl<'x> Unpin for Variables<'x>
impl<'x> UnsafeUnpin for Variables<'x>
impl<'x> UnwindSafe for Variables<'x>
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