Document other_errors

This commit is contained in:
Marcel Müller
2020-07-31 11:56:50 +02:00
parent 75f2a5bd77
commit 1ef789a31c
3 changed files with 22 additions and 1 deletions
+2
View File
@@ -17,6 +17,8 @@ use crate::error;
/// It should always read and save in full the data that it is passed. This
/// means that a write to the backend followed by a read __must__ return the
/// same dataset.
///
/// **Important**: You can only return custom errors if the `other_errors` feature is enabled
pub trait Backend {
/// Read the all data from the backend.
fn get_data(&mut self) -> error::BackendResult<Vec<u8>>;
+2
View File
@@ -68,6 +68,8 @@ pub use self::bincode::Bincode;
///
/// fn main() {}
/// ```
///
/// **Important**: You can only return custom errors if the `other_errors` feature is enabled
pub trait DeSerializer<T: Serialize + DeserializeOwned>:
std::default::Default + Send + Sync + Clone
{
+18 -1
View File
@@ -19,8 +19,16 @@ pub enum DeSerError {
/// An error occured with Bincode
#[error("An error with Bincode occured")]
Bincode(#[from] std::boxed::Box<bincode::ErrorKind>),
/// An internal error to Rustbreak occured
#[error("An internal error to rustbreak occured, please report it to the maintainers")]
Internal(String),
#[cfg(feature = "other_errors")]
/// An error occured with Bincode
/// A dynamic error occured
///
/// Most likely the custom `DeSer` implementation has thrown an error, consult its documentation
/// for more information
///
/// **Important**: This can only be used if the `other_errors` feature is enabled
#[error(transparent)]
Other(#[from] anyhow::Error),
}
@@ -38,6 +46,15 @@ pub enum BackendError {
/// An internal error to Rustbreak occured
#[error("An internal error to rustbreak occured, please report it to the maintainers")]
Internal(String),
#[cfg(feature = "other_errors")]
/// A dynamic error occured
///
/// Most likely the custom `Backend` implementation has thrown an error, consult its documentation
/// for more information
///
/// **Important**: This can only be used if the `other_errors` feature is enabled
#[error(transparent)]
Other(#[from] anyhow::Error),
}
/// The different kinds of errors that can be returned