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.
910use proptest_derive::Arbitrary;
11use serde::{Deserialize, Serialize};
12use std::fmt::{Debug, Display};
1314use static_assertions::assert_not_impl_all;
1516///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);
1920assert_not_impl_all!(Password: Display);
2122impl From<String> for Password {
23fn from(password: String) -> Self {
24 Password(password)
25 }
26}
2728impl From<&str> for Password {
29fn from(password: &str) -> Self {
30 Password(password.to_string())
31 }
32}
3334impl ToString for Password {
35fn to_string(&self) -> String {
36self.0.clone()
37 }
38}
3940impl Debug for Password {
41fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
42write!(f, "Password(****)")
43 }
44}