diff --git a/src/fallible.rs b/src/fallible.rs index 64f5bce..2f2b1f1 100644 --- a/src/fallible.rs +++ b/src/fallible.rs @@ -97,3 +97,14 @@ pub fn devicename_os() -> Result { pub fn hostname() -> Result { 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 { + let mut hostname = hostname()?; + + hostname.make_ascii_lowercase(); + Ok(hostname) +}