Replace Result<_, Error> with Result<_>

This commit is contained in:
link2xt
2023-01-28 11:12:06 +00:00
parent 4eda53d5a1
commit dab8acc7d8
4 changed files with 13 additions and 13 deletions

View File

@@ -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<i32, Error> {
pub fn get_exif_orientation(&self, context: &Context) -> Result<i32> {
let file = std::fs::File::open(self.to_abs_path())?;
let mut bufreader = std::io::BufReader::new(&file);
let exifreader = exif::Reader::new();

View File

@@ -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<String, Error> {
fn normalize_address(addr: &str) -> Result<String> {
// 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);

View File

@@ -210,7 +210,7 @@ async fn fingerprint_equals_sender(
context: &Context,
fingerprint: &Fingerprint,
contact_id: ContactId,
) -> Result<bool, Error> {
) -> Result<bool> {
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,

View File

@@ -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<String> {
}
/// 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<P: AsRef<Path>>(context: &Context, path: P) -> Result<Vec<u8>, Error> {
pub async fn read_file(context: &Context, path: impl AsRef<Path>) -> Result<Vec<u8>> {
let path_abs = get_abs_path(context, &path);
match fs::read(&path_abs).await {
@@ -473,7 +473,7 @@ pub async fn read_file<P: AsRef<Path>>(context: &Context, path: P) -> Result<Vec
}
}
pub async fn open_file<P: AsRef<Path>>(context: &Context, path: P) -> Result<fs::File, Error> {
pub async fn open_file(context: &Context, path: impl AsRef<Path>) -> Result<fs::File> {
let path_abs = get_abs_path(context, &path);
match fs::File::open(&path_abs).await {
@@ -493,7 +493,7 @@ pub async fn open_file<P: AsRef<Path>>(context: &Context, path: P) -> Result<fs:
pub fn open_file_std<P: AsRef<std::path::Path>>(
context: &Context,
path: P,
) -> Result<std::fs::File, Error> {
) -> Result<std::fs::File> {
let p: PathBuf = path.as_ref().into();
let path_abs = get_abs_path(context, p);