From 6d2b318ef3c9a68b12b1f637fd6ca092919e7230 Mon Sep 17 00:00:00 2001 From: Oliver Ford Date: Mon, 29 Jan 2024 20:52:53 +0000 Subject: [PATCH] Fix deprecation errors --- notmuch-more/src/compose.rs | 12 ++++-------- notmuch-more/src/parse/headers.rs | 7 ++----- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/notmuch-more/src/compose.rs b/notmuch-more/src/compose.rs index 7247390..0576dc5 100644 --- a/notmuch-more/src/compose.rs +++ b/notmuch-more/src/compose.rs @@ -3,9 +3,9 @@ use std::convert::TryInto; use std::fs; use anyhow::anyhow; -use chrono::DateTime; +use base64::{engine::general_purpose::STANDARD as BASE64_STANDARD, Engine as _}; use chrono::Local; -use chrono::NaiveDateTime; +use chrono::TimeZone; use chrono::Utc; use itertools::Itertools; use notmuch::Database; @@ -84,7 +84,7 @@ pub fn format_message( .essence_str(), "base64", &format!("attachment; filename={}", attachment.name), - &format_attachment(&base64::encode(fs::read(&attachment.path)?)), + &format_attachment(&BASE64_STANDARD.encode(&fs::read(&attachment.path)?)), )); } @@ -94,11 +94,7 @@ pub fn format_message( fn template_body(meta: &EmlMeta, body: &EmlBody) -> String { format!( "\r\n\r\nOn {}, {} wrote:\r\n{}", - DateTime::::from_utc( - NaiveDateTime::from_timestamp_opt(meta.timestamp, 0).unwrap(), - Utc - ) - .to_rfc2822(), + Utc.timestamp_opt(meta.timestamp, 0).unwrap().to_rfc2822(), meta.from .last() .map(String::from) diff --git a/notmuch-more/src/parse/headers.rs b/notmuch-more/src/parse/headers.rs index 0586aab..a096af0 100644 --- a/notmuch-more/src/parse/headers.rs +++ b/notmuch-more/src/parse/headers.rs @@ -4,7 +4,7 @@ use std::convert::TryInto; use chrono::DateTime; use chrono::FixedOffset; -use chrono::NaiveDateTime; +use chrono::TimeZone; use chrono::Utc; use delegate::delegate; use itertools::Itertools; @@ -362,10 +362,7 @@ impl From<&EmlMeta> for Rfc5322Fields { } })); - fields.date(&DateTime::::from_utc( - NaiveDateTime::from_timestamp_opt(meta.timestamp, 0).unwrap(), - Utc, - )); + fields.date(&Utc.timestamp_opt(meta.timestamp, 0).unwrap()); fields }