-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fallible for
username()
, realname()
and _os
varaints
- Loading branch information
1 parent
188c446
commit 7a0de2b
Showing
6 changed files
with
89 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
//! Fallible versions of the whoami APIs. | ||
//! | ||
//! Some of the functions in the root module will return "Unknown" on error. | ||
//! This might not be desirable in some situations. The functions in this | ||
//! module all return a [`Result`]. | ||
|
||
use std::ffi::OsString; | ||
|
||
use crate::{platform, Result}; | ||
|
||
/// Get the user's username. | ||
/// | ||
/// On unix-systems this differs from [`realname()`] most notably in that spaces | ||
/// are not allowed. | ||
#[inline(always)] | ||
pub fn username() -> Result<String> { | ||
platform::username() | ||
} | ||
|
||
/// Get the user's username. | ||
/// | ||
/// On unix-systems this differs from [`realname()`] most notably in that spaces | ||
/// are not allowed. | ||
#[inline(always)] | ||
pub fn username_os() -> Result<OsString> { | ||
platform::username_os() | ||
} | ||
|
||
/// Get the user's real (full) name. | ||
#[inline(always)] | ||
pub fn realname() -> Result<String> { | ||
platform::realname() | ||
} | ||
|
||
/// Get the user's real (full) name. | ||
#[inline(always)] | ||
pub fn realname_os() -> Result<OsString> { | ||
platform::realname_os() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters