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#[derive(Clone, Copy, Debug, Eq, Error, PartialEq)]
12pub enum Leb128DecodeErrorKind {
13 /// The input ended before a terminating LEB128 byte was available.
14 #[error("incomplete LEB128 integer")]
15 Incomplete,
16
17 /// The input bytes cannot represent a value of the requested width.
18 #[error("malformed LEB128 integer")]
19 Malformed,
20
21 /// Strict decoding rejected a value that was not minimally encoded.
22 #[error("non-canonical LEB128 integer")]
23 NonCanonical,
24}