mirror of
https://github.com/chatmail/core.git
synced 2026-05-05 22:36:30 +03:00
chore: nightly clippy fixes
This commit is contained in:
@@ -76,7 +76,7 @@ impl ContactAddress {
|
|||||||
|
|
||||||
/// Allow converting [`ContactAddress`] to an SQLite type.
|
/// Allow converting [`ContactAddress`] to an SQLite type.
|
||||||
impl rusqlite::types::ToSql for ContactAddress {
|
impl rusqlite::types::ToSql for ContactAddress {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Text(self.0.to_string());
|
let val = rusqlite::types::Value::Text(self.0.to_string());
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
@@ -282,7 +282,7 @@ impl EmailAddress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::types::ToSql for EmailAddress {
|
impl rusqlite::types::ToSql for EmailAddress {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Text(self.to_string());
|
let val = rusqlite::types::Value::Text(self.to_string());
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ pub enum Meaning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Lot {
|
impl Lot {
|
||||||
pub fn get_text1(&self) -> Option<Cow<str>> {
|
pub fn get_text1(&self) -> Option<Cow<'_, str>> {
|
||||||
match self {
|
match self {
|
||||||
Self::Summary(summary) => match &summary.prefix {
|
Self::Summary(summary) => match &summary.prefix {
|
||||||
None => None,
|
None => None,
|
||||||
@@ -66,7 +66,7 @@ impl Lot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_text2(&self) -> Option<Cow<str>> {
|
pub fn get_text2(&self) -> Option<Cow<'_, str>> {
|
||||||
match self {
|
match self {
|
||||||
Self::Summary(summary) => Some(summary.truncated_text(160)),
|
Self::Summary(summary) => Some(summary.truncated_text(160)),
|
||||||
Self::Qr(_) => None,
|
Self::Qr(_) => None,
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
|||||||
"send-backup" => {
|
"send-backup" => {
|
||||||
let provider = BackupProvider::prepare(&context).await?;
|
let provider = BackupProvider::prepare(&context).await?;
|
||||||
let qr = format_backup(&provider.qr())?;
|
let qr = format_backup(&provider.qr())?;
|
||||||
println!("QR code: {}", qr);
|
println!("QR code: {qr}");
|
||||||
qr2term::print_qr(qr.as_str())?;
|
qr2term::print_qr(qr.as_str())?;
|
||||||
provider.await?;
|
provider.await?;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,25 +41,25 @@ fn receive_event(event: EventType) {
|
|||||||
match event {
|
match event {
|
||||||
EventType::Info(msg) => {
|
EventType::Info(msg) => {
|
||||||
/* do not show the event as this would fill the screen */
|
/* do not show the event as this would fill the screen */
|
||||||
info!("{}", msg);
|
info!("{msg}");
|
||||||
}
|
}
|
||||||
EventType::SmtpConnected(msg) => {
|
EventType::SmtpConnected(msg) => {
|
||||||
info!("[SMTP_CONNECTED] {}", msg);
|
info!("[SMTP_CONNECTED] {msg}");
|
||||||
}
|
}
|
||||||
EventType::ImapConnected(msg) => {
|
EventType::ImapConnected(msg) => {
|
||||||
info!("[IMAP_CONNECTED] {}", msg);
|
info!("[IMAP_CONNECTED] {msg}");
|
||||||
}
|
}
|
||||||
EventType::SmtpMessageSent(msg) => {
|
EventType::SmtpMessageSent(msg) => {
|
||||||
info!("[SMTP_MESSAGE_SENT] {}", msg);
|
info!("[SMTP_MESSAGE_SENT] {msg}");
|
||||||
}
|
}
|
||||||
EventType::Warning(msg) => {
|
EventType::Warning(msg) => {
|
||||||
warn!("{}", msg);
|
warn!("{msg}");
|
||||||
}
|
}
|
||||||
EventType::Error(msg) => {
|
EventType::Error(msg) => {
|
||||||
error!("{}", msg);
|
error!("{msg}");
|
||||||
}
|
}
|
||||||
EventType::ErrorSelfNotInGroup(msg) => {
|
EventType::ErrorSelfNotInGroup(msg) => {
|
||||||
error!("[SELF_NOT_IN_GROUP] {}", msg);
|
error!("[SELF_NOT_IN_GROUP] {msg}");
|
||||||
}
|
}
|
||||||
EventType::MsgsChanged { chat_id, msg_id } => {
|
EventType::MsgsChanged { chat_id, msg_id } => {
|
||||||
info!(
|
info!(
|
||||||
@@ -124,7 +124,7 @@ fn receive_event(event: EventType) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
info!("Received {:?}", event);
|
info!("Received {event:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ async fn main_impl() -> Result<()> {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
let path = std::env::var("DC_ACCOUNTS_PATH").unwrap_or_else(|_| "accounts".to_string());
|
let path = std::env::var("DC_ACCOUNTS_PATH").unwrap_or_else(|_| "accounts".to_string());
|
||||||
log::info!("Starting with accounts directory `{}`.", path);
|
log::info!("Starting with accounts directory `{path}`.");
|
||||||
let writable = true;
|
let writable = true;
|
||||||
let accounts = Accounts::new(PathBuf::from(&path), writable).await?;
|
let accounts = Accounts::new(PathBuf::from(&path), writable).await?;
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ async fn main_impl() -> Result<()> {
|
|||||||
Some(message) => serde_json::to_string(&message)?,
|
Some(message) => serde_json::to_string(&message)?,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
log::trace!("RPC send {}", message);
|
log::trace!("RPC send {message}");
|
||||||
println!("{message}");
|
println!("{message}");
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
@@ -141,7 +141,7 @@ async fn main_impl() -> Result<()> {
|
|||||||
Some(message) => message,
|
Some(message) => message,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
log::trace!("RPC recv {}", message);
|
log::trace!("RPC recv {message}");
|
||||||
let session = session.clone();
|
let session = session.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
session.handle_incoming(&message).await;
|
session.handle_incoming(&message).await;
|
||||||
|
|||||||
@@ -1508,7 +1508,7 @@ impl std::fmt::Display for ChatId {
|
|||||||
/// This allows you to directly store [ChatId] into the database as
|
/// This allows you to directly store [ChatId] into the database as
|
||||||
/// well as query for a [ChatId].
|
/// well as query for a [ChatId].
|
||||||
impl rusqlite::types::ToSql for ChatId {
|
impl rusqlite::types::ToSql for ChatId {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
@@ -2380,7 +2380,7 @@ pub enum ChatVisibility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::types::ToSql for ChatVisibility {
|
impl rusqlite::types::ToSql for ChatVisibility {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Integer(*self as i64);
|
let val = rusqlite::types::Value::Integer(*self as i64);
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
@@ -4026,7 +4026,7 @@ pub enum MuteDuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::types::ToSql for MuteDuration {
|
impl rusqlite::types::ToSql for MuteDuration {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let duration: i64 = match &self {
|
let duration: i64 = match &self {
|
||||||
MuteDuration::NotMuted => 0,
|
MuteDuration::NotMuted => 0,
|
||||||
MuteDuration::Forever => -1,
|
MuteDuration::Forever => -1,
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ impl fmt::Display for ContactId {
|
|||||||
|
|
||||||
/// Allow converting [`ContactId`] to an SQLite type.
|
/// Allow converting [`ContactId`] to an SQLite type.
|
||||||
impl rusqlite::types::ToSql for ContactId {
|
impl rusqlite::types::ToSql for ContactId {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ impl FromStr for Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::types::ToSql for Timer {
|
impl rusqlite::types::ToSql for Timer {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Integer(match self {
|
let val = rusqlite::types::Value::Integer(match self {
|
||||||
Self::Disabled => 0,
|
Self::Disabled => 0,
|
||||||
Self::Enabled { duration } => i64::from(*duration),
|
Self::Enabled { duration } => i64::from(*duration),
|
||||||
|
|||||||
@@ -134,14 +134,14 @@ pub trait HeaderDefMap {
|
|||||||
fn get_header_value(&self, headerdef: HeaderDef) -> Option<String>;
|
fn get_header_value(&self, headerdef: HeaderDef) -> Option<String>;
|
||||||
|
|
||||||
/// Returns requested header if it exists.
|
/// Returns requested header if it exists.
|
||||||
fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader>;
|
fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader<'_>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HeaderDefMap for [MailHeader<'_>] {
|
impl HeaderDefMap for [MailHeader<'_>] {
|
||||||
fn get_header_value(&self, headerdef: HeaderDef) -> Option<String> {
|
fn get_header_value(&self, headerdef: HeaderDef) -> Option<String> {
|
||||||
self.get_first_value(headerdef.get_headername())
|
self.get_first_value(headerdef.get_headername())
|
||||||
}
|
}
|
||||||
fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader> {
|
fn get_header(&self, headerdef: HeaderDef) -> Option<&MailHeader<'_>> {
|
||||||
self.get_first_header(headerdef.get_headername())
|
self.get_first_header(headerdef.get_headername())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2163,7 +2163,7 @@ pub(crate) fn get_folder_meaning(folder: &Name) -> FolderMeaning {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the headers from the FETCH result.
|
/// Parses the headers from the FETCH result.
|
||||||
fn get_fetch_headers(prefetch_msg: &Fetch) -> Result<Vec<mailparse::MailHeader>> {
|
fn get_fetch_headers(prefetch_msg: &Fetch) -> Result<Vec<mailparse::MailHeader<'_>>> {
|
||||||
match prefetch_msg.header() {
|
match prefetch_msg.header() {
|
||||||
Some(header_bytes) => {
|
Some(header_bytes) => {
|
||||||
let (headers, _) = mailparse::parse_headers(header_bytes)?;
|
let (headers, _) = mailparse::parse_headers(header_bytes)?;
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ impl std::fmt::Display for MsgId {
|
|||||||
/// This **does** ensure that no special message IDs are written into
|
/// This **does** ensure that no special message IDs are written into
|
||||||
/// the database and the conversion will fail if this is not the case.
|
/// the database and the conversion will fail if this is not the case.
|
||||||
impl rusqlite::types::ToSql for MsgId {
|
impl rusqlite::types::ToSql for MsgId {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
if self.0 <= DC_MSG_ID_LAST_SPECIAL {
|
if self.0 <= DC_MSG_ID_LAST_SPECIAL {
|
||||||
return Err(rusqlite::Error::ToSqlConversionFailure(
|
return Err(rusqlite::Error::ToSqlConversionFailure(
|
||||||
format_err!("Invalid MsgId {}", self.0).into(),
|
format_err!("Invalid MsgId {}", self.0).into(),
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ impl Summary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the [`Summary::text`] attribute truncated to an approximate length.
|
/// Returns the [`Summary::text`] attribute truncated to an approximate length.
|
||||||
pub fn truncated_text(&self, approx_chars: usize) -> Cow<str> {
|
pub fn truncated_text(&self, approx_chars: usize) -> Cow<'_, str> {
|
||||||
truncate(&self.text, approx_chars)
|
truncate(&self.text, approx_chars)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ use crate::stock_str;
|
|||||||
|
|
||||||
/// Shortens a string to a specified length and adds "[...]" to the
|
/// Shortens a string to a specified length and adds "[...]" to the
|
||||||
/// end of the shortened string.
|
/// end of the shortened string.
|
||||||
pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<str> {
|
pub(crate) fn truncate(buf: &str, approx_chars: usize) -> Cow<'_, str> {
|
||||||
let count = buf.chars().count();
|
let count = buf.chars().count();
|
||||||
if count <= approx_chars + DC_ELLIPSIS.len() {
|
if count <= approx_chars + DC_ELLIPSIS.len() {
|
||||||
return Cow::Borrowed(buf);
|
return Cow::Borrowed(buf);
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ impl StatusUpdateSerial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl rusqlite::types::ToSql for StatusUpdateSerial {
|
impl rusqlite::types::ToSql for StatusUpdateSerial {
|
||||||
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput> {
|
fn to_sql(&self) -> rusqlite::Result<rusqlite::types::ToSqlOutput<'_>> {
|
||||||
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
let val = rusqlite::types::Value::Integer(i64::from(self.0));
|
||||||
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
let out = rusqlite::types::ToSqlOutput::Owned(val);
|
||||||
Ok(out)
|
Ok(out)
|
||||||
|
|||||||
Reference in New Issue
Block a user