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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
// =============================================================================
// Copyright (c) 2026 Haixing Hu.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0.
// =============================================================================
//! # qubit-codec
//!
//! Domain-neutral codec traits and buffer conversion primitives.
//!
//! `qubit-codec` is the foundation shared by the Qubit binary, text, misc, and
//! I/O codec crates. It defines the small contracts that concrete format crates
//! build on, without shipping concrete binary or text formats itself.
//!
//! # Overview
//!
//! The crate provides:
//!
//! - [`Codec`] for low-level single-value codecs over caller-managed buffers.
//! - [`CodecValueEncoder`] and [`CodecValueDecoder`] for owned one-value
//! convenience APIs.
//! - [`CodecTranscodeEncoder`], [`CodecTranscodeDecoder`], and
//! [`CodecTranscodeConverter`] for strict streaming adapters around a
//! [`Codec`].
//! - [`engine::TranscodeEncodeEngine`], [`engine::TranscodeDecodeEngine`], and
//! [`engine::TranscodeConvertEngine`] for policy-aware buffered loops.
//! - [`engine::TranscodeEncodeHooks`] and [`engine::TranscodeDecodeHooks`] for
//! replacement, skip, report, finish, and reset policy decisions.
//! - [`Transcoder`], [`TranscodeProgress`], and [`TranscodeStatus`] for
//! caller-managed streaming conversion.
//! - [`ValueEncoder`] and [`ValueDecoder`] for whole-value convenience APIs.
//! - [`ByteOrder`], [`ByteOrderSpec`], [`BigEndian`], [`LittleEndian`], and
//! [`NativeEndian`] for shared byte-order metadata.
//! - [`nz()`] and [`nz!`] for checked `NonZeroUsize` construction shared by
//! codec implementations.
//!
//! Concrete codecs live in sibling crates such as `qubit-codec-binary`,
//! `qubit-codec-text`, and `qubit-codec-misc`.
//!
//! # Choosing an Abstraction
//!
//! Pick the smallest layer that matches the shape of the problem:
//!
//! ```text
//! What are you writing?
//!
//! +-- A codec for one logical value
//! | (UTF-8 char, LEB128 integer, fixed-width scalar, ...)
//! | -> implement Codec
//! |
//! +-- A whole-value codec where a single-value quantum is not useful
//! | (Base64 text, percent encoding, escaped strings, ...)
//! | -> implement ValueEncoder<Input> / ValueDecoder<Input>
//! |
//! +-- A strict streaming wrapper around an existing Codec
//! | -> use CodecTranscodeDecoder<C> / CodecTranscodeEncoder<C>
//! | / CodecTranscodeConverter<D, E>
//! |
//! +-- An owned-output wrapper around an existing Codec
//! | -> use CodecValueEncoder<C> / CodecValueDecoder<C>
//! |
//! +-- A streaming codec with policy decisions
//! (skip, replace, count, report, finish output, ...)
//! -> implement engine::TranscodeDecodeHooks<C>
//! / engine::TranscodeEncodeHooks<C>
//! and use engine::TranscodeDecodeEngine<C, H>
//! / engine::TranscodeEncodeEngine<C, H>
//! ```
//!
//! Unit-to-unit conversions, such as UTF-8 bytes to UTF-16 units, compose a
//! decode side and an encode side. Use [`CodecTranscodeConverter`] for a strict
//! pipeline and [`engine::TranscodeConvertEngine`] when either side needs
//! policy hooks.
//!
//! # Layer Overview
//!
//! ```text
//! concrete I/O crates
//! |
//! TranscodeDecodeInput / TranscodeEncodeOutput [feature = "io"]
//! |
//! Transcode*Engine + Transcode*Hooks
//! CodecTranscodeDecoder / Encoder / Converter
//! |
//! Transcoder + TranscodeProgress + TranscodeStatus
//! ValueEncoder / ValueDecoder
//! |
//! Codec
//! ```
//!
//! Implementing further up the stack does not require rewriting the lower
//! layers. The adapter types turn any suitable [`Codec`] into owned-value or
//! streaming APIs. Drop down to the engine and hook layer when the codec needs
//! continuous-stream semantics or policy decisions.
/// Policy-aware transcode engines, hooks, contexts, and policy actions.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;