@@ -166,12 +166,31 @@ use std::io::Write;
166166use base64_ng :: {STANDARD , stream :: Encoder };
167167
168168let 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+
170181let encoded = encoder . finish (). unwrap ();
171182
172183assert_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+
175194The ` tokio ` feature is reserved for future async wrappers. It is currently
176195inert and dependency-free; use the explicit ` stream ` feature for ` std::io `
177196wrappers.
0 commit comments