Function hostname

fn hostname() -> Result<OsString>

Returns the system hostname.

This can error out in platform-specific error cases; for example, uefi and wasm, where hostnames aren't supported.

Underlying system calls

Platform System call
UNIX gethostname
Windows (8+) GetHostNameW

Note that platform-specific behavior may change in the future.