[−][src]Crate gmailnator
This library contains objects to create a gmailnator inbox and read the messages it contains.
Getting started :
The main struct is the GmailnatorInbox struct, one instance contains one inbox associated to an email address.
This creates a new temporary gmail address :
use gmailnator::GmailnatorInbox; let inbox = GmailnatorInbox::new().unwrap();
To get the associated mail address :
let address:&str = inbox.get_address();
This creates n number of addresses, it must be used to create a large number of inboxes.
use gmailnator::GmailnatorInbox; let n:u32 = 500; let inboxes:Vec<GmailnatorInbox> = GmailnatorInbox::new_bulk(n).unwrap(); assert_eq!(inboxes.len() as u32, n);
To retrieve messages and display them via the container struct MailMessage:
This method requests every message's subject & body, if you don't necessarily need every message in the inbox : consider using get_messages_iter() to save resources.
use gmailnator::{GmailnatorInbox, MailMessage}; let messages:Vec<MailMessage> = inbox.get_messages().unwrap(); for message in messages { let title = message.get_subject(); let raw_body = message.get_raw_content(); let decoded_body = message.decode_content().unwrap(); // raw_body = <You> Where did you put the "thing" ? // decoded_body = <You> Where did you put the "thing" ? println!("Title : {}\nBody : {}", title, decoded_body); }
To search for a particular message, use the MailMessageIterator :
use gmailnator::{GmailnatorInbox, MailMessage, MailMessageIterator}; let mut messages_iter:MailMessageIterator = inbox.get_messages_iter().unwrap(); let find_result = messages_iter.find(|m| m.get_subject() == "Confirm your order"); if let Some(confirmation_message) = find_result { //Confirm your order :) }
Structs
| GmailnatorInbox | The library's main object, when instantiated represents a gmailnator inbox associated to an e-mail address. |
| MailMessage | A structure that contains an e-mail subject and its content under two forms : raw, and html decoded. |
| MailMessageIterator |
|
Enums
| GmailnatorError | Default error enum for the crate, containing all the potential errors. |
Type Definitions
| Error | Default error for the crate. |