frp_persistence/error.rs
1use thiserror::Error;
2
3use frp_loom::error::StoreError;
4
5/// Errors produced internally by [`InfiniteDbStore`](crate::store::InfiniteDbStore).
6///
7/// All variants implement `Into<StoreError>` so that they can be propagated
8/// through the `frp-loom` store traits.
9#[derive(Debug, Error)]
10pub enum PersistenceError {
11 /// An error returned by the `infinite-db` engine.
12 #[error("database error: {0}")]
13 Db(String),
14
15 /// Serialization of a domain value to bytes failed.
16 #[error("serialize error: {0}")]
17 Serialize(String),
18
19 /// Deserialization of bytes from the database failed.
20 #[error("deserialize error: {0}")]
21 Deserialize(String),
22}
23
24impl From<PersistenceError> for StoreError {
25 fn from(e: PersistenceError) -> Self {
26 StoreError::Io(e.to_string())
27 }
28}