pub struct HostMap { /* private fields */ }Expand description
Bidirectional hostname ↔ npub mapping table.
Implementations§
Source§impl HostMap
impl HostMap
Sourcepub fn insert(&mut self, hostname: &str, npub: &str) -> Result<(), HostMapError>
pub fn insert(&mut self, hostname: &str, npub: &str) -> Result<(), HostMapError>
Insert a hostname → npub mapping.
Validates the hostname and npub before inserting. The hostname is stored in lowercase for case-insensitive matching.
Sourcepub fn lookup_npub(&self, hostname: &str) -> Option<&str>
pub fn lookup_npub(&self, hostname: &str) -> Option<&str>
Look up the npub for a hostname (case-insensitive).
Sourcepub fn lookup_hostname(&self, node_addr: &NodeAddr) -> Option<&str>
pub fn lookup_hostname(&self, node_addr: &NodeAddr) -> Option<&str>
Look up the hostname for a NodeAddr (reverse lookup for display).
Sourcepub fn from_peer_configs(peers: &[PeerConfig]) -> Self
pub fn from_peer_configs(peers: &[PeerConfig]) -> Self
Build a host map from configured peer aliases.
Peers with a valid alias field are inserted. Invalid hostnames
or npubs are logged as warnings and skipped.
Sourcepub fn load_hosts_file(path: &Path) -> Self
pub fn load_hosts_file(path: &Path) -> Self
Load a host map from a hosts file.
If the file does not exist, returns an empty map (not an error). Parse errors on individual lines are logged as warnings and skipped.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HostMap
impl RefUnwindSafe for HostMap
impl Send for HostMap
impl Sync for HostMap
impl Unpin for HostMap
impl UnsafeUnpin for HostMap
impl UnwindSafe for HostMap
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more