Skip to content

Commit

Permalink
Implement Display for NameOrAddress
Browse files Browse the repository at this point in the history
Mainly for debugging, but hesitant to override the `Debug` impl for
`Address` with the hex representation.
  • Loading branch information
kim committed Aug 9, 2023
1 parent dec2955 commit 73135d4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/client-api/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod flat_csv;
pub mod websocket;

use core::fmt;
use std::net::IpAddr;

use axum::body::{Bytes, HttpBody};
Expand Down Expand Up @@ -106,3 +107,12 @@ impl<'de> serde::Deserialize<'de> for NameOrAddress {
})
}
}

impl fmt::Display for NameOrAddress {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Address(addr) => f.write_str(&addr.to_hex()),
Self::Name(name) => f.write_str(name),
}
}
}

0 comments on commit 73135d4

Please sign in to comment.