1use core::fmt;
4
5#[derive(Copy, Clone, Debug, PartialEq, Eq, thiserror::Error)]
10pub enum Error {
11 #[error("attempted tabulation of a value in the past of the previous tabulation")]
14 Causality,
15 #[error("attempted tabulation of a value with negative weight")]
17 NegativeWeight,
18 #[error("insufficient space in storage")]
20 InsufficientSpace,
21}
22
23#[derive(Debug, PartialEq, Eq, thiserror::Error)]
28#[error(
29 "tabulated value at model-time {cause:?} (cause) happens before \
30 model-time {effect:?} (effect), violating causality"
31)]
32pub struct Causality<T> {
33 pub cause: T,
35 pub effect: T,
37}
38
39impl<T> From<Causality<T>> for Error {
40 #[inline]
41 fn from(_: Causality<T>) -> Self {
42 Error::Causality
43 }
44}
45
46#[derive(Debug, PartialEq, Eq, thiserror::Error)]
49#[error("tabulated value has negative weight {weight:?}")]
50pub struct NegativeWeight<W> {
51 pub weight: W,
53}
54
55impl<W> From<NegativeWeight<W>> for Error {
56 #[inline]
57 fn from(_: NegativeWeight<W>) -> Self {
58 Error::NegativeWeight
59 }
60}
61
62#[derive(PartialEq, Eq, thiserror::Error)]
64#[error("insufficient space in storage")]
65pub struct InsufficientSpace<B>(pub B);
66
67impl<B> fmt::Debug for InsufficientSpace<B> {
68 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
69 f.write_str("Insufficient space in storage")
70 }
71}
72
73impl<B> From<InsufficientSpace<B>> for Error {
74 #[inline]
75 fn from(_: InsufficientSpace<B>) -> Self {
76 Error::InsufficientSpace
77 }
78}