From 9b7705ed26e682866b8cd2c219e19db3aac32abd Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Wed, 18 May 2022 20:16:42 +0200 Subject: [PATCH] chore: change Result to anyhow::Result --- src/api/delete_image.rs | 3 +-- src/api/get_image.rs | 3 +-- src/api/mod.rs | 3 +-- src/api/rate_limit.rs | 3 +-- src/api/upload_image.rs | 3 +-- src/config/toml.rs | 2 +- 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/api/delete_image.rs b/src/api/delete_image.rs index f04d2fd..4ef9b6c 100644 --- a/src/api/delete_image.rs +++ b/src/api/delete_image.rs @@ -1,11 +1,10 @@ use std::io; -use anyhow::Error; use reqwest::Method; use super::{client::api_url, send_api_request, ImgurClient}; -pub async fn delete_image(client: &ImgurClient, delete_hash: &str) -> Result<(), Error> { +pub async fn delete_image(client: &ImgurClient, delete_hash: &str) -> anyhow::Result<()> { // get imgur api url let uri = api_url!(format!("image/{delete_hash}")); diff --git a/src/api/get_image.rs b/src/api/get_image.rs index c78e0fe..54aa9ea 100644 --- a/src/api/get_image.rs +++ b/src/api/get_image.rs @@ -1,11 +1,10 @@ use std::io; -use anyhow::Error; use reqwest::Method; use super::{client::api_url, send_api_request, ImageInfo, ImgurClient}; -pub async fn get_image(client: &ImgurClient, image: &str) -> Result { +pub async fn get_image(client: &ImgurClient, image: &str) -> anyhow::Result { // get imgur api url let uri = api_url!(format!("image/{image}")); diff --git a/src/api/mod.rs b/src/api/mod.rs index 6426888..8ed1826 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -15,7 +15,6 @@ pub use upload_image::*; use std::collections::HashMap; -use anyhow::Error; use reqwest::{Method, Response}; // send request to imgur api @@ -24,7 +23,7 @@ pub async fn send_api_request( method: Method, uri: String, form: Option>, -) -> Result { +) -> anyhow::Result { // get request client let client = &config.client; diff --git a/src/api/rate_limit.rs b/src/api/rate_limit.rs index d1abcee..9abba5d 100644 --- a/src/api/rate_limit.rs +++ b/src/api/rate_limit.rs @@ -1,6 +1,5 @@ use std::io; -use anyhow::Error; use reqwest::Method; use serde::{Deserialize, Serialize}; @@ -27,7 +26,7 @@ pub struct RateLimitData { pub client_remaining: i32, } -pub async fn rate_limit(client: &ImgurClient) -> Result { +pub async fn rate_limit(client: &ImgurClient) -> anyhow::Result { // get imgur api url let uri = api_url!("credits"); diff --git a/src/api/upload_image.rs b/src/api/upload_image.rs index b9d8281..df596b9 100644 --- a/src/api/upload_image.rs +++ b/src/api/upload_image.rs @@ -1,11 +1,10 @@ use std::{collections::HashMap, io}; -use anyhow::Error; use reqwest::Method; use super::{client::api_url, send_api_request, ImageInfo, ImgurClient}; -pub async fn upload_image(client: &ImgurClient, image: String) -> Result { +pub async fn upload_image(client: &ImgurClient, image: String) -> anyhow::Result { // create http form (hashmap) let mut form = HashMap::new(); // insert image to form diff --git a/src/config/toml.rs b/src/config/toml.rs index f36fd59..2df5535 100644 --- a/src/config/toml.rs +++ b/src/config/toml.rs @@ -50,7 +50,7 @@ pub fn parse() -> Config { }) } -fn toml() -> Result { +fn toml() -> anyhow::Result { let config_dir = config_dir().unwrap(); let file_dir = format!("{}{CONFIG_DIR}", config_dir.to_string_lossy()); let toml_str = read_to_string(file_dir).map_err(Error::new)?;