Skip to main content

spatialrust_records/
error.rs

1//! Errors for versioned spatial records and chunked streams.
2
3/// Result type for record and stream operations.
4pub type RecordsResult<T> = Result<T, RecordsError>;
5
6/// Shared record/stream failures.
7#[derive(Debug, thiserror::Error)]
8pub enum RecordsError {
9    /// Invalid public configuration.
10    #[error("invalid record configuration: {0}")]
11    InvalidConfiguration(String),
12    /// Schema identifiers or versions are incompatible.
13    #[error("schema mismatch: {0}")]
14    SchemaMismatch(String),
15    /// A required field is missing during migration.
16    #[error("missing required field `{0}`")]
17    MissingField(String),
18    /// A tracked allocation would exceed the configured streaming memory budget.
19    #[error(
20        "streaming memory budget exceeded: requested {requested} bytes with {current} bytes \
21         already reserved (limit {limit} bytes)"
22    )]
23    MemoryBudgetExceeded {
24        /// Additional bytes requested by the operation.
25        requested: u64,
26        /// Bytes already reserved when the request was made.
27        current: u64,
28        /// Configured hard limit.
29        limit: u64,
30    },
31    /// A streaming counter exceeded the representable receipt range.
32    #[error("streaming receipt counter overflow: {0}")]
33    ReceiptOverflow(String),
34    /// A versioned streaming receipt did not satisfy its schema contract.
35    #[error("invalid streaming receipt: {0}")]
36    InvalidReceipt(String),
37    /// Cooperative cancellation was observed at a streaming boundary.
38    #[error("streaming operation cancelled")]
39    Cancelled,
40    /// A source emitted a chunk that violates its declared stream contract.
41    #[error("invalid streaming chunk: {0}")]
42    InvalidChunk(String),
43    /// A background stream ended without an explicit end marker.
44    #[error("streaming channel closed unexpectedly")]
45    StreamClosed,
46    /// Wrapped core spatial failure.
47    #[error(transparent)]
48    Spatial(#[from] spatialrust_core::SpatialError),
49}