Trait integer_encoding::FixedInt [] [src]

pub trait FixedInt: Sized + Copy {
    fn size_required() -> usize;
    fn encode_fixed(self, &mut [u8]);
    fn decode_fixed(&[u8]) -> Self;

    fn encode_fixed_vec(self) -> Vec<u8> { ... }
    fn decode_fixed_vec(v: &Vec<u8>) -> Self { ... }
}

FixedInt provides encoding/decoding to and from fixed int representations. The emitted bytestring contains the bytes of the integer in little-endian order.

Required Methods

fn size_required() -> usize

Returns how many bytes are required to represent the given type.

fn encode_fixed(self, &mut [u8])

Encode a value into the given slice.

fn decode_fixed(&[u8]) -> Self

Decode a value from the given slice.

Provided Methods

fn encode_fixed_vec(self) -> Vec<u8>

Helper: Encode the value and return a Vec.

fn decode_fixed_vec(v: &Vec<u8>) -> Self

Helper: Decode the value from the Vec.

Implementors