Skip to main content

Padding

Trait Padding 

Source
pub trait Padding {
    // Required methods
    fn padded_buffer_length(data_length: usize, block_size: usize) -> usize;
    fn pad(
        buffer: &mut [u8],
        data_length: usize,
        block_size: usize,
    ) -> Result<&[u8], Error>;
    fn unpad(buffer: &[u8]) -> Result<&[u8], Error>;
}
Expand description

Trait defining interface for a Padding implementation

Required Methods§

Source

fn padded_buffer_length(data_length: usize, block_size: usize) -> usize

Given a length of data and block_size return the minimum size of a buffer required to hold the padded data

Source

fn pad( buffer: &mut [u8], data_length: usize, block_size: usize, ) -> Result<&[u8], Error>

Take a buffer containing data of specified length and based on the blocksize apply the padding to the buffer. The returned slice will reference the slice of padded data in the buffer

Source

fn unpad(buffer: &[u8]) -> Result<&[u8], Error>

Given a buffer of padded data, attempt to provide a slice that references the unpadded data

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§