From 8826d9446e6c492db2243b9921e59ce496027bef Mon Sep 17 00:00:00 2001 From: Vika Date: Wed, 9 Apr 2025 23:31:02 +0300 Subject: cargo fmt Change-Id: I80e81ebba3f0cdf8c094451c9fe3ee4126b8c888 --- util/src/fs.rs | 14 +++++++------- util/src/lib.rs | 4 ++-- util/src/micropub.rs | 14 ++++++++------ util/src/queue.rs | 6 ++++-- 4 files changed, 21 insertions(+), 17 deletions(-) (limited to 'util/src') diff --git a/util/src/fs.rs b/util/src/fs.rs index 6a7a5b4..ea9dadd 100644 --- a/util/src/fs.rs +++ b/util/src/fs.rs @@ -1,6 +1,6 @@ +use rand::{distributions::Alphanumeric, Rng}; use std::io::{self, Result}; use std::path::{Path, PathBuf}; -use rand::{Rng, distributions::Alphanumeric}; use tokio::fs; /// Create a temporary file named `temp.[a-zA-Z0-9]{length}` in @@ -20,7 +20,7 @@ use tokio::fs; pub async fn mktemp(dir: T, basename: B, length: usize) -> Result<(PathBuf, fs::File)> where T: AsRef, - B: Into> + B: Into>, { let dir = dir.as_ref(); let basename = basename.into().unwrap_or(""); @@ -33,9 +33,9 @@ where if basename.is_empty() { "" } else { "." }, { let string = rand::thread_rng() - .sample_iter(&Alphanumeric) - .take(length) - .collect::>(); + .sample_iter(&Alphanumeric) + .take(length) + .collect::>(); String::from_utf8(string).unwrap() } )); @@ -49,8 +49,8 @@ where Ok(file) => return Ok((filename, file)), Err(err) => match err.kind() { io::ErrorKind::AlreadyExists => continue, - _ => return Err(err) - } + _ => return Err(err), + }, } } } diff --git a/util/src/lib.rs b/util/src/lib.rs index cb5f666..0c5df49 100644 --- a/util/src/lib.rs +++ b/util/src/lib.rs @@ -17,7 +17,7 @@ pub enum MentionType { Bookmark, /// A plain link without MF2 annotations. #[default] - Mention + Mention, } /// Common data-types useful in creating smart authentication systems. @@ -29,7 +29,7 @@ pub mod auth { /// used to recover from a lost passkey. Password, /// Denotes availability of one or more passkeys. - WebAuthn + WebAuthn, } } diff --git a/util/src/micropub.rs b/util/src/micropub.rs index 9d2c525..1f8008b 100644 --- a/util/src/micropub.rs +++ b/util/src/micropub.rs @@ -21,7 +21,7 @@ pub enum QueryType { Category, /// Unsupported query type // TODO: make this take a lifetime parameter for zero-copy deserialization if possible? - Unknown(std::borrow::Cow<'static, str>) + Unknown(std::borrow::Cow<'static, str>), } /// Data structure representing a Micropub channel in the ?q=channels output. @@ -42,7 +42,7 @@ pub struct SyndicationDestination { /// The syndication destination's UID, opaque to the client. pub uid: String, /// A human-friendly name. - pub name: String + pub name: String, } fn default_q_list() -> Vec { @@ -67,7 +67,7 @@ pub struct Config { pub media_endpoint: Option, /// Other unspecified keys, sometimes implementation-defined. #[serde(flatten)] - pub other: HashMap + pub other: HashMap, } #[derive(Serialize, Deserialize, PartialEq, Eq, Debug)] @@ -145,14 +145,17 @@ impl Error { pub const fn from_static(error: ErrorKind, error_description: &'static str) -> Self { Self { error, - error_description: Some(std::borrow::Cow::Borrowed(error_description)) + error_description: Some(std::borrow::Cow::Borrowed(error_description)), } } } impl From for Error { fn from(error: ErrorKind) -> Self { - Self { error, error_description: None } + Self { + error, + error_description: None, + } } } @@ -190,4 +193,3 @@ impl axum_core::response::IntoResponse for Error { )) } } - diff --git a/util/src/queue.rs b/util/src/queue.rs index edbec86..b32fdc5 100644 --- a/util/src/queue.rs +++ b/util/src/queue.rs @@ -1,5 +1,5 @@ -use std::future::Future; use futures_util::Stream; +use std::future::Future; use std::pin::Pin; use uuid::Uuid; @@ -44,7 +44,9 @@ pub trait JobQueue: Send + Sync + Sized + Clone + 'static { /// /// Note that one item may be returned several times if it is not /// marked as done. - fn into_stream(self) -> impl Future, Self::Error>> + Send; + fn into_stream( + self, + ) -> impl Future, Self::Error>> + Send; } /// A job description yielded from a job queue. -- cgit 1.4.1