diff options
author | Paul Osborne <osbpau@gmail.com> | 2016-10-27 19:36:29 -0400 |
---|---|---|
committer | Paul Osborne <osbpau@gmail.com> | 2016-10-27 19:36:29 -0400 |
commit | 7b9e9e572ce8aadc755c5925325440e9f8edcf4d (patch) | |
tree | 31a2690fd897853c6796179faca4ac6a6108084a | |
parent | 8d0e312844fb7372f20efc022187f1c493672059 (diff) | |
download | nix-7b9e9e572ce8aadc755c5925325440e9f8edcf4d.zip |
error: add documentation for nix::Error
Signed-off-by: Paul Osborne <paul.osborne@smartthings.com>
-rw-r--r-- | src/lib.rs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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, |