Skip to content

Commit

Permalink
Add documentation for how to do the equivalent of gethostname. (#880)
Browse files Browse the repository at this point in the history
Add documentation showing how to get the `gethostname` value using
`uname`.
  • Loading branch information
sunfishcode committed Oct 18, 2023
1 parent 3a53dfe commit 702c54a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/system.rs
Expand Up @@ -20,6 +20,8 @@ pub use backend::system::types::Sysinfo;
/// `uname()`—Returns high-level information about the runtime OS and
/// hardware.
///
/// For `gethostname()`, use [`Uname::nodename`] on the result.
///
/// # References
/// - [POSIX]
/// - [Linux]
Expand All @@ -40,6 +42,7 @@ pub use backend::system::types::Sysinfo;
/// [DragonFly BSD]: https://man.dragonflybsd.org/?command=uname&section=3
/// [illumos]: https://illumos.org/man/2/uname
/// [glibc]: https://www.gnu.org/software/libc/manual/html_node/Platform-Type.html
#[doc(alias = "gethostname")]
#[inline]
pub fn uname() -> Uname {
Uname(backend::system::syscalls::uname())
Expand All @@ -61,6 +64,8 @@ impl Uname {
/// This is intended to be a network name, however it's unable to convey
/// information about hosts that have multiple names, or any information
/// about where the names are visible.
///
/// This corresponds to the `gethostname` value.
#[inline]
pub fn nodename(&self) -> &CStr {
Self::to_cstr(self.0.nodename.as_ptr().cast())
Expand Down

0 comments on commit 702c54a

Please sign in to comment.