pub trait EngineBytesExt<A, const PAD: bool>where
A: Alphabet,{
// Required methods
fn encode_bytes(
&self,
input: impl AsRef<[u8]>,
) -> Result<Bytes, EncodeError>;
fn decode_bytes(
&self,
input: impl AsRef<[u8]>,
) -> Result<Bytes, DecodeError>;
fn encode_buf<B>(&self, input: B) -> Result<Bytes, EncodeError>
where B: Buf;
fn encode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesEncodeError>
where B: Buf;
fn decode_buf<B>(&self, input: B) -> Result<Bytes, DecodeError>
where B: Buf;
fn decode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesDecodeError>
where B: Buf;
fn encode_buf_to_mut<B, M>(
&self,
input: B,
output: &mut M,
) -> Result<usize, EncodeError>
where B: Buf,
M: BufMut;
fn encode_buf_to_mut_limited<B, M>(
&self,
input: B,
output: &mut M,
max_input_len: usize,
) -> Result<usize, BytesEncodeError>
where B: Buf,
M: BufMut;
fn decode_buf_to_mut<B, M>(
&self,
input: B,
output: &mut M,
) -> Result<usize, DecodeError>
where B: Buf,
M: BufMut;
fn decode_buf_to_mut_limited<B, M>(
&self,
input: B,
output: &mut M,
max_input_len: usize,
) -> Result<usize, BytesDecodeError>
where B: Buf,
M: BufMut;
}Expand description
Extension helpers for base64_ng::Engine and bytes buffers.
Required Methods§
Sourcefn encode_bytes(&self, input: impl AsRef<[u8]>) -> Result<Bytes, EncodeError>
fn encode_bytes(&self, input: impl AsRef<[u8]>) -> Result<Bytes, EncodeError>
Sourcefn decode_bytes(&self, input: impl AsRef<[u8]>) -> Result<Bytes, DecodeError>
fn decode_bytes(&self, input: impl AsRef<[u8]>) -> Result<Bytes, DecodeError>
Sourcefn encode_buf<B>(&self, input: B) -> Result<Bytes, EncodeError>where
B: Buf,
fn encode_buf<B>(&self, input: B) -> Result<Bytes, EncodeError>where
B: Buf,
Encodes all remaining bytes from input into a Bytes value.
The input buffer is advanced to completion only after its current chunks have been copied into a temporary contiguous buffer.
§Errors
Returns EncodeError if the encoded length overflows.
Sourcefn encode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesEncodeError>where
B: Buf,
fn encode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesEncodeError>where
B: Buf,
Encodes at most max_input_len remaining bytes from input into a
Bytes value.
Use this variant for peer-controlled or metadata-declared frame sizes.
The input buffer is not collected if Buf::remaining exceeds
max_input_len.
§Errors
Returns BytesEncodeError::InputTooLarge if input.remaining()
exceeds max_input_len, or BytesEncodeError::Encode if Base64
encoding fails.
Sourcefn decode_buf<B>(&self, input: B) -> Result<Bytes, DecodeError>where
B: Buf,
fn decode_buf<B>(&self, input: B) -> Result<Bytes, DecodeError>where
B: Buf,
Decodes all remaining bytes from input into a Bytes value.
§Errors
Returns DecodeError if decoding fails.
Sourcefn decode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesDecodeError>where
B: Buf,
fn decode_buf_limited<B>(
&self,
input: B,
max_input_len: usize,
) -> Result<Bytes, BytesDecodeError>where
B: Buf,
Decodes at most max_input_len remaining Base64 bytes from input
into a Bytes value.
Use this variant for peer-controlled or metadata-declared frame sizes.
The input buffer is not collected if Buf::remaining exceeds
max_input_len.
§Errors
Returns BytesDecodeError::InputTooLarge if input.remaining()
exceeds max_input_len, or BytesDecodeError::Decode if Base64
decoding fails.
Sourcefn encode_buf_to_mut<B, M>(
&self,
input: B,
output: &mut M,
) -> Result<usize, EncodeError>
fn encode_buf_to_mut<B, M>( &self, input: B, output: &mut M, ) -> Result<usize, EncodeError>
Encodes all remaining bytes from input into output.
§Errors
Returns EncodeError::OutputTooSmall if output does not have enough
remaining mutable capacity.
Sourcefn encode_buf_to_mut_limited<B, M>(
&self,
input: B,
output: &mut M,
max_input_len: usize,
) -> Result<usize, BytesEncodeError>
fn encode_buf_to_mut_limited<B, M>( &self, input: B, output: &mut M, max_input_len: usize, ) -> Result<usize, BytesEncodeError>
Encodes at most max_input_len remaining bytes from input into
output.
§Errors
Returns BytesEncodeError::InputTooLarge if input.remaining()
exceeds max_input_len, BytesEncodeError::Encode with
EncodeError::OutputTooSmall if output is too small, or another
wrapped EncodeError if Base64 encoding fails.
Sourcefn decode_buf_to_mut<B, M>(
&self,
input: B,
output: &mut M,
) -> Result<usize, DecodeError>
fn decode_buf_to_mut<B, M>( &self, input: B, output: &mut M, ) -> Result<usize, DecodeError>
Decodes all remaining Base64 bytes from input into output.
§Errors
Returns DecodeError::OutputTooSmall if output does not have enough
remaining mutable capacity, or another DecodeError if decoding
fails.
Sourcefn decode_buf_to_mut_limited<B, M>(
&self,
input: B,
output: &mut M,
max_input_len: usize,
) -> Result<usize, BytesDecodeError>
fn decode_buf_to_mut_limited<B, M>( &self, input: B, output: &mut M, max_input_len: usize, ) -> Result<usize, BytesDecodeError>
Decodes at most max_input_len remaining Base64 bytes from input
into output.
§Errors
Returns BytesDecodeError::InputTooLarge if input.remaining()
exceeds max_input_len, BytesDecodeError::Decode with
DecodeError::OutputTooSmall if output is too small, or another
wrapped DecodeError if Base64 decoding fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".