Skip to main content

qubit_codec_binary/codec/
leb128_decode_policy.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// =============================================================================
8
9use super::internal::sealed::Sealed;
10
11/// Describes a type-level LEB128 decoding policy.
12///
13/// This trait is sealed because the current LEB128 decoder only supports the
14/// two built-in canonicality modes represented by [`crate::Strict`] and
15/// [`crate::NonStrict`].
16///
17/// ```compile_fail
18/// use qubit_codec_binary::Leb128DecodePolicy;
19///
20/// #[derive(Clone, Copy, Default)]
21/// struct ExternalPolicy;
22///
23/// impl Leb128DecodePolicy for ExternalPolicy {
24///     const STRICT: bool = false;
25/// }
26/// ```
27pub trait Leb128DecodePolicy: Sealed + Copy + Default {
28    /// Whether this policy rejects non-canonical encodings.
29    const STRICT: bool;
30}