summaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-10-30 06:52:19 +0900
committerHomu <homu@barosl.com>2016-10-30 06:52:19 +0900
commitff4484d343dbd8f224d767b4499cc502c4c7f016 (patch)
tree866d224c706f369513be98d81dc242731703ca25 /src/lib.rs
parentb05c1e4f385107357c65575594ac72378e9ae6c3 (diff)
parentfdf8ab6d2ea107b3cbe7cba70f64a79c2c4fc4d0 (diff)
downloadnix-ff4484d343dbd8f224d767b4499cc502c4c7f016.zip
Auto merge of #449 - posborne:documentation-improvements, r=kamalmarhubi
Documentation improvements This series of commits starts to fill in documentation that was not previously present for various calls, mostly in unistd for this pass. r? @kamalmarhubi
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 8dbf9fe0..ab8339ef 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -77,8 +77,16 @@ use std::fmt;
use std::error;
use libc::PATH_MAX;
+/// Nix Result Type
pub type Result<T> = result::Result<T, Error>;
+/// Nix Error Type
+///
+/// The nix error type provides a common way of dealing with
+/// various system system/libc calls that might fail. Each
+/// error has a corresponding errno (usually the one from the
+/// underlying OS) to which it can be mapped in addition to
+/// implementing other common traits.
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Error {
Sys(errno::Errno),
@@ -86,18 +94,23 @@ pub enum Error {
}
impl Error {
+
+ /// Create a nix Error from a given errno
pub fn from_errno(errno: errno::Errno) -> Error {
Error::Sys(errno)
}
+ /// Get the current errno and convert it to a nix Error
pub fn last() -> Error {
Error::Sys(errno::Errno::last())
}
+ /// Create a new invalid argument error (`EINVAL`)
pub fn invalid_argument() -> Error {
Error::Sys(errno::EINVAL)
}
+ /// Get the errno associated with this error
pub fn errno(&self) -> errno::Errno {
match *self {
Error::Sys(errno) => errno,