diff --git a/src/lib.rs b/src/lib.rs index 05c4460..0a05d76 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,7 +3,7 @@ //! # Examples //! //! ``` -//! # fn try_main() -> Result<(), keepawake::Error> { +//! # fn try_main() -> keepawake::Result<()> { //! let _awake = keepawake::Builder::default() //! .display(true) //! .reason("Video playback") @@ -16,7 +16,7 @@ //! ``` //! //! ``` -//! # fn try_main() -> Result<(), keepawake::Error> { +//! # fn try_main() -> keepawake::Result<()> { //! let _awake = keepawake::Builder::default() //! .display(true) //! .idle(true) @@ -35,15 +35,22 @@ mod sys; #[cfg(feature = "capi")] pub mod capi; +/// A system error whose actual type varies by target. +pub use sys::Error as SystemError; + +/// Error type. #[derive(Error, Debug)] pub enum Error { #[error("builder: {0}")] Builder(#[from] BuilderError), #[error("system: {0}")] - System(#[from] sys::Error), + System(#[from] SystemError), } +/// A specialized [`Result`](std::result::Result) type for this crate. +pub type Result = std::result::Result; + #[derive(Builder, Debug)] #[builder(public, name = "Builder", build_fn(private))] #[allow(dead_code)] // Some fields are unused on some platforms @@ -79,7 +86,7 @@ struct Options { impl Builder { /// Create the [`KeepAwake`]. - pub fn create(&self) -> Result { + pub fn create(&self) -> Result { Ok(KeepAwake { _imp: sys::KeepAwake::new(self.build()?)?, })