build(deps): Upgrade all dependencies and eliminate unsound chain
Bump clap to 4.6.6, imap to 3.0.0-alpha.15 and native-tls to 0.2.18. The imap upgrade removes the unsound lexical-core 0.7.6 dependency inherited via nom 5 (RUSTSEC-2023-0086), leaving cargo audit clean. Drop the unused imap-proto dependency and migrate to the imap 3.x ClientBuilder and AppendCmd APIs.
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
use crate::config::settings::ImapConfig;
|
||||
use native_tls::TlsConnector;
|
||||
|
||||
pub struct ImapClient {
|
||||
session: Option<imap::Session<native_tls::TlsStream<std::net::TcpStream>>>,
|
||||
session: Option<imap::Session<imap::Connection>>,
|
||||
}
|
||||
|
||||
impl ImapClient {
|
||||
@@ -13,8 +12,7 @@ impl ImapClient {
|
||||
}
|
||||
|
||||
pub fn login(&mut self, config: &ImapConfig) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let tls = TlsConnector::builder().build()?;
|
||||
let client = imap::connect((config.host.as_str(), config.port), &config.host, &tls)?;
|
||||
let client = imap::ClientBuilder::new(config.host.as_str(), config.port).connect()?;
|
||||
let session = client.login(&config.username, &config.password).map_err(|e| e.0)?;
|
||||
self.session = Some(session);
|
||||
Ok(())
|
||||
@@ -29,7 +27,7 @@ impl ImapClient {
|
||||
|
||||
pub fn append_message(&mut self, message: &str) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if let Some(ref mut session) = self.session {
|
||||
session.append("INBOX", message.as_bytes())?;
|
||||
session.append("INBOX", message.as_bytes()).finish()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user