pub struct HostFile { /* private fields */ }Expand description
Collection of host file entries keyed by reflector name.
Lookups are case-insensitive — the query is upper-cased before
the HashMap lookup. Parsed insertion likewise upper-cases the
name. Duplicate names use last-wins semantics.
Implementations§
Source§impl HostFile
impl HostFile
Sourcepub fn parse(&mut self, content: &str, default_port: u16)
pub fn parse(&mut self, content: &str, default_port: u16)
Parse host entries from text content.
Supports two formats:
- 3 columns:
name address port - 2 columns:
name address(port fromdefault_port)
Lines starting with # are comments. Empty lines skipped.
Unparseable ports fall back to default_port rather than
dropping the entry.
Sourcepub fn lookup(&self, name: &str) -> Option<&HostEntry>
pub fn lookup(&self, name: &str) -> Option<&HostEntry>
Look up an entry by name (case-insensitive).
Sourcepub fn insert(&mut self, entry: HostEntry)
pub fn insert(&mut self, entry: HostEntry)
Insert a host entry directly. Uses entry.name verbatim as
the key, so callers should pass an upper-case name to remain
reachable via Self::lookup.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HostFile
impl RefUnwindSafe for HostFile
impl Send for HostFile
impl Sync for HostFile
impl Unpin for HostFile
impl UnwindSafe for HostFile
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