[][src]Trait integer_encoding::FixedInt

pub trait FixedInt: Sized + Copy {
    pub const REQUIRED_SPACE: usize;

    pub fn required_space() -> usize;
pub fn encode_fixed(self, src: &mut [u8]);
pub fn decode_fixed(src: &[u8]) -> Self;
pub fn encode_fixed_light<'a>(&'a self) -> &'a [u8]; pub fn encode_fixed_vec(self) -> Vec<u8> { ... }
pub 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 machine endianness.

Associated Constants

Loading content...

Required methods

pub fn required_space() -> usize[src]

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

pub fn encode_fixed(self, src: &mut [u8])[src]

Encode a value into the given slice. dst must be exactly REQUIRED_SPACE bytes.

pub fn decode_fixed(src: &[u8]) -> Self[src]

Decode a value from the given slice. src must be exactly REQUIRED_SPACE bytes.

pub fn encode_fixed_light<'a>(&'a self) -> &'a [u8][src]

Perform a transmute, i.e. return a "view" into the integer's memory, which is faster than performing a copy.

Loading content...

Provided methods

pub fn encode_fixed_vec(self) -> Vec<u8>[src]

Helper: Encode the value and return a Vec.

pub fn decode_fixed_vec(v: &Vec<u8>) -> Self[src]

Helper: Decode the value from the Vec.

Loading content...

Implementations on Foreign Types

impl FixedInt for usize[src]

impl FixedInt for u64[src]

impl FixedInt for u32[src]

impl FixedInt for u16[src]

impl FixedInt for isize[src]

impl FixedInt for i64[src]

impl FixedInt for i32[src]

impl FixedInt for i16[src]

Loading content...

Implementors

Loading content...