diff --git a/Cargo.lock b/Cargo.lock index bd8ea2620..346e06790 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3280,6 +3280,7 @@ dependencies = [ "pretty_assertions", "serde", "simd-json", + "thiserror", "tokio", "tower", "tracing", diff --git a/crates/kitsune-webfinger/Cargo.toml b/crates/kitsune-webfinger/Cargo.toml index a19572c59..5cf9cfd45 100644 --- a/crates/kitsune-webfinger/Cargo.toml +++ b/crates/kitsune-webfinger/Cargo.toml @@ -13,6 +13,7 @@ kitsune-http-client = { path = "../kitsune-http-client" } kitsune-type = { path = "../kitsune-type" } kitsune-util = { path = "../kitsune-util" } serde = { version = "1.0.192", features = ["derive"] } +thiserror = "1.0.50" tracing = "0.1.40" [dev-dependencies] diff --git a/crates/kitsune-webfinger/src/error.rs b/crates/kitsune-webfinger/src/error.rs new file mode 100644 index 000000000..c439846df --- /dev/null +++ b/crates/kitsune-webfinger/src/error.rs @@ -0,0 +1,12 @@ +use thiserror::Error; + +pub type Result = std::result::Result; + +#[derive(Debug, Error)] +pub enum Error { + #[error(transparent)] + Cache(#[from] kitsune_cache::Error), + + #[error(transparent)] + HttpClient(#[from] kitsune_http_client::Error), +} diff --git a/crates/kitsune-webfinger/src/lib.rs b/crates/kitsune-webfinger/src/lib.rs index 5ee9a101f..7e49ed9fd 100644 --- a/crates/kitsune-webfinger/src/lib.rs +++ b/crates/kitsune-webfinger/src/lib.rs @@ -3,7 +3,6 @@ extern crate tracing; use crate::{consts::USER_AGENT, error::Result}; use autometrics::autometrics; -use core::ptr; use futures_util::future::{FutureExt, OptionFuture}; use http::{HeaderValue, StatusCode}; use kitsune_cache::{ArcCache, CacheBackend, RedisCache}; @@ -11,7 +10,9 @@ use kitsune_http_client::Client; use kitsune_type::webfinger::Resource; use kitsune_util::try_join; use serde::{Deserialize, Serialize}; -use std::{sync::Arc, time::Duration}; +use std::{ptr, sync::Arc, time::Duration}; + +pub mod error; const CACHE_DURATION: Duration = Duration::from_secs(10 * 60); // 10 minutes