redoubt_alloc/
error.rs

1// Copyright (c) 2025-2026 Federico Hoerth <memparanoid@gmail.com>
2// SPDX-License-Identifier: GPL-3.0-only
3// See LICENSE in the repository root for full license text.
4
5//! Error types for redoubt-alloc.
6
7use thiserror::Error;
8
9/// Error type for `AllockedVec` operations.
10#[derive(Debug, Error, Eq, PartialEq)]
11pub enum AllockedVecError {
12    /// Attempted to reserve capacity on an already-sealed vector.
13    #[error("Vector is already sealed and cannot be resized")]
14    AlreadySealed,
15
16    /// Integer overflow when computing new length.
17    ///
18    /// This error is practically impossible to encounter in normal usage,
19    /// as it would require a vector with length approaching `isize::MAX`.
20    /// It exists as a defensive check for integer overflow safety.
21    #[error("Integer overflow: total length would exceed usize::MAX")]
22    Overflow,
23
24    /// Attempted to push beyond the vector's capacity.
25    #[error("Capacity exceeded: cannot push beyond sealed capacity")]
26    CapacityExceeded,
27}
28
29/// Error type for `RedoubtOption` operations.
30#[derive(Debug, Error, Eq, PartialEq)]
31pub enum RedoubtOptionError {
32    /// Attempted to access value when option is empty.
33    #[error("RedoubtOption is empty")]
34    Empty,
35}