1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! # Qubit Binary Codec
//!
//! Buffer-oriented binary codecs for Rust.
//!
//! This crate provides fixed-width scalar, LEB128, and ZigZag codecs for
//! caller-managed byte buffers. Stream-oriented readers and writers live in
//! `qubit-io-binary`.
//!
//! # Checked single-value conversion
//!
//! For ordinary one-value conversion, prefer
//! [`qubit_codec::CodecValueEncoder`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/struct.CodecValueEncoder.html)
//! and [`qubit_codec::CodecValueDecoder`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/struct.CodecValueDecoder.html).
//! These checked adapters own the temporary buffer and keep the unsafe
//! boundary inside the adapter:
//!
//! ```
//! use qubit_codec::{CodecValueDecoder, CodecValueEncoder, ValueEncoder};
//! use qubit_codec_binary::{Leb128Codec, NonStrict, Strict};
//!
//! let mut encoder = CodecValueEncoder::new(Leb128Codec::<u64, NonStrict>::default());
//! let encoded = encoder.encode(&300).expect("u64 is always encodable");
//!
//! let mut decoder = CodecValueDecoder::new(Leb128Codec::<u64, Strict>::default());
//! let decoded = decoder.decode(&encoded).expect("the encoding is canonical");
//! assert_eq!(300, decoded);
//! ```
//!
//! Each adapter handles exactly one value. The decoder rejects empty input and
//! trailing bytes, and does not return a consumed prefix. Encoding is always
//! canonical; `NonStrict` is the conventional policy marker for this
//! encode-only path, while `Strict` verifies the canonical encoded value.
//!
//! # API navigation
//!
//! For fixed-width fields, see [`BinaryCodec`] and
//! [`qubit_codec::BigEndian`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/struct.BigEndian.html),
//! [`qubit_codec::LittleEndian`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/struct.LittleEndian.html),
//! and [`qubit_codec::NativeEndian`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/struct.NativeEndian.html).
//! For variable-width fields, see
//! [`Leb128Codec`], [`ZigZagCodec`], [`Strict`], and [`NonStrict`].
//!
//! Direct calls to the low-level `unsafe` methods require the surrounding code
//! to guarantee valid input/output indices and sufficient readable/writable
//! capacity. See [`qubit_codec::Codec`](https://docs.rs/qubit-codec/0.17.1/qubit_codec/trait.Codec.html)
//! for the low-level contract.
//!
//! Read the [English user guide](https://github.com/qubit-ltd/rs-codec-binary/blob/main/doc/user_guide.md)
//! or the [中文用户指南](https://github.com/qubit-ltd/rs-codec-binary/blob/main/doc/user_guide.zh_CN.md).
pub use BinaryCodec;
pub use Leb128Codec;
pub use Leb128DecodeError;
pub use Leb128DecodeErrorKind;
pub use Leb128DecodePolicy;
pub use NonStrict;
pub use Strict;
pub use ZigZagCodec;