pub fn encoded_len(bytes_len: usize, padding: bool) -> Option<usize> {
    let rem = bytes_len % 3;

    let complete_input_chunks = bytes_len / 3;
    let complete_chunk_output = complete_input_chunks.checked_mul(4);

    if rem > 0 {
        if padding {
            complete_chunk_output.and_then(|c| c.checked_add(4))
        } else {
            let encoded_rem = match rem {
                1 => 2,
                2 => 3,
                _ => unreachable!("Impossible remainder"),
            };
            complete_chunk_output.and_then(|c| c.checked_add(encoded_rem))
        }
    } else {
        complete_chunk_output
    }
}
/// Calculate the base64 encoded length for a given input length, optionally including any
/// appropriate padding bytes.
///
/// Returns `None` if the encoded length can't be represented in `usize`.
Calculate the base64 encoded length for a given input length, optionally including any
appropriate padding bytes.

Returns `None` if the encoded length can't be represented in `usize`.
Calculate the base64 encoded length for a given input length optionally including any appropriate padding bytes . Returns ` None ` if the encoded length can ' t be represented in ` usize ` .
pub fn encoded_len(bytes_len: usize, padding: bool) -> Option<usize> {
    let rem = bytes_len % 3;
    let complete_input_chunks = bytes_len / 3;
    let complete_chunk_output = complete_input_chunks.checked_mul(4);
    if rem > 0 {
        if padding {
            complete_chunk_output.and_then(|c| c.checked_add(4))
        } else {
            let encoded_rem = match rem {
                1 => 2,
                2 => 3,
                _ => unreachable!("Impossible remainder"),
            };
            complete_chunk_output.and_then(|c| c.checked_add(encoded_rem))
        }
    } else {
        complete_chunk_output
    }
}
pub fn encoded_len ( bytes_len : usize , padding : bool ) -> Option < usize > { let rem = bytes_len % 3 ; let complete_input_chunks = bytes_len / 3 ; let complete_chunk_output = complete_input_chunks . checked_mul ( 4 ) ; if rem > 0 { if padding { complete_chunk_output . and_then ( | c | c . checked_add ( 4 ) ) } else { let encoded_rem = match rem { 1 => 2 , 2 => 3 , _ => unreachable ! ( " " ) , } ; complete_chunk_output . and_then ( | c | c . checked_add ( encoded_rem ) ) } } else { complete_chunk_output } }
Calculate the base64 encoded length for a given input length, optionally including any
appropriate padding bytes.
Calculate the base64 encoded length for a given input length optionally including any appropriate padding bytes .
bytes_len
usize
padding
bool
bytes_len
usize
padding
bool