Skip to main content

coven_merge/
error.rs

1use crate::{LostKey, RowId, WriteId};
2
3/// Invalid input to the pure merge; no partially changed state is returned.
4#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
5pub enum MergeError {
6    /// Milliseconds do not fit in the timestamp's 48 bits.
7    #[error("milliseconds exceed 48 bits: {0}")]
8    MillisecondsOutOfRange(u64),
9    /// The final millisecond and counter have both been used.
10    #[error("timestamp space exhausted")]
11    TimestampExhausted,
12    /// Advancing a generation would exceed its representation.
13    #[error("generation space exhausted")]
14    GenerationExhausted,
15    /// An insert was not made at an even generation, or an edit/delete at an odd one.
16    #[error("operation has the wrong generation parity: {0}")]
17    GenerationParity(u64),
18    /// No write the author had read moved this row to the specified generation.
19    #[error("generation {generation} of {row:?} was not read by the author")]
20    GenerationNotSeen {
21        /// The row, including its audience.
22        row: RowId,
23        /// The generation the change was made at.
24        generation: u64,
25    },
26    /// Causality has not brought the receiving row to this generation.
27    #[error("change to {row:?} is ahead of the receiving generation")]
28    GenerationAhead {
29        /// The receiving row.
30        row: RowId,
31    },
32    /// A required write is missing from the applied set.
33    #[error("write {0:?} has not been applied")]
34    MissingWrite(WriteId),
35    /// A write occurs twice in the input or has already been applied.
36    #[error("write {0:?} occurs twice")]
37    DuplicateWrite(WriteId),
38    /// Two different writes have equal timestamps.
39    #[error("writes {0:?} and {1:?} have equal timestamps")]
40    DuplicateTimestamp(WriteId, WriteId),
41    /// A timestamp is not larger than that of a write its author had read.
42    #[error("write {0:?} is not stamped after its past")]
43    CausalTimestamp(WriteId),
44    /// A write's recorded past omits a predecessor of a write it had read:
45    /// its `read_through` is below that of its device's last landed write.
46    #[error("write {0:?} has a past that is not causally closed")]
47    CausalClosure(WriteId),
48    /// The timestamp's device is different from the write's device.
49    #[error("timestamp device differs from write {0:?}")]
50    TimestampDevice(WriteId),
51    /// A write's row changes do not include the row passed to `apply`.
52    #[error("write has no change for {0:?}")]
53    MissingChange(RowId),
54    /// A parent generation must name an existing incarnation, an odd generation.
55    #[error("parent generation is not odd: {0}")]
56    ParentGeneration(u64),
57    /// A reference reaches an audience some readers of the child cannot read.
58    #[error("reference from {0:?} reaches an unreadable audience")]
59    ReferenceAudience(RowId),
60    /// The removal view listed a row more than once.
61    #[error("removal view lists {0:?} twice")]
62    #[cfg(any(test, feature = "test-utils"))]
63    DuplicateRow(RowId),
64    /// Stored generations must be contiguous from one through the current one.
65    #[error("stored generation {0} is missing or out of order")]
66    GenerationGap(u64),
67    /// Each generation must be stamped after the preceding generation.
68    #[error("stored generation {0} is not stamped after its predecessor")]
69    GenerationTimestamp(u64),
70    /// A deleted row cannot retain winning cells.
71    #[error("deleted row has winning cells")]
72    DeletedRowHasCells,
73    /// A cell's setter cannot precede the start of its incarnation.
74    #[error("cell {0} precedes its incarnation")]
75    CellBeforeIncarnation(String),
76    /// A lost record has an invalid incarnation or canonical replacer.
77    #[error("invalid lost value {0:?}")]
78    InvalidLostValue(LostKey),
79    /// A required cell of a unique constraint has never been set.
80    #[error("unique constraint column {0} has no winning value")]
81    #[cfg(test)]
82    MissingClaimColumn(String),
83    /// A unique constraint must have at least one column.
84    #[error("unique constraint has no columns")]
85    #[cfg(test)]
86    EmptyClaim,
87}