use crate::STANDARD;
#[cfg(any(feature = "alloc", feature = "std", test))]
use alloc::vec::Vec;
-use core::fmt;
#[cfg(any(feature = "std", test))]
use std::error;
+use core::fmt;
// decode logic operates on chunks of 8 input bytes without padding
const INPUT_CHUNK_LEN: usize = 8;
///}
///```
#[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode<T: AsRef<[u8]>>(input: T) -> Result<Vec<u8>, DecodeError> {
+pub fn decode<T: ?Sized + AsRef<[u8]>>(input: &T) -> Result<Vec<u8>, DecodeError> {
decode_config(input, STANDARD)
}
///}
///```
#[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode_config<T: AsRef<[u8]>>(input: T, config: Config) -> Result<Vec<u8>, DecodeError> {
+pub fn decode_config<T: ?Sized + AsRef<[u8]>>(
+ input: &T,
+ config: Config,
+) -> Result<Vec<u8>, DecodeError> {
let mut buffer = Vec::<u8>::with_capacity(input.as_ref().len() * 4 / 3);
decode_config_buf(input, config, &mut buffer).map(|_| buffer)
///}
///```
#[cfg(any(feature = "alloc", feature = "std", test))]
-pub fn decode_config_buf<T: AsRef<[u8]>>(
- input: T,
+pub fn decode_config_buf<T: ?Sized + AsRef<[u8]>>(
+ input: &T,
config: Config,
buffer: &mut Vec<u8>,
) -> Result<(), DecodeError> {
/// input, rounded up, or in other words `(input_len + 3) / 4 * 3`.
///
/// If the slice is not large enough, this will panic.
-pub fn decode_config_slice<T: AsRef<[u8]>>(
- input: T,
+pub fn decode_config_slice<T: ?Sized + AsRef<[u8]>>(
+ input: &T,
config: Config,
output: &mut [u8],
) -> Result<usize, DecodeError> {
}
}
}
-
- #[test]
- fn decode_imap() {
- assert_eq!(
- decode_config(b"+,,+", crate::IMAP_MUTF7),
- decode_config(b"+//+", crate::STANDARD_NO_PAD)
- );
- }
}