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) + } + } + } +}