qubit_codec/transcode/capacity_error.rs
1// =============================================================================
2// Copyright (c) 2026 Haixing Hu.
3//
4// SPDX-License-Identifier: Apache-2.0
5//
6// Licensed under the Apache License, Version 2.0.
7// =============================================================================
8use thiserror::Error;
9
10/// Error reported by output-capacity planning APIs.
11///
12/// Capacity planning is separate from actual transcoding. This error means the
13/// requested upper bound cannot be represented as a `usize`; callers should
14/// reject the one-shot allocation request or switch to chunked streaming.
15///
16/// # Examples
17///
18/// ```
19/// use qubit_codec::CapacityError;
20///
21/// let error = CapacityError::OutputLengthOverflow;
22/// assert_eq!(error.to_string(), "output length overflow");
23/// ```
24#[derive(Clone, Copy, Debug, Eq, Error, Hash, PartialEq)]
25#[non_exhaustive]
26#[must_use]
27pub enum CapacityError {
28 /// The computed output length overflowed `usize`.
29 #[error("output length overflow")]
30 OutputLengthOverflow,
31}