pyrus_cert_store/
error.rs

1//! [`StoreError`] type and [`Result<T>`] type specialization.
2
3use thiserror::Error;
4
5/// Error type used for all fallible operations.
6///
7/// It is recommended to use [`anyhow`](https://docs.rs/anyhow/latest/anyhow/) 
8/// for easy error handling or error propagation.
9#[non_exhaustive]
10#[derive(Error, Debug)]
11pub enum StoreError {
12    /// Argon2 password hashing error. Only applicable if using an encrypted 
13    /// cert store.
14    #[error("Argon2 password hashing error.")]
15    Argon2Error(#[from] argon2::Error),
16    /// Propagates the error from `pyrus_crypto`. Serialization error is the 
17    /// only possible error to occur in this crate, thus the name.
18    #[error("Error while serializing a certificate.")]
19    CertSerializationError(#[from] pyrus_crypto::error::CryptoError),
20    /// Error indicating invalid Argon2 parameters. 
21    /// See [`CertStoreConn::with_params`](crate::connection::CertStoreConn::with_params) 
22    /// for more info.
23    #[error("Invalid Argon2 parameters supplied.")]
24    InvalidParams,
25    /// Occurs when the store path cannot be converted to a C-compatible string.
26    #[error("The path for the database connection is invalid.")]
27    InvalidPath,
28    /// Serialization error. See [`postcard::Error`] for more details.
29    #[error("Serialization error.")]
30    SerializationError(#[from] postcard::Error),
31    /// Most common error in this library. Propagates [`rusqlite::Error`].
32    #[error("Underlying SQLite call failure.")]
33    SQLiteFail(#[from] rusqlite::Error),
34}
35
36/// [`Result<T, E>`](std::result::Result) type specialization.
37pub type Result<T> = std::result::Result<T, StoreError>;