Hide cookies in ServerConfig Debug impl

This commit is contained in:
Joscha 2023-01-22 20:49:34 +01:00
parent 1ea5ede442
commit 0c7e8c1dff

View file

@ -2,6 +2,7 @@
//! //!
//! See [`Instance`] for more details. //! See [`Instance`] for more details.
use std::fmt;
use std::str::FromStr; use std::str::FromStr;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use std::time::Duration; use std::time::Duration;
@ -18,7 +19,7 @@ use crate::conn::{self, Conn, ConnTx, State};
/// Settings that are usually shared between all instances connecting to a /// Settings that are usually shared between all instances connecting to a
/// specific server. /// specific server.
#[derive(Debug, Clone)] #[derive(Clone)]
pub struct ServerConfig { pub struct ServerConfig {
/// How long to wait for the server until an operation is considered timed /// How long to wait for the server until an operation is considered timed
/// out. /// out.
@ -74,6 +75,25 @@ impl Default for ServerConfig {
} }
} }
struct Hidden;
impl fmt::Debug for Hidden {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "<hidden>")
}
}
impl fmt::Debug for ServerConfig {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("ServerConfig")
.field("timeout", &self.timeout)
.field("reconnect_delay", &self.reconnect_delay)
.field("domain", &self.domain)
.field("cookies", &Hidden)
.finish()
}
}
/// Settings that are usually specific to a single instance. /// Settings that are usually specific to a single instance.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct InstanceConfig { pub struct InstanceConfig {