diff --git a/src/base32/alphabet.rs b/src/base32/alphabet.rs index 575177e..9dafea0 100644 --- a/src/base32/alphabet.rs +++ b/src/base32/alphabet.rs @@ -229,6 +229,8 @@ impl Alphabet32Padded { } /// Pass decoder array to [`decode`](super::decode()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 8) #[inline] pub fn decode(&self, a: &[u8]) -> Result, DecodeError> { if a.len() % WIDTH_ENC != 0 { @@ -239,6 +241,8 @@ impl Alphabet32Padded { } /// Pass decoder array to [`decode_into`](super::decode_into()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 8) #[inline] pub fn decode_into(&self, a: &[u8], b: &mut Vec) -> Result<(), DecodeError> { if a.len() % WIDTH_ENC != 0 { @@ -249,6 +253,8 @@ impl Alphabet32Padded { } /// Pass string as bytes and decoder array to [`decode`](super::decode()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 8) #[inline] pub fn decode_str(&self, a: impl AsRef) -> Result, DecodeError> { let a = a.as_ref().as_bytes(); diff --git a/src/base32/decode_bytes.rs b/src/base32/decode_bytes.rs index 269d101..a62a51a 100644 --- a/src/base32/decode_bytes.rs +++ b/src/base32/decode_bytes.rs @@ -5,6 +5,8 @@ use crate::shared::{bits_or_err_u8, DecodeError}; use super::alphabet::{WIDTH_DEC, WIDTH_ENC}; /// Capacity needed in dest `Vec` to decode this byte array -- without padding! +/// +/// Also see padded [`capacity_decode`](super::Alphabet32Padded::capacity_decode()) #[inline] pub const fn capacity_decode(a: &[u8]) -> usize { a.len() * WIDTH_DEC / WIDTH_ENC diff --git a/src/base32/encode_bytes.rs b/src/base32/encode_bytes.rs index 07a0201..5c6e155 100644 --- a/src/base32/encode_bytes.rs +++ b/src/base32/encode_bytes.rs @@ -9,6 +9,8 @@ const U8_MASK_MID_2: u8 = 0b01111100; const U8_MASK_MID_1: u8 = 0b00111110; /// Capacity needed in dest `Vec` to encode this byte array -- without padding! +/// +/// Also see padded [`capacity_encode`](super::Alphabet32Padded::capacity_encode()) #[inline] pub const fn capacity_encode(a: &[u8]) -> usize { // https://stackoverflow.com/questions/23636240/how-do-i-predict-the-required-size-of-a-base32-decode-output diff --git a/src/base64/alphabet.rs b/src/base64/alphabet.rs index e10f25a..b7cebff 100644 --- a/src/base64/alphabet.rs +++ b/src/base64/alphabet.rs @@ -180,6 +180,8 @@ impl Alphabet64Padded { } /// Pass decoder array to [`decode`](super::decode()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 4) #[inline] pub fn decode(&self, a: &[u8]) -> Result, DecodeError> { if a.len() % WIDTH_ENC != 0 { @@ -190,6 +192,8 @@ impl Alphabet64Padded { } /// Pass decoder array to [`decode_into`](super::decode_into()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 4) #[inline] pub fn decode_into(&self, a: &[u8], b: &mut Vec) -> Result<(), DecodeError> { if a.len() % WIDTH_ENC != 0 { @@ -200,6 +204,8 @@ impl Alphabet64Padded { } /// Pass string as bytes and decoder array to [`decode`](super::decode()), and remove padding as needed + /// + /// Also returns [`DecodeError`] if input is an invalid length for padding (i.e. not a multiple of 4) #[inline] pub fn decode_str(&self, a: impl AsRef) -> Result, DecodeError> { let a = a.as_ref().as_bytes(); diff --git a/src/base64/decode_bytes.rs b/src/base64/decode_bytes.rs index e1c5951..9a9ac90 100644 --- a/src/base64/decode_bytes.rs +++ b/src/base64/decode_bytes.rs @@ -5,6 +5,8 @@ use crate::shared::{bits_or_err_u8, DecodeError}; use super::alphabet::{WIDTH_DEC, WIDTH_ENC}; /// Capacity needed in dest `Vec` to decode this byte array -- without padding! +/// +/// Also see padded [`capacity_decode`](super::Alphabet64Padded::capacity_decode()) #[inline] pub const fn capacity_decode(a: &[u8]) -> usize { a.len() * WIDTH_DEC / WIDTH_ENC diff --git a/src/base64/encode_bytes.rs b/src/base64/encode_bytes.rs index 5ff5ff2..7ef5f79 100644 --- a/src/base64/encode_bytes.rs +++ b/src/base64/encode_bytes.rs @@ -6,6 +6,8 @@ use crate::shared::*; use super::alphabet::{BITS, WIDTH_DEC, WIDTH_ENC}; /// Capacity needed in dest `Vec` to encode this byte array -- without padding! +/// +/// Also see padded [`capacity_encode`](super::Alphabet64Padded::capacity_encode()) #[inline] pub const fn capacity_encode(a: &[u8]) -> usize { // https://stackoverflow.com/questions/23636240/how-do-i-predict-the-required-size-of-a-base32-decode-output