0.2.1 |
|
---|---|
0.2.0 |
|
0.1.5 |
|
#15 in #gmail
24KB
398 lines
Please refer to the documentation at docs.rs for up to date examples.
lib.rs
:
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);
Retrieve messages in a vector and display them via the container struct MailMessage
:
use gmailnator::{GmailnatorInbox, MailMessage};
let messages:Vec<MailMessage> = inbox.get_messages_iter().unwrap().collect();
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 :)
}
Dependencies
~9–16MB
~215K SLoC