appcore_sync/sync/error.rs
1// =============================================================================
2// #######
3// ### ### F: error.rs
4// ## ## ## ## P: AppCore-Runtime
5// ## ##
6// C: 2026/06/02 13:08:16 by dnettoRaw
7// ## ## ## ## U: 2026/07/24 16:07:49 by dnettoRaw
8// ########### S: 1.0.1-rc.8
9// =============================================================================
10
11//! Sync-local typed errors.
12
13pub(crate) const UPDATE_REQUIRED_MESSAGE: &str = "NO MORE SUPPORTED PLEASE UPDATE";
14
15/// Sync-local result type.
16pub type SyncResult<T> = Result<T, SyncError>;
17
18/// Sync-local typed errors.
19#[derive(Debug, Clone, PartialEq, Eq)]
20pub enum SyncError {
21 /// The remote peer does not share the local application sync identity.
22 IncompatiblePeer,
23 /// A transport operation failed for the supplied reason.
24 TransportFailed(String),
25 /// A transport operation exceeded its configured deadline.
26 TransportTimeout(String),
27 /// The remote HTTP endpoint returned a non-success status.
28 HttpStatus(u16),
29 /// The remote endpoint closed the connection without a response.
30 EmptyHttpResponse,
31 /// A sync request did not contain a body.
32 EmptyRequestBody,
33 /// An outbound request exceeded the configured byte limit.
34 RequestBodyTooLarge {
35 /// Actual encoded body size in bytes.
36 size: usize,
37 /// Maximum accepted body size in bytes.
38 max: usize,
39 },
40 /// An inbound response exceeded the configured byte limit.
41 ResponseTooLarge {
42 /// Maximum accepted response size in bytes.
43 max: usize,
44 },
45 /// A batch contained more events than the receiver accepts.
46 TooManyEvents {
47 /// Number of events found in the batch.
48 count: usize,
49 /// Maximum accepted event count.
50 max: usize,
51 },
52 /// A sequence does not continue or validly overlap the checkpoint.
53 InvalidSequence(u64),
54 /// A sequence already exists with different payload bytes.
55 SequenceConflict(u64),
56 /// A UI-visible conflict could not be recorded or validated.
57 InvalidConflict(String),
58 /// A requested conflict is not present in the bounded conflict store.
59 ConflictNotFound(String),
60 /// A conflict already has a different idempotent resolution.
61 ConflictAlreadyResolved(String),
62 /// The bounded conflict store cannot retain another conflict.
63 ConflictStoreFull,
64 /// A resumable sync chunk violated its bounded range or digest contract.
65 InvalidChunk(String),
66 /// A chunk overlaps previously accepted bytes with different content.
67 ChunkConflict(u64),
68 /// A chunk assembly is not complete yet.
69 ChunkIncomplete,
70 /// The selected replication log does not implement snapshots.
71 SnapshotUnsupported,
72 /// A snapshot failed integrity or structural validation.
73 InvalidSnapshot(&'static str),
74 /// A peer identifier is empty or contains unsupported characters.
75 InvalidPeerId,
76 /// A peer seed cannot be parsed as a supported host and port.
77 InvalidPeerAddress,
78 /// A peer seed uses a transport scheme unsupported by sync.
79 UnsupportedPeerScheme,
80 /// A DNS seed could not be resolved.
81 DnsResolutionFailed(String),
82 /// TLS setup or negotiation failed.
83 TlsFailed(String),
84 /// A replication-log read started beyond the current log length.
85 LogIndexOutOfBounds {
86 /// Requested zero-based offset.
87 index: usize,
88 /// Current log length.
89 len: usize,
90 },
91 /// A synchronization primitive was poisoned.
92 LockPoisoned(&'static str),
93 /// A wire message violated a sync invariant.
94 InvalidSyncMessage(&'static str),
95 /// An additive outbox operation is unavailable on this provider.
96 OutboxOperationUnsupported(&'static str),
97 /// An event payload is not valid hexadecimal data.
98 InvalidEventHex,
99 /// A durable replication-log record is malformed.
100 CorruptReplicationLog {
101 /// One-based line containing the invalid record.
102 line: usize,
103 /// Stable description of the violated record format.
104 reason: &'static str,
105 },
106 /// A durable outbox record is malformed.
107 CorruptOutbox {
108 /// One-based line containing the invalid record.
109 line: usize,
110 },
111 /// Leader-election state could not be advanced.
112 ElectionFailed(String),
113 /// Replication persistence or application failed.
114 ReplicationFailed(String),
115 /// A requested peer is absent from the current directory.
116 PeerNotFound(String),
117}