1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! A small library to poll mails from tutanota and possibly decrypt sender name, subject and body and mark them as read.
//!
//! ## Overview
//! The library provides a high level client with the option to connect to a websocket to listen for new messages as well as a wrapper for the undocumented tuta api.
//! The library can also decrypt sender name, subject and message body.
//!
//! ## Usage
//!
//! ### Config and Client
//!
//! ```ignore
//! let config = tuta_poll::config::Account {
//! "...@tuta.com",
//! "some_password",
//! watch_spam: true,
//! show_name: true,
//! show_subject: true,
//! show_body: true,
//! };
//!
//! let client = tuta_poll::client::Client::new(&config).await?;
//! ```
//!
//! ### Get messages
//! ```ignore
//! use futures_util::pin_mut;
//! use futures_util::StreamExt;
//!
//! let mails = client.get_mails();
//! pin_mut!(mails);
//! while let Some(mail) = mails.next().await {
//! let mut mail = mail?;
//! let decrypted_mail = client.decrypt(&mail).await;
//! }
//! ```
//! ### Connect to websocket
//!
//! ```ignore
//! let connector = client.get_websocket_connector()?;
//!
//! loop {
//! let mut socket = connector.connect()?;
//! while let Ok(has_new) = socket.has_new().await {
//! if !has_new {
//! continue;
//! }
//! let mails = client.get_mails();
//! }
//! }
//! ```