base64: add decode_to_vec variants

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2025-05-22 16:33:55 +02:00
parent 3b25bc05d5
commit e8db97ca11

View File

@ -151,6 +151,38 @@ macro_rules! implement_kind {
}
*/
/// Decode
#[$kind]
/// data with *optional* padding into a byte vector.
pub fn decode_to_vec<T>(data: T, output: &mut Vec<u8>) -> Result<(), DecodeError>
where
T: AsRef<[u8]>,
{
DECODE_ENGINE_INDIFFERENT_PAD
.decode_vec(data, output)
.convert_error()
}
/// Decode
#[$kind]
/// data which *must* be padded into a byte vector.
pub fn decode_to_vec_pad<T>(data: T, output: &mut Vec<u8>) -> Result<(), DecodeError>
where
T: AsRef<[u8]>,
{
ENGINE_MUST_PAD.decode_vec(data, output).convert_error()
}
/// Decode
#[$kind]
/// data which *must not* be padded into a byte vector.
pub fn decode_to_vec_no_pad<T>(data: T, output: &mut Vec<u8>) -> Result<(), DecodeError>
where
T: AsRef<[u8]>,
{
ENGINE_MUST_NOT_PAD.decode_vec(data, output).convert_error()
}
/// A formatting wrapper producing
#[$kind]
/// data with padding.