Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions base64ct/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,8 @@ impl<'i, E: Encoding> Decoder<'i, E> {
///
/// # Returns
/// - `Ok(bytes)` if the expected amount of data was read
/// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read, or
/// if the output buffer has a length of 0
/// - `Err(Error::InvalidLength)` if the exact amount of data couldn't be read
pub fn decode<'o>(&mut self, out: &'o mut [u8]) -> Result<&'o [u8], Error> {
if out.is_empty() {
return Err(InvalidLength);
}

if self.is_finished() {
return Err(InvalidLength);
}
Expand Down Expand Up @@ -551,8 +546,6 @@ impl<'i> Iterator for LineReader<'i> {
mod tests {
use crate::{Base64, Base64Unpadded, Decoder, alphabet::Alphabet, test_vectors::*};

#[cfg(feature = "std")]
use crate::Error::InvalidLength;
#[cfg(feature = "std")]
use {alloc::vec::Vec, std::io::Read};

Expand Down Expand Up @@ -598,16 +591,6 @@ mod tests {
assert_eq!(buf.as_slice(), MULTILINE_PADDED_BIN);
}

#[cfg(feature = "std")]
#[test]
fn reject_empty_read() {
let mut decoder = Decoder::<Base64>::new(b"AAAA").unwrap();

let mut buf: Vec<u8> = vec![];

assert_eq!(decoder.decode(&mut buf), Err(InvalidLength));
}

/// Core functionality of a decoding test
#[allow(clippy::arithmetic_side_effects)]
fn decode_test<'a, F, V>(expected: &[u8], f: F)
Expand Down