Crates.io | hostname |
lib.rs | hostname |
version | 0.4.0 |
source | src |
created_at | 2016-12-13 12:47:54.090323 |
updated_at | 2024-04-01 09:45:59.615561 |
description | Cross-platform system's host name functions |
homepage | |
repository | https://github.com/svartalf/hostname |
max_upload_size | |
id | 7563 |
size | 35,939 |
Cross-platform system's host name functions in Rust
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.
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(())
}
hostname is primarily distributed under the terms of the MIT license (LICENSE or http://opensource.org/licenses/MIT).