oxedyne/fe2o3/fe2o3_mail/src/sync/imap.rs
2.9 KiB, 19 runs
created by r1870400018:75205, which is this file's identity for as long as the history lasts, whatever it is later renamed to
download · who wrote it · its history
| 1 | //! [`MailSession`] over [`ImapClient`] on any [`LineIo`]: the tokio socket in the gateway, the |
| 2 | //! tunnel's bytes in a browser, with no adapter of either's own. |
| 3 | |
| 4 | use crate::sync::{ |
| 5 | AppendUid, |
| 6 | CopyUid, |
| 7 | FetchChanged, |
| 8 | FetchWhat, |
| 9 | FetchedMessage, |
| 10 | MailSession, |
| 11 | MailboxInfo, |
| 12 | MailboxStatus, |
| 13 | Segment, |
| 14 | SelectWith, |
| 15 | UidSet, |
| 16 | }; |
| 17 | |
| 18 | use oxedyne_fe2o3_core::prelude::*; |
| 19 | use oxedyne_fe2o3_net::{ |
| 20 | imap::client::ImapClient, |
| 21 | lineio::LineIo, |
| 22 | }; |
| 23 | |
| 24 | |
| 25 | impl<I: LineIo> MailSession for ImapClient<I> { |
| 26 | async fn capabilities(&mut self) -> Outcome<Vec<String>> { |
| 27 | Ok(res!(self.capability().await).to_vec()) |
| 28 | } |
| 29 | |
| 30 | async fn list(&mut self) -> Outcome<Vec<MailboxInfo>> { |
| 31 | ImapClient::list(self, "", "*").await |
| 32 | } |
| 33 | |
| 34 | async fn create(&mut self, mailbox: &str) -> Outcome<()> { |
| 35 | ImapClient::create(self, mailbox).await |
| 36 | } |
| 37 | |
| 38 | async fn select(&mut self, mailbox: &str, with: &SelectWith) -> Outcome<MailboxStatus> { |
| 39 | self.select_with(mailbox, with).await |
| 40 | } |
| 41 | |
| 42 | async fn examine(&mut self, mailbox: &str, with: &SelectWith) -> Outcome<MailboxStatus> { |
| 43 | self.examine_with(mailbox, with).await |
| 44 | } |
| 45 | |
| 46 | async fn uid_fetch(&mut self, uids: &UidSet, what: FetchWhat) -> Outcome<Vec<FetchedMessage>> { |
| 47 | ImapClient::uid_fetch(self, uids, what).await |
| 48 | } |
| 49 | |
| 50 | async fn uid_fetch_changed(&mut self, uids: &UidSet, what: FetchWhat, modseq: u64) |
| 51 | -> Outcome<FetchChanged> |
| 52 | { |
| 53 | ImapClient::uid_fetch_changed(self, uids, what, modseq).await |
| 54 | } |
| 55 | |
| 56 | async fn uid_search(&mut self, criteria: &str) -> Outcome<Vec<u32>> { |
| 57 | ImapClient::uid_search(self, criteria).await |
| 58 | } |
| 59 | |
| 60 | async fn uid_search_key(&mut self, args: &[Segment]) -> Outcome<Vec<u32>> { |
| 61 | ImapClient::uid_search_key(self, args).await |
| 62 | } |
| 63 | |
| 64 | async fn uid_fetch_section(&mut self, uid: u32, section: &str, max: u32) |
| 65 | -> Outcome<Option<FetchedMessage>> |
| 66 | { |
| 67 | ImapClient::uid_fetch_section(self, uid, section, max).await |
| 68 | } |
| 69 | |
| 70 | fn read_bytes(&self) -> u64 { |
| 71 | ImapClient::read_bytes(self) |
| 72 | } |
| 73 | |
| 74 | async fn count(&mut self, mailbox: &str) -> Outcome<u32> { |
| 75 | Ok(res!(ImapClient::status(self, mailbox).await).messages) |
| 76 | } |
| 77 | |
| 78 | async fn uid_store_flags(&mut self, uids: &UidSet, add: &[&str], remove: &[&str]) -> Outcome<()> { |
| 79 | ImapClient::uid_store_flags(self, uids, add, remove).await |
| 80 | } |
| 81 | |
| 82 | async fn uid_copy(&mut self, uids: &UidSet, to: &str) -> Outcome<Option<CopyUid>> { |
| 83 | ImapClient::uid_copy(self, uids, to).await |
| 84 | } |
| 85 | |
| 86 | async fn uid_move(&mut self, uids: &UidSet, to: &str) -> Outcome<Option<CopyUid>> { |
| 87 | ImapClient::uid_move(self, uids, to).await |
| 88 | } |
| 89 | |
| 90 | async fn uid_expunge(&mut self, uids: &UidSet) -> Outcome<()> { |
| 91 | ImapClient::uid_expunge(self, uids).await |
| 92 | } |
| 93 | |
| 94 | async fn append(&mut self, mailbox: &str, flags: &[&str], raw: &[u8]) -> Outcome<Option<AppendUid>> { |
| 95 | ImapClient::append(self, mailbox, flags, raw).await |
| 96 | } |
| 97 | } |