1#[derive(Debug, thiserror::Error)]
7pub enum CrdtError {
8 #[error("constraint violation: {constraint} on collection `{collection}`: {detail}")]
10 ConstraintViolation {
11 constraint: String,
12 collection: String,
13 detail: String,
14 },
15
16 #[error("delta application failed: {0}")]
18 DeltaApplyFailed(String),
19
20 #[error("loro error: {0}")]
22 Loro(String),
23
24 #[error("dead-letter queue full: capacity {capacity}, pending {pending}")]
26 DlqFull { capacity: usize, pending: usize },
27
28 #[error("unknown collection: {0}")]
30 UnknownCollection(String),
31
32 #[error("auth expired: user {user_id} must re-authenticate (expired at {expired_at})")]
34 AuthExpired { user_id: u64, expired_at: u64 },
35
36 #[error("delta signature invalid for user {user_id}: {detail}")]
38 InvalidSignature { user_id: u64, detail: String },
39
40 #[error(
45 "replay detected for user {user_id} device {device_id}: \
46 seq_no {seq_no} <= last_seen {last_seen}"
47 )]
48 ReplayDetected {
49 user_id: u64,
50 device_id: u64,
51 seq_no: u64,
52 last_seen: u64,
53 },
54}
55
56pub type Result<T> = std::result::Result<T, CrdtError>;