refactor(imap): move list_folders() to Session

This commit is contained in:
link2xt
2024-02-28 21:40:22 +00:00
parent 08a30031eb
commit d4a505b52e
3 changed files with 12 additions and 15 deletions

View File

@@ -1,7 +1,9 @@
use std::ops::{Deref, DerefMut};
use anyhow::Result;
use async_imap::types::Mailbox;
use async_imap::Session as ImapSession;
use futures::TryStreamExt;
use crate::imap::capabilities::Capabilities;
use crate::net::session::SessionStream;
@@ -68,4 +70,10 @@ impl Session {
pub fn can_metadata(&self) -> bool {
self.capabilities.can_metadata
}
/// Returns the names of all folders on the IMAP server.
pub async fn list_folders(&mut self) -> Result<Vec<async_imap::types::Name>> {
let list = self.list(Some(""), Some("*")).await?.try_collect().await?;
Ok(list)
}
}