diff --git a/Cargo.toml b/Cargo.toml index 4db5d26..c2670d3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "base64" -version = "0.21.7" +version = "0.22.0" authors = ["Alice Maz ", "Marshall Pierce "] description = "encodes and decodes base64 as bytes or utf8" repository = "https://github.com/marshallpierce/rust-base64" diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 0031215..46e281e 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,9 @@ +# 0.22.0 + +- `DecodeSliceError::OutputSliceTooSmall` is now conservative rather than precise. That is, the error will only occur if the decoded output _cannot_ fit, meaning that `Engine::decode_slice` can now be used with exactly-sized output slices. As part of this, `Engine::internal_decode` now returns `DecodeSliceError` instead of `DecodeError`, but that is not expected to affect any external callers. +- `DecodeError::InvalidLength` now refers specifically to the _number of valid symbols_ being invalid (i.e. `len % 4 == 1`), rather than just the number of input bytes. This avoids confusing scenarios when based on interpretation you could make a case for either `InvalidLength` or `InvalidByte` being appropriate. +- Decoding is somewhat faster (5-10%) + # 0.21.7 - Support getting an alphabet's contents as a str via `Alphabet::as_str()` diff --git a/src/engine/general_purpose/decode.rs b/src/engine/general_purpose/decode.rs index 98ce043..b55d3fc 100644 --- a/src/engine/general_purpose/decode.rs +++ b/src/engine/general_purpose/decode.rs @@ -348,7 +348,10 @@ mod tests { let len_128 = encoded_len as u128; let estimate = GeneralPurposeEstimate::new(encoded_len); - assert_eq!((len_128 + 3) / 4 * 3, estimate.conservative_decoded_len as u128); + assert_eq!( + (len_128 + 3) / 4 * 3, + estimate.conservative_decoded_len as u128 + ); }) } } diff --git a/src/engine/naive.rs b/src/engine/naive.rs index 15c07cc..af509bf 100644 --- a/src/engine/naive.rs +++ b/src/engine/naive.rs @@ -112,8 +112,12 @@ impl Engine for Naive { output: &mut [u8], estimate: Self::DecodeEstimate, ) -> Result { - let complete_nonterminal_quads_len = - general_purpose::decode::complete_quads_len(input, estimate.rem, output.len(), &self.decode_table)?; + let complete_nonterminal_quads_len = general_purpose::decode::complete_quads_len( + input, + estimate.rem, + output.len(), + &self.decode_table, + )?; const BOTTOM_BYTE: u32 = 0xFF; diff --git a/src/lib.rs b/src/lib.rs index 6b5cccb..579a722 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -228,7 +228,7 @@ unused_extern_crates, unused_import_braces, unused_results, - variant_size_differences, + variant_size_differences )] #![forbid(unsafe_code)] // Allow globally until https://github.com/rust-lang/rust-clippy/issues/8768 is resolved.