use thiserror::Error;
use crate::errors::WalError;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum WroteCommit {
Yes,
No,
}
impl WroteCommit {
pub fn wrote(self) -> bool {
matches!(self, Self::Yes)
}
}
#[derive(Debug, Error)]
pub enum WalCommitError {
#[error("WAL commit failed: {0}")]
Commit(#[source] WalError),
#[error("WAL flush failed: {0}")]
Flush(#[source] WalError),
}
#[derive(Debug, Error)]
#[error("WAL poisoned: {reason}")]
pub struct WalPoisonError {
pub(super) reason: String,
}
impl WalPoisonError {
pub fn reason(&self) -> &str {
&self.reason
}
}
#[derive(Debug, Error)]
pub enum WalBufferedCommitError {
#[error("WAL arm failed: {0}")]
Arm(#[source] WalError),
#[error("WAL poisoned: {0}")]
Poisoned(String),
#[error("WAL poisoned during commit replay: {0}")]
ReplayPoisoned(String),
#[error(transparent)]
Commit(#[from] WalCommitError),
}