hopr-types 1.8.0

Complete collection of Rust types used in Hoprnet and other related projects
Documentation
use thiserror::Error;

/// Type for any possible error, because the traits in this module
/// can be used in with any possible contexts (and error types).
pub type AnyError = Box<dyn std::error::Error + Send + Sync + 'static>;

/// Listing of some general re-usable errors
#[derive(Error, Debug, PartialEq)]
pub enum GeneralError {
    #[error("failed to parse/deserialize the data: {0}")]
    ParseError(String),

    #[error("input argument to the function is invalid")]
    InvalidInput,

    #[error("non-specific error: {0}")]
    NonSpecificError(String),
}

/// Convenience type alias for `Result` with [`GeneralError`] as the error type.
pub type Result<T> = core::result::Result<T, GeneralError>;