data-encoding 1.0.0

Generic data encoding functions. It is meant to provide mathematical guarantees, to conform to RFC 4648 (base64, base32, hex, etc.), to be efficient, and to give choice between allocating and in-place functions.
Documentation
macro_rules! check {
    ($e: expr, $c: expr) => {
        if !$c {
            return Err($e);
        }
    };
}

pub fn div_ceil(x: usize, m: usize) -> usize {
    (x + m - 1) / m
}

pub fn chunk(x: &[u8], n: usize, i: usize) -> &[u8] {
    &x[n * i .. n * (i + 1)]
}

pub fn chunk_mut(x: &mut [u8], n: usize, i: usize) -> &mut [u8] {
    &mut x[n * i .. n * (i + 1)]
}