pub struct SpfRecord { /* private fields */ }Expand description
SPF record metadata.
Implementations§
Source§impl SpfRecord
impl SpfRecord
Sourcepub const fn new() -> SpfRecord
pub const fn new() -> SpfRecord
Creates an empty SPF v1 record.
Examples found in repository?
examples/email_facade_basic_usage.rs (line 15)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let mailbox = address::Mailbox::new(Some("Jane Doe"), "jane@example.com")?;
5 let message_id: id::MessageId = "welcome@example.com".parse()?;
6 let message = message::EmailMessage::plain_text("Welcome", "A short note.")
7 .with_header("From", mailbox.to_string())?;
8 let envelope = envelope::Envelope::new(envelope::EnvelopeSender::new("bounce@example.com")?)
9 .with_recipient(envelope::EnvelopeRecipient::new("jane@example.com")?);
10 let mailto_uri = mailto::MailtoBuilder::new()
11 .to("jane@example.com")?
12 .subject("Welcome")
13 .build();
14 let reply = smtp::SmtpReply::new(smtp::SmtpReplyCode::new(250)?, "OK")?;
15 let spf = auth::spf::SpfRecord::new().with_term(auth::spf::SpfTerm::new(
16 auth::spf::SpfQualifier::Fail,
17 auth::spf::SpfMechanism::All,
18 ));
19
20 assert_eq!(message.subject(), Some("Welcome"));
21 assert_eq!(message_id.to_string(), "<welcome@example.com>");
22 assert_eq!(envelope.recipients().len(), 1);
23 assert_eq!(
24 mailto_uri.to_string(),
25 "mailto:jane@example.com?subject=Welcome"
26 );
27 assert_eq!(reply.to_string(), "250 OK");
28 assert_eq!(spf.to_string(), "v=spf1 -all");
29
30 Ok(())
31}Sourcepub fn with_term(self, term: SpfTerm) -> SpfRecord
pub fn with_term(self, term: SpfTerm) -> SpfRecord
Adds a term and returns the updated record.
Examples found in repository?
examples/email_facade_basic_usage.rs (lines 15-18)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let mailbox = address::Mailbox::new(Some("Jane Doe"), "jane@example.com")?;
5 let message_id: id::MessageId = "welcome@example.com".parse()?;
6 let message = message::EmailMessage::plain_text("Welcome", "A short note.")
7 .with_header("From", mailbox.to_string())?;
8 let envelope = envelope::Envelope::new(envelope::EnvelopeSender::new("bounce@example.com")?)
9 .with_recipient(envelope::EnvelopeRecipient::new("jane@example.com")?);
10 let mailto_uri = mailto::MailtoBuilder::new()
11 .to("jane@example.com")?
12 .subject("Welcome")
13 .build();
14 let reply = smtp::SmtpReply::new(smtp::SmtpReplyCode::new(250)?, "OK")?;
15 let spf = auth::spf::SpfRecord::new().with_term(auth::spf::SpfTerm::new(
16 auth::spf::SpfQualifier::Fail,
17 auth::spf::SpfMechanism::All,
18 ));
19
20 assert_eq!(message.subject(), Some("Welcome"));
21 assert_eq!(message_id.to_string(), "<welcome@example.com>");
22 assert_eq!(envelope.recipients().len(), 1);
23 assert_eq!(
24 mailto_uri.to_string(),
25 "mailto:jane@example.com?subject=Welcome"
26 );
27 assert_eq!(reply.to_string(), "250 OK");
28 assert_eq!(spf.to_string(), "v=spf1 -all");
29
30 Ok(())
31}Sourcepub fn with_modifier(self, modifier: SpfModifier) -> SpfRecord
pub fn with_modifier(self, modifier: SpfModifier) -> SpfRecord
Adds a modifier and returns the updated record.
Sourcepub const fn version(&self) -> SpfVersion
pub const fn version(&self) -> SpfVersion
Returns the version.
Sourcepub fn modifiers(&self) -> &[SpfModifier]
pub fn modifiers(&self) -> &[SpfModifier]
Returns modifiers.
Trait Implementations§
impl Eq for SpfRecord
impl StructuralPartialEq for SpfRecord
Auto Trait Implementations§
impl Freeze for SpfRecord
impl RefUnwindSafe for SpfRecord
impl Send for SpfRecord
impl Sync for SpfRecord
impl Unpin for SpfRecord
impl UnsafeUnpin for SpfRecord
impl UnwindSafe for SpfRecord
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