summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Osborne <osbpau@gmail.com>2016-10-27 19:36:29 -0400
committerPaul Osborne <osbpau@gmail.com>2016-10-27 19:36:29 -0400
commit7b9e9e572ce8aadc755c5925325440e9f8edcf4d (patch)
tree31a2690fd897853c6796179faca4ac6a6108084a
parent8d0e312844fb7372f20efc022187f1c493672059 (diff)
downloadnix-7b9e9e572ce8aadc755c5925325440e9f8edcf4d.zip
error: add documentation for nix::Error
Signed-off-by: Paul Osborne <paul.osborne@smartthings.com>
-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,