From 553c28c928fa0f7e6f67be20b304ec458b0ca32c Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 5 Apr 2025 11:36:06 -0400 Subject: [PATCH] Added salt model --- src/user.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/user.rs b/src/user.rs index f3e8720..56e570d 100644 --- a/src/user.rs +++ b/src/user.rs @@ -59,3 +59,29 @@ impl User { } } } + +pub mod salt { + use std::default::Default; + + use crate::init; + + use serde::{Deserialize, Serialize}; + + #[derive(Clone, Debug, Default, Deserialize, Serialize)] + pub struct Salt { + #[serde(skip_serializing_if = "init::is_uuid_nil")] + pub id: uuid::Uuid, + #[serde(skip_serializing_if = "String::is_empty")] + pub salt: String, + } + + impl Salt { + pub fn to_json(&self, output_pretty: bool) -> Result { + if output_pretty { + serde_json::to_string_pretty(&self) + } else { + serde_json::to_string(&self) + } + } + } +}