gleb128
Types
pub type Endianness {
Big
Little
}
Constructors
-
Big
-
Little
Functions
pub fn decode_native_signed_integer(
data: BitArray,
endianness: Endianness,
) -> Int
Decodes an arbitrary bit array into a native signed (positive or negative) integer.
pub fn decode_native_unsigned_integer(
data: BitArray,
endianness: Endianness,
) -> Int
Decodes an arbitrary bit array into a native unsigned (positive) integer.
pub fn decode_signed(data: BitArray) -> Result(Int, String)
Decodes a bit array containing some LEB128 integer as an signed (positive or negative) native integer.
Returns an error when the given data can’t be decoded.
pub fn decode_unsigned(data: BitArray) -> Result(Int, String)
Decodes a bit array containing some LEB128 integer as an unsigned (positive) native integer.
Returns an error when the given data can’t be decoded.
pub fn encode_signed(value: Int) -> BitArray
Encodes an signed (positive or negative) integer to a bit array containing its LEB128 representation.
pub fn encode_unsigned(value: Int) -> Result(BitArray, String)
Encodes an unsigned (positive) integer to a bit array containing its LEB128 representation.
Returns an error when the given value to encode is negative.
pub fn fast_decode_signed(data: BitArray) -> Result(Int, String)
Decodes a bit array containing some LEB128 integer as an signed (positive or negative) native integer. When the length of the data is less than or equal to 8 bytes, this function will treat and process the data as an native integer, thus enabling a performance boost. It will fallback to the default decoding function when the length of the data is greater than 8 bytes.
Returns an error when the given data can’t be decoded.
pub fn fast_decode_unsigned(
data: BitArray,
) -> Result(Int, String)
Decodes a bit array containing some LEB128 integer as an unsigned (positive) native integer. When the length of the data is less than or equal to 8 bytes, this function will treat and process the data as an native integer, thus enabling a performance boost. It will fallback to the default decoding function when the length of the data is greater than 8 bytes.
Returns an error when the given data can’t be decoded.
pub fn get_cpu_endianness() -> Result(Endianness, String)