| Crates.io | os-interface |
| lib.rs | os-interface |
| version | 0.2.1 |
| created_at | 2025-12-26 17:42:46.852364+00 |
| updated_at | 2025-12-30 17:02:32.644371+00 |
| description | Interface to retrieve OS information. |
| homepage | https://github.com/cmasus/os-interface |
| repository | https://github.com/cmasus/os-interface |
| max_upload_size | |
| id | 2005994 |
| size | 30,192 |
Crate holding easy to use functions for retrieving information from the operating system.
PR contributions are welcome. Contributions could be in the form of improvements to existing functionality, adding new functionality or adding support for other operating systems.
Example usage
use os_interface::network::network_interfaces;
fn main() {
let network_interfaces = network_interfaces().unwrap();
println!("Network interfaces: {:#?}", network_interfaces);
}
gives an output similar to the following
Network interfaces: [
NetworkInterface {
index: 1,
name: "lo",
addr: [
IPv4(
IfAddrV4 {
ip: 127.0.0.1,
netmask: Some(
255.0.0.0,
),
broadcast: None,
},
),
IPv6(
IfAddrV6 {
ip: ::1,
netmask: Some(
ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff,
),
},
),
],
mac_addr: Some(
"00:00:00:00:00:00",
),
flags: Flags {
up: true,
loopback: true,
running: true,
multicast: false,
broadcast: false,
},
},
...
]
| function | linux | macos | windows | freebsd | android | ios |
|---|---|---|---|---|---|---|
| network_interfaces() | yes | yes | no | yes | yes | yes |
| local_ipv4_addresses() | yes | yes | no | yes | yes | yes |
| local_ipv6_addresses() | yes | yes | no | yes | yes | yes |
| hostname() | yes | yes | no | yes | yes | yes |
Distributed under the terms of both the MIT license and the Apache License (Version 2.0)