#hostname #gethostname #sethostname

hostname

Cross-platform system’s host name functions

7 releases

0.2.0 Nov 9, 2019
0.1.5 May 25, 2018
0.1.4 Dec 19, 2017
0.1.3 Feb 9, 2017
0.1.2 Dec 13, 2016

#4 in Operating systems

Download history 26936/week @ 2019-07-27 27502/week @ 2019-08-03 29199/week @ 2019-08-10 27515/week @ 2019-08-17 24739/week @ 2019-08-24 25979/week @ 2019-08-31 25257/week @ 2019-09-07 27423/week @ 2019-09-14 25832/week @ 2019-09-21 27142/week @ 2019-09-28 26104/week @ 2019-10-05 28538/week @ 2019-10-12 28013/week @ 2019-10-19 27355/week @ 2019-10-26 29652/week @ 2019-11-02

116,701 downloads per month
Used in 331 crates (51 directly)

MIT license

10KB
163 lines

hostname

Latest Version Latest Version Build Status Minimum rustc version MIT licensed

Cross-platform system's host name functions in Rust

Supported platforms

  • POSIX-compliant systems
    (Linux, macOS, Android, FreeBSD, OpenBSD, NetBSD, Solaris, Redox, and so on)
  • Windows

Rust version requirements

Since version 0.2.0 this crate requires Rust version 1.19.0 or greater.

This version is explicitly tested in CI and may be bumped in any major or minor release as needed.
Maintaining compatibility with older compilers is a priority though, so the bar for bumping the minimum supported version is set very high. Any changes to the supported minimum version will be called out in the release notes.

Usage

Add the following dependency to your Cargo manifest:

[dependencies]
hostname = "^0.2"

Crate API provides two simple functions for retrieving and setting the system's host name:

use std::io;

fn main() -> io::Result<()> {
    // Retrieve the hostname
    dbg!(hostname::get()?);

    // And set a new one
    hostname::set("potato")?;

    Ok(())
}

License

hostname is primarily distributed under the terms of the MIT license (LICENSE or http://opensource.org/licenses/MIT).

Dependencies

~39KB