Skip to content

Commit b525470

Browse files
committed
Document stream state migration guidance
1 parent 59470ac commit b525470

2 files changed

Lines changed: 23 additions & 4 deletions

File tree

docs/MIGRATION.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,31 @@ use std::io::Write;
166166
use base64_ng::{STANDARD, stream::Encoder};
167167

168168
let mut encoder = Encoder::new(Vec::new(), STANDARD);
169-
encoder.write_all(b"hello").unwrap();
169+
assert_eq!(encoder.engine(), STANDARD);
170+
assert!(encoder.is_padded());
171+
172+
encoder.write_all(b"he").unwrap();
173+
assert!(encoder.has_pending_input());
174+
175+
encoder.write_all(b"llo").unwrap();
176+
assert!(encoder.has_pending_input());
177+
178+
encoder.try_finish().unwrap();
179+
assert!(encoder.is_finalized());
180+
170181
let encoded = encoder.finish().unwrap();
171182

172183
assert_eq!(encoded, b"aGVsbG8=");
173184
```
174185

186+
Writer adapters expose `try_finish()` when a caller wants to finalize pending
187+
Base64 input and flush the wrapped writer without immediately consuming the
188+
adapter. After successful finalization, later non-empty writes return
189+
`InvalidInput`. Stream adapters also expose non-sensitive state helpers such as
190+
`engine()`, `is_padded()`, `pending_len()`, `has_pending_input()`, reader-side
191+
`buffered_output_len()`, and decoder-side `has_terminal_padding()` for framed
192+
protocols and audit logging.
193+
175194
The `tokio` feature is reserved for future async wrappers. It is currently
176195
inert and dependency-free; use the explicit `stream` feature for `std::io`
177196
wrappers.

docs/RELEASE_EVIDENCE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ The release gate runs:
105105
undersized output, and in-place cleanup
106106
- constant-time-oriented validate/decode agreement tests for valid and
107107
malformed inputs across supported alphabets and padding modes
108-
- stream encoder and decoder tests proving `finish()`, `try_finish()`,
109-
`into_inner()`, and adjacent-payload behavior remain intact after cleanup
110-
hardening
108+
- stream encoder and decoder tests proving policy accessors, state accessors,
109+
`finish()`, `try_finish()`, `into_inner()`, and adjacent-payload behavior
110+
remain intact after cleanup hardening
111111
- stream fuzz coverage for chunked writers, fragmented reader sources, and
112112
adjacent framed payload boundaries
113113
- Kani proofs through `scripts/check_kani.sh` when Kani is installed and its

0 commit comments

Comments
 (0)