Bläddra i källkod

Fix clippy nits and reformat.

Kestrel 7 månader sedan
förälder
incheckning
2920a79c2e
10 ändrade filer med 37 tillägg och 74 borttagningar
  1. 6 2
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 7 1
      src/cli.rs
  4. 1 5
      src/cli/client.rs
  5. 1 5
      src/cli/group.rs
  6. 1 5
      src/cli/role.rs
  7. 1 5
      src/cli/scope.rs
  8. 1 5
      src/cli/user.rs
  9. 18 33
      src/config/helper.rs
  10. 0 12
      src/user.rs

+ 6 - 2
Cargo.lock

@@ -1400,7 +1400,9 @@ checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
 
 [[package]]
 name = "microrm"
-version = "0.4.0-rc.5"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3622a907b71b6b3a9133ecccf67cd0d4539fad7ba60653557cae5335b86d8b3d"
 dependencies = [
  "clap",
  "itertools",
@@ -1414,7 +1416,9 @@ dependencies = [
 
 [[package]]
 name = "microrm-macros"
-version = "0.4.0-rc.4"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "80eb88bc6673048db8d83f8c57f8eb180f9755aa5e3018db3b7609cc800bc337"
 dependencies = [
  "convert_case",
  "proc-macro2",

+ 1 - 1
Cargo.toml

@@ -28,7 +28,7 @@ bincode = "1.3"
 toml = "0.8.2"
 
 # Data storage dependencies
-microrm = { version = "0.4.0-rc.5", path="../microrm/microrm/", features = ["clap"] }
+microrm = { version = "0.4.0", features = ["clap"] }
 serde_bytes = { version = "0.11.6" }
 
 # Public API/server dependencies

+ 7 - 1
src/cli.rs

@@ -223,7 +223,13 @@ struct ServerArgs {
 impl ServerArgs {
     async fn run(self, args: RunArgs) -> Result<(), UIDCError> {
         let config = config::Config::build_from(&args.db, None);
-        server::run_server(args.db, config, self.bind.as_deref().unwrap_or("127.0.0.1"), self.port.unwrap_or(2114)).await
+        server::run_server(
+            args.db,
+            config,
+            self.bind.as_deref().unwrap_or("127.0.0.1"),
+            self.port.unwrap_or(2114),
+        )
+        .await
     }
 }
 

+ 1 - 5
src/cli/client.rs

@@ -45,11 +45,7 @@ impl microrm::cli::EntityInterface for ClientInterface {
         field: &'static str,
         _role: microrm::cli::ValueRole,
     ) -> bool {
-        if field == "realm" {
-            true
-        } else {
-            false
-        }
+        field == "realm"
     }
 
     fn override_for(

+ 1 - 5
src/cli/group.rs

@@ -39,11 +39,7 @@ impl microrm::cli::EntityInterface for GroupInterface {
         field: &'static str,
         _role: microrm::cli::ValueRole,
     ) -> bool {
-        if field == "realm" {
-            true
-        } else {
-            false
-        }
+        field == "realm"
     }
 
     fn override_for(

+ 1 - 5
src/cli/role.rs

@@ -38,11 +38,7 @@ impl microrm::cli::EntityInterface for RoleInterface {
         field: &'static str,
         _role: microrm::cli::ValueRole,
     ) -> bool {
-        if field == "realm" {
-            true
-        } else {
-            false
-        }
+        field == "realm"
     }
 
     fn override_for(

+ 1 - 5
src/cli/scope.rs

@@ -38,11 +38,7 @@ impl microrm::cli::EntityInterface for ScopeInterface {
         field: &'static str,
         _role: microrm::cli::ValueRole,
     ) -> bool {
-        if field == "realm" {
-            true
-        } else {
-            false
-        }
+        field == "realm"
     }
 
     fn override_for(

+ 1 - 5
src/cli/user.rs

@@ -89,11 +89,7 @@ impl microrm::cli::EntityInterface for UserInterface {
         field: &'static str,
         _role: microrm::cli::ValueRole,
     ) -> bool {
-        if field == "realm" {
-            true
-        } else {
-            false
-        }
+        field == "realm"
     }
 
     fn override_for(

+ 18 - 33
src/config/helper.rs

@@ -78,10 +78,10 @@ impl<'l> serde::Serializer for &'l ValueToStringSerializer {
         Ok(None)
     }
 
-    fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    fn serialize_some<T: ?Sized + serde::Serialize>(
+        self,
+        value: &T,
+    ) -> Result<Self::Ok, Self::Error> {
         value.serialize(self)
     }
 
@@ -137,14 +137,11 @@ impl<'l> serde::Serializer for &'l ValueToStringSerializer {
         todo!()
     }
 
-    fn serialize_newtype_struct<T: ?Sized>(
+    fn serialize_newtype_struct<T: ?Sized + serde::Serialize>(
         self,
         name: &'static str,
         value: &T,
-    ) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    ) -> Result<Self::Ok, Self::Error> {
         todo!()
     }
 
@@ -158,16 +155,13 @@ impl<'l> serde::Serializer for &'l ValueToStringSerializer {
         todo!()
     }
 
-    fn serialize_newtype_variant<T: ?Sized>(
+    fn serialize_newtype_variant<T: ?Sized + serde::Serialize>(
         self,
         name: &'static str,
         variant_index: u32,
         variant: &'static str,
         value: &T,
-    ) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    ) -> Result<Self::Ok, Self::Error> {
         todo!()
     }
 }
@@ -196,14 +190,11 @@ impl<'r, 's> serde::ser::SerializeStruct for ConfigSerializer<'r, 's> {
     type Ok = ();
     type Error = ConfigError;
 
-    fn serialize_field<T: ?Sized>(
+    fn serialize_field<T: ?Sized + serde::Serialize>(
         &mut self,
         key: &'static str,
         value: &T,
-    ) -> Result<(), Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    ) -> Result<(), Self::Error> {
         let key = format!("{}{}", self.prefix, key);
 
         let value = value.serialize(&ValueToStringSerializer {})?;
@@ -291,10 +282,10 @@ impl<'r, 's> serde::Serializer for &'r ConfigSerializer<'r, 's> {
         Ok(())
     }
 
-    fn serialize_some<T: ?Sized>(self, value: &T) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    fn serialize_some<T: ?Sized + serde::Serialize>(
+        self,
+        value: &T,
+    ) -> Result<Self::Ok, Self::Error> {
         todo!()
     }
 
@@ -367,14 +358,11 @@ impl<'r, 's> serde::Serializer for &'r ConfigSerializer<'r, 's> {
         todo!()
     }
 
-    fn serialize_newtype_struct<T: ?Sized>(
+    fn serialize_newtype_struct<T: ?Sized + serde::Serialize>(
         self,
         name: &'static str,
         value: &T,
-    ) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    ) -> Result<Self::Ok, Self::Error> {
         todo!()
     }
 
@@ -388,16 +376,13 @@ impl<'r, 's> serde::Serializer for &'r ConfigSerializer<'r, 's> {
         todo!()
     }
 
-    fn serialize_newtype_variant<T: ?Sized>(
+    fn serialize_newtype_variant<T: ?Sized + serde::Serialize>(
         self,
         name: &'static str,
         variant_index: u32,
         variant: &'static str,
         value: &T,
-    ) -> Result<Self::Ok, Self::Error>
-    where
-        T: serde::Serialize,
-    {
+    ) -> Result<Self::Ok, Self::Error> {
         todo!()
     }
 }

+ 0 - 12
src/user.rs

@@ -37,18 +37,6 @@ fn generate_totp_digits(secret: &[u8], time_offset: isize) -> Result<u32, UIDCEr
 pub trait UserExt {
     fn stored_user(&self) -> &Stored<schema::User>;
 
-    /*fn change_username(&mut self, new_name: &String) -> Result<(), UIDCError> {
-        let realm = self.stored_user().realm;
-        // check to ensure the new username isn't already in use
-        if self.realm.users.with(schema::User::Username, new_name).first().get()?.is_some() {
-            Err(UIDCError::Abort("username already in use"))
-        } else {
-            self.user.username = new_name.clone();
-            self.user.sync()?;
-            Ok(())
-        }
-    }*/
-
     /// returns Ok(true) if challenge passed, Ok(false) if challenge failed, and
     /// UserError::NoSuchChallenge if challenge not found
     fn verify_challenge_by_type(