Skip to main content

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    /// The selected replication log does not implement snapshots.
57    SnapshotUnsupported,
58    /// A snapshot failed integrity or structural validation.
59    InvalidSnapshot(&'static str),
60    /// A peer identifier is empty or contains unsupported characters.
61    InvalidPeerId,
62    /// A peer seed cannot be parsed as a supported host and port.
63    InvalidPeerAddress,
64    /// A peer seed uses a transport scheme unsupported by sync.
65    UnsupportedPeerScheme,
66    /// A DNS seed could not be resolved.
67    DnsResolutionFailed(String),
68    /// TLS setup or negotiation failed.
69    TlsFailed(String),
70    /// A replication-log read started beyond the current log length.
71    LogIndexOutOfBounds {
72        /// Requested zero-based offset.
73        index: usize,
74        /// Current log length.
75        len: usize,
76    },
77    /// A synchronization primitive was poisoned.
78    LockPoisoned(&'static str),
79    /// A wire message violated a sync invariant.
80    InvalidSyncMessage(&'static str),
81    /// An event payload is not valid hexadecimal data.
82    InvalidEventHex,
83    /// A durable replication-log record is malformed.
84    CorruptReplicationLog {
85        /// One-based line containing the invalid record.
86        line: usize,
87        /// Stable description of the violated record format.
88        reason: &'static str,
89    },
90    /// A durable outbox record is malformed.
91    CorruptOutbox {
92        /// One-based line containing the invalid record.
93        line: usize,
94    },
95    /// Leader-election state could not be advanced.
96    ElectionFailed(String),
97    /// Replication persistence or application failed.
98    ReplicationFailed(String),
99    /// A requested peer is absent from the current directory.
100    PeerNotFound(String),
101}