mz_auth/
password.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10use proptest_derive::Arbitrary;
11use serde::{Deserialize, Serialize};
12use std::fmt::{Debug, Display};
13
14use static_assertions::assert_not_impl_all;
15
16///Password is a String wrapper type that does not implement Display or Debug
17#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, PartialOrd, Ord, Arbitrary)]
18pub struct Password(pub String);
19
20assert_not_impl_all!(Password: Display);
21
22impl From<String> for Password {
23    fn from(password: String) -> Self {
24        Password(password)
25    }
26}
27
28impl From<&str> for Password {
29    fn from(password: &str) -> Self {
30        Password(password.to_string())
31    }
32}
33
34impl ToString for Password {
35    fn to_string(&self) -> String {
36        self.0.clone()
37    }
38}
39
40impl Debug for Password {
41    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42        write!(f, "Password(****)")
43    }
44}