about summary refs log tree commit diff
path: root/util/src
diff options
context:
space:
mode:
Diffstat (limited to 'util/src')
-rw-r--r--util/src/fs.rs14
-rw-r--r--util/src/lib.rs4
-rw-r--r--util/src/micropub.rs14
-rw-r--r--util/src/queue.rs6
4 files changed, 21 insertions, 17 deletions
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<T, B>(dir: T, basename: B, length: usize) -> Result<(PathBuf, fs::File)>
 where
     T: AsRef<Path>,
-    B: Into<Option<&'static str>>
+    B: Into<Option<&'static str>>,
 {
     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::<Vec<u8>>();
+                    .sample_iter(&Alphanumeric)
+                    .take(length)
+                    .collect::<Vec<u8>>();
                 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<QueryType> {
@@ -67,7 +67,7 @@ pub struct Config {
     pub media_endpoint: Option<url::Url>,
     /// Other unspecified keys, sometimes implementation-defined.
     #[serde(flatten)]
-    pub other: HashMap<String, serde_json::Value>
+    pub other: HashMap<String, serde_json::Value>,
 }
 
 #[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<ErrorKind> 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<T: JobItem>: 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<Output = Result<JobStream<Self::Job, Self::Error>, Self::Error>> + Send;
+    fn into_stream(
+        self,
+    ) -> impl Future<Output = Result<JobStream<Self::Job, Self::Error>, Self::Error>> + Send;
 }
 
 /// A job description yielded from a job queue.