10 releases

0.4.0 Apr 1, 2024
0.3.1 Feb 28, 2020
0.3.0 Dec 19, 2019
0.2.0 Nov 9, 2019
0.1.2 Dec 13, 2016

#13 in Operating systems

Download history 516304/week @ 2024-07-17 535018/week @ 2024-07-24 519748/week @ 2024-07-31 566176/week @ 2024-08-07 536834/week @ 2024-08-14 572825/week @ 2024-08-21 559135/week @ 2024-08-28 623514/week @ 2024-09-04 598683/week @ 2024-09-11 754328/week @ 2024-09-18 799175/week @ 2024-09-25 1165010/week @ 2024-10-02 1200446/week @ 2024-10-09 1222070/week @ 2024-10-16 759260/week @ 2024-10-23 689263/week @ 2024-10-30

4,107,051 downloads per month
Used in 1,562 crates (224 directly)

MIT license

13KB
226 lines

hostname

Latest Version Latest Version Build Status Minimum rustc version MIT licensed Crates.io

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.4.0 this crate requires Rust version 1.67.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.4"

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

~0–35MB
~523K SLoC