qubit_codec_binary/codec/leb128_decode_error_kind.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/// Classifies failures detected while decoding LEB128 integers.
11///
12/// # Examples
13///
14/// ```
15/// use qubit_codec_binary::Leb128DecodeErrorKind;
16///
17/// let kind = Leb128DecodeErrorKind::NonCanonical;
18/// assert_eq!(kind.to_string(), "non-canonical LEB128 integer");
19/// ```
20#[must_use]
21#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
22pub enum Leb128DecodeErrorKind {
23 /// The input ended before a terminating LEB128 byte was available.
24 #[error("incomplete LEB128 integer")]
25 Incomplete,
26
27 /// The input bytes cannot represent a value of the requested width.
28 #[error("malformed LEB128 integer")]
29 Malformed,
30
31 /// Strict decoding rejected a value that was not minimally encoded.
32 #[error("non-canonical LEB128 integer")]
33 NonCanonical,
34}