impl fmt::Display for FedDest

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-05-31 01:21:15 +00:00
parent 9df5265c00
commit ba48758b89
2 changed files with 11 additions and 1 deletions

View file

@ -448,7 +448,7 @@ pub(crate) async fn resolve_true_destination(
let (actual_dest, hostname_uri) = resolve_actual_dest(&server_name, no_cache).await?;
Ok(RoomMessageEventContent::text_plain(format!(
"Actual destination: {actual_dest:?} | Hostname URI: {hostname_uri}"
"Actual destination: {actual_dest} | Hostname URI: {hostname_uri}"
)))
}

View file

@ -1,4 +1,5 @@
use std::{
fmt,
fmt::Debug,
net::{IpAddr, SocketAddr},
};
@ -414,6 +415,15 @@ impl FedDest {
}
}
impl fmt::Display for FedDest {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
FedDest::Named(host, port) => write!(f, "{host}{port}"),
FedDest::Literal(addr) => write!(f, "{addr}"),
}
}
}
#[cfg(test)]
mod tests {
use super::{add_port_to_hostname, get_ip_with_port, FedDest};