toasty_core/error/
read_only_transaction.rs1use super::Error;
2
3#[derive(Debug)]
4pub(super) struct ReadOnlyTransaction {
5 message: Box<str>,
6}
7
8impl std::error::Error for ReadOnlyTransaction {}
9
10impl core::fmt::Display for ReadOnlyTransaction {
11 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
12 write!(f, "read-only transaction: {}", self.message)
13 }
14}
15
16impl Error {
17 pub fn read_only_transaction(message: impl Into<String>) -> Error {
22 Error::from(super::ErrorKind::ReadOnlyTransaction(ReadOnlyTransaction {
23 message: message.into().into(),
24 }))
25 }
26
27 pub fn is_read_only_transaction(&self) -> bool {
29 matches!(self.kind(), super::ErrorKind::ReadOnlyTransaction(_))
30 }
31}