penumbra_sdk_tct/
error.rs1use crate::builder;
5#[cfg(doc)]
6use crate::prelude::*;
7
8#[doc(inline)]
9pub use crate::tree::RootDecodeError;
10
11pub mod proof {
12 #[doc(inline)]
14 pub use crate::internal::{
15 path::PathDecodeError,
16 proof::{ProofDecodeError as DecodeError, VerifyError},
17 };
18}
19
20pub mod block {
21 #[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
25 #[error("could not decode block root")]
26 pub struct RootDecodeError;
27
28 #[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
31 #[error("block is full")]
32 #[non_exhaustive]
33 pub struct InsertError;
34}
35
36pub mod epoch {
37 use super::*;
39
40 #[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
42 #[error("could not decode epoch root")]
43 pub struct RootDecodeError;
44
45 #[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
47 pub enum InsertError {
48 #[error("epoch is full")]
50 #[non_exhaustive]
51 Full,
52 #[error("most recent block in epoch is full")]
54 #[non_exhaustive]
55 BlockFull,
56 }
57
58 #[derive(Debug, Clone, Error)]
60 #[error("epoch is full")]
61 #[non_exhaustive]
62 pub struct InsertBlockError(pub builder::block::Finalized);
63}
64
65#[derive(Debug, Clone, Copy, PartialEq, Eq, Error)]
67pub enum InsertError {
68 #[error("tree is full")]
70 Full,
71 #[error("most recent epoch in tree is full")]
73 EpochFull,
74 #[error("most recent block in most recent epoch of tree is full")]
76 BlockFull,
77}
78
79#[derive(Debug, Clone, Error)]
81pub enum InsertBlockError {
82 #[error("tree is full")]
84 #[non_exhaustive]
85 Full(builder::block::Finalized),
86 #[error("most recent epoch is full")]
88 #[non_exhaustive]
89 EpochFull(builder::block::Finalized),
90}
91
92impl From<InsertBlockError> for builder::block::Finalized {
93 fn from(error: InsertBlockError) -> Self {
94 match error {
95 InsertBlockError::Full(block) => block,
96 InsertBlockError::EpochFull(block) => block,
97 }
98 }
99}
100
101#[derive(Debug, Clone, Error)]
103#[error("tree is full")]
104#[non_exhaustive]
105pub struct InsertEpochError(pub builder::epoch::Finalized);
106
107impl From<InsertEpochError> for builder::epoch::Finalized {
108 fn from(error: InsertEpochError) -> Self {
109 error.0
110 }
111}
112
113#[cfg(test)]
114mod test {
115 use super::*;
116
117 #[test]
118 fn insert_errors_sync_send() {
119 static_assertions::assert_impl_all!(InsertError: Sync, Send);
120 static_assertions::assert_impl_all!(InsertBlockError: Sync, Send);
121 static_assertions::assert_impl_all!(InsertEpochError: Sync, Send);
122 }
123}