From dab8acc7d8298d4cb8fd676a28186f5f05a15d85 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 28 Jan 2023 11:12:06 +0000 Subject: [PATCH] Replace Result<_, Error> with Result<_> --- src/blob.rs | 4 ++-- src/qr.rs | 4 ++-- src/securejoin.rs | 8 ++++---- src/tools.rs | 10 +++++----- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/blob.rs b/src/blob.rs index 5de6a44b2..d58cf6775 100644 --- a/src/blob.rs +++ b/src/blob.rs @@ -6,7 +6,7 @@ use std::fmt; use std::io::Cursor; use std::path::{Path, PathBuf}; -use anyhow::{format_err, Context as _, Error, Result}; +use anyhow::{format_err, Context as _, Result}; use image::{DynamicImage, ImageFormat}; use num_traits::FromPrimitive; use tokio::io::AsyncWriteExt; @@ -443,7 +443,7 @@ impl<'a> BlobObject<'a> { }) } - pub fn get_exif_orientation(&self, context: &Context) -> Result { + pub fn get_exif_orientation(&self, context: &Context) -> Result { let file = std::fs::File::open(self.to_abs_path())?; let mut bufreader = std::io::BufReader::new(&file); let exifreader = exif::Reader::new(); diff --git a/src/qr.rs b/src/qr.rs index 7c14c4de0..7130e2301 100644 --- a/src/qr.rs +++ b/src/qr.rs @@ -5,7 +5,7 @@ mod dclogin_scheme; use std::collections::BTreeMap; -use anyhow::{anyhow, bail, ensure, Context as _, Error, Result}; +use anyhow::{anyhow, bail, ensure, Context as _, Result}; pub use dclogin_scheme::LoginOptions; use once_cell::sync::Lazy; use percent_encoding::percent_decode_str; @@ -629,7 +629,7 @@ impl Qr { } /// URL decodes a given address, does basic email validation on the result. -fn normalize_address(addr: &str) -> Result { +fn normalize_address(addr: &str) -> Result { // urldecoding is needed at least for OPENPGP4FPR but should not hurt in the other cases let new_addr = percent_decode_str(addr).decode_utf8()?; let new_addr = addr_normalize(&new_addr); diff --git a/src/securejoin.rs b/src/securejoin.rs index 692c28ff8..756f1d001 100644 --- a/src/securejoin.rs +++ b/src/securejoin.rs @@ -210,7 +210,7 @@ async fn fingerprint_equals_sender( context: &Context, fingerprint: &Fingerprint, contact_id: ContactId, -) -> Result { +) -> Result { let contact = Contact::load_from_db(context, contact_id).await?; let peerstate = match Peerstate::from_addr(context, contact.get_addr()).await { Ok(peerstate) => peerstate, @@ -698,7 +698,7 @@ async fn secure_connection_established( context: &Context, contact_id: ContactId, chat_id: ChatId, -) -> Result<(), Error> { +) -> Result<()> { let contact = Contact::get_by_id(context, contact_id).await?; let msg = stock_str::contact_verified(context, &contact).await; chat::add_info_msg(context, chat_id, &msg, time()).await?; @@ -711,7 +711,7 @@ async fn could_not_establish_secure_connection( contact_id: ContactId, chat_id: ChatId, details: &str, -) -> Result<(), Error> { +) -> Result<()> { let contact = Contact::get_by_id(context, contact_id).await?; let msg = stock_str::contact_not_verified(context, &contact).await; chat::add_info_msg(context, chat_id, &msg, time()).await?; @@ -726,7 +726,7 @@ async fn mark_peer_as_verified( context: &Context, fingerprint: Fingerprint, verifier: String, -) -> Result<(), Error> { +) -> Result<()> { if let Some(ref mut peerstate) = Peerstate::from_fingerprint(context, &fingerprint).await? { if let Err(err) = peerstate.set_verified( PeerstateKeyType::PublicKey, diff --git a/src/tools.rs b/src/tools.rs index ca935cf1e..837829f39 100644 --- a/src/tools.rs +++ b/src/tools.rs @@ -11,7 +11,7 @@ use std::path::{Path, PathBuf}; use std::str::from_utf8; use std::time::{Duration, SystemTime}; -use anyhow::{bail, Error, Result}; +use anyhow::{bail, Result}; use chrono::{Local, TimeZone}; use futures::{StreamExt, TryStreamExt}; use mailparse::dateparse; @@ -344,7 +344,7 @@ pub fn get_filesuffix_lc(path_filename: &str) -> Option { } /// Returns the `(width, height)` of the given image buffer. -pub fn get_filemeta(buf: &[u8]) -> Result<(u32, u32), Error> { +pub fn get_filemeta(buf: &[u8]) -> Result<(u32, u32)> { let image = image::io::Reader::new(Cursor::new(buf)).with_guessed_format()?; let dimensions = image.into_dimensions()?; Ok(dimensions) @@ -456,7 +456,7 @@ pub(crate) async fn write_file( }) } -pub async fn read_file>(context: &Context, path: P) -> Result, Error> { +pub async fn read_file(context: &Context, path: impl AsRef) -> Result> { let path_abs = get_abs_path(context, &path); match fs::read(&path_abs).await { @@ -473,7 +473,7 @@ pub async fn read_file>(context: &Context, path: P) -> Result>(context: &Context, path: P) -> Result { +pub async fn open_file(context: &Context, path: impl AsRef) -> Result { let path_abs = get_abs_path(context, &path); match fs::File::open(&path_abs).await { @@ -493,7 +493,7 @@ pub async fn open_file>(context: &Context, path: P) -> Result>( context: &Context, path: P, -) -> Result { +) -> Result { let p: PathBuf = path.as_ref().into(); let path_abs = get_abs_path(context, p);