File: README.md

package info (click to toggle)
rust-coreutils 0.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 505,620 kB
  • sloc: ansic: 103,594; asm: 28,570; sh: 8,910; python: 5,581; makefile: 472; cpp: 97; javascript: 72
file content (56 lines) | stat: -rw-r--r-- 1,755 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# hostname

[![Latest Version](https://img.shields.io/crates/v/hostname.svg)](https://crates.io/crates/hostname)
[![Latest Version](https://docs.rs/hostname/badge.svg)](https://docs.rs/hostname)
[![Build Status](https://github.com/djc/hostname/actions/workflows/ci.yml/badge.svg)](https://github.com/djc/hostname/actions)
![Minimum rustc Version](https://img.shields.io/badge/rustc-1.74+-green.svg)
![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg)
![crates.io](https://img.shields.io/crates/d/hostname)

> 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.74` 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 https://opensource.org/license/mit).