Skip to content

Commit

Permalink
Add fallible::hostname_lower
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgf committed Sep 26, 2024
1 parent c1dfdec commit 0d1ca50
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/fallible.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,14 @@ pub fn devicename_os() -> Result<OsString> {
pub fn hostname() -> Result<String> {
Target::hostname(Os)
}

/// Get the host device's hostname, lowercased
///
/// Limited to a-z, 0-9 and dashes. This returns the same result as the
/// deprecated [`whoami::hostname()`](crate::hostname).
pub fn hostname_lower() -> Result<String> {
let mut hostname = hostname()?;

hostname.make_ascii_lowercase();
Ok(hostname)
}

0 comments on commit 0d1ca50

Please sign in to comment.