https://github.com/svartalf/hostname
Cross-platform hostname functions in Rust
https://github.com/svartalf/hostname
hostname posix rust rust-lang unix windows
Last synced: 25 days ago
JSON representation
Cross-platform hostname functions in Rust
- Host: GitHub
- URL: https://github.com/svartalf/hostname
- Owner: svartalf
- License: mit
- Created: 2016-12-13T12:29:09.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-04-07T15:24:13.000Z (about 1 year ago)
- Last Synced: 2025-03-28T20:09:17.331Z (about 1 month ago)
- Topics: hostname, posix, rust, rust-lang, unix, windows
- Language: Rust
- Homepage: https://crates.io/crates/hostname
- Size: 27.3 KB
- Stars: 63
- Watchers: 2
- Forks: 23
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# hostname
[](https://crates.io/crates/hostname)
[](https://docs.rs/hostname)
[](https://github.com/svartalf/hostname/actions)


> Cross-platform system's host name functions in Rust
## Supported platforms
* [POSIX-compliant](https://en.wikipedia.org/wiki/POSIX#POSIX-oriented_operating_systems) 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:
```toml
[dependencies]
hostname = "^0.4"
```Crate API provides two simple functions for retrieving and setting the system's host name:
```rust
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](LICENSE) or http://opensource.org/licenses/MIT).