Rename InitFailure to InitError and add documentation

This commit is contained in:
Mika Attila 2015-11-03 00:52:13 +01:00
parent 503eee4441
commit ba947a35f8

View File

@ -31,9 +31,10 @@ use gtypes::{TRUE, FALSE};
/// Error that can happen on context creation /// Error that can happen on context creation
#[derive(Debug)] #[derive(Debug)]
pub enum ContextCreationError { pub enum ContextCreationError {
/// Context already exists /// Context already exists.
AlreadyExists, AlreadyExists,
InitFailure, /// Failed to initialize libnotify.
InitError,
NulError, NulError,
} }
@ -42,7 +43,7 @@ impl fmt::Display for ContextCreationError {
use ContextCreationError::*; use ContextCreationError::*;
match *self { match *self {
AlreadyExists => write!(f, "A Libnotify context already exists."), AlreadyExists => write!(f, "A Libnotify context already exists."),
InitFailure => write!(f, "Failed to initialize libnotify."), InitError => write!(f, "Failed to initialize libnotify."),
NulError => write!(f, "Argument contains a nul character."), NulError => write!(f, "Argument contains a nul character."),
} }
} }
@ -85,7 +86,7 @@ impl Context {
Err(_) => return Err(ContextCreationError::NulError), Err(_) => return Err(ContextCreationError::NulError),
}; };
if sys::notify_init(app_name.as_ptr()) == FALSE { if sys::notify_init(app_name.as_ptr()) == FALSE {
return Err(ContextCreationError::InitFailure); return Err(ContextCreationError::InitError);
} }
} }
Ok(Context) Ok(Context)