mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 15:06:30 +03:00
refactor: upgrade to Rust 2024
This commit is contained in:
@@ -5,8 +5,8 @@ use async_channel::Receiver;
|
||||
use async_imap::extensions::idle::IdleResponse;
|
||||
use tokio::time::timeout;
|
||||
|
||||
use super::session::Session;
|
||||
use super::Imap;
|
||||
use super::session::Session;
|
||||
use crate::context::Context;
|
||||
use crate::log::{info, warn};
|
||||
use crate::net::TIMEOUT;
|
||||
|
||||
@@ -111,7 +111,9 @@ async fn check_target_folder_combination(
|
||||
outgoing: bool,
|
||||
setupmessage: bool,
|
||||
) -> Result<()> {
|
||||
println!("Testing: For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}");
|
||||
println!(
|
||||
"Testing: For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}"
|
||||
);
|
||||
|
||||
let t = TestContext::new_alice().await;
|
||||
t.ctx
|
||||
@@ -166,7 +168,11 @@ async fn check_target_folder_combination(
|
||||
} else {
|
||||
Some(expected_destination)
|
||||
};
|
||||
assert_eq!(expected, actual.as_deref(), "For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}: expected {expected:?}, got {actual:?}");
|
||||
assert_eq!(
|
||||
expected,
|
||||
actual.as_deref(),
|
||||
"For folder {folder}, mvbox_move {mvbox_move}, chat_msg {chat_msg}, accepted {accepted_chat}, outgoing {outgoing}, setupmessage {setupmessage}: expected {expected:?}, got {actual:?}"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ use anyhow::{Context as _, Result};
|
||||
|
||||
use super::{get_folder_meaning_by_attrs, get_folder_meaning_by_name};
|
||||
use crate::config::Config;
|
||||
use crate::imap::{session::Session, Imap};
|
||||
use crate::log::{info, LogExt};
|
||||
use crate::imap::{Imap, session::Session};
|
||||
use crate::log::{LogExt, info};
|
||||
use crate::tools::{self, time_elapsed};
|
||||
use crate::{context::Context, imap::FolderMeaning};
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum Error {
|
||||
#[error("Got a NO response when trying to select {0}, usually this means that it doesn't exist: {1}")]
|
||||
#[error(
|
||||
"Got a NO response when trying to select {0}, usually this means that it doesn't exist: {1}"
|
||||
)]
|
||||
NoFolder(String, String),
|
||||
|
||||
#[error("IMAP other error: {0}")]
|
||||
@@ -139,7 +141,7 @@ impl ImapSession {
|
||||
Error::NoFolder(..) => return Ok(false),
|
||||
_ => {
|
||||
return Err(err)
|
||||
.with_context(|| format!("Failed to select folder {folder:?}"))?
|
||||
.with_context(|| format!("Failed to select folder {folder:?}"))?;
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -210,7 +212,10 @@ impl ImapSession {
|
||||
// If UIDNEXT changed, there are new emails.
|
||||
self.new_mail |= new_uid_next != old_uid_next;
|
||||
} else {
|
||||
warn!(context, "Folder {folder} was just selected but we failed to determine UIDNEXT, assume that it has new mail.");
|
||||
warn!(
|
||||
context,
|
||||
"Folder {folder} was just selected but we failed to determine UIDNEXT, assume that it has new mail."
|
||||
);
|
||||
self.new_mail = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ use std::collections::BTreeMap;
|
||||
use std::ops::{Deref, DerefMut};
|
||||
|
||||
use anyhow::{Context as _, Result};
|
||||
use async_imap::types::Mailbox;
|
||||
use async_imap::Session as ImapSession;
|
||||
use async_imap::types::Mailbox;
|
||||
use futures::TryStreamExt;
|
||||
|
||||
use crate::imap::capabilities::Capabilities;
|
||||
|
||||
Reference in New Issue
Block a user