From e8db97ca1178cb8c42a21f68240519c17c23e99e Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 22 May 2025 16:33:55 +0200 Subject: [PATCH] base64: add decode_to_vec variants Signed-off-by: Wolfgang Bumiller --- proxmox-base64/src/implementation.rs | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/proxmox-base64/src/implementation.rs b/proxmox-base64/src/implementation.rs index 560fa886..4e7d131c 100644 --- a/proxmox-base64/src/implementation.rs +++ b/proxmox-base64/src/implementation.rs @@ -151,6 +151,38 @@ macro_rules! implement_kind { } */ + /// Decode + #[$kind] + /// data with *optional* padding into a byte vector. + pub fn decode_to_vec(data: T, output: &mut Vec) -> 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(data: T, output: &mut Vec) -> 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(data: T, output: &mut Vec) -> Result<(), DecodeError> + where + T: AsRef<[u8]>, + { + ENGINE_MUST_NOT_PAD.decode_vec(data, output).convert_error() + } + /// A formatting wrapper producing #[$kind] /// data with padding.