glepack/encode
This module provides functions to encode various data types into MessagePack format.
Functions
pub fn array(values: List(Value)) -> Result(BitArray, Nil)
Encode an array of values into MessagePack format The function returns a Result containing the encoded BitArray or an error.
pub fn binary(value: BitArray) -> Result(BitArray, Nil)
Encode a binary value into MessagePack format The function returns a Result containing the encoded BitArray or an error.
pub fn boolean(value: Bool) -> Result(BitArray, Nil)
Encode a boolean value into MessagePack format
pub fn extension(
type_id: Int,
data: BitArray,
) -> Result(BitArray, Nil)
Encode a MessagePack extension value The function takes a type ID and a BitArray of data, and returns a Result containing the encoded BitArray or an error. The type ID is an integer that identifies the type of extension data. The data is a BitArray representing the extension data.
pub fn float(value: Float) -> Result(BitArray, Nil)
Encode a floating-point value into MessagePack format The function returns a Result containing the encoded BitArray or an error.
pub fn integer(value: Int) -> Result(BitArray, Nil)
Encode an integer value into MessagePack format The function returns a Result containing the encoded BitArray or an error.
pub fn map(value: Dict(Value, Value)) -> Result(BitArray, Nil)
Encode a map of key-value pairs into MessagePack format The function returns a Result containing the encoded BitArray or an error.
pub fn string(value: String) -> Result(BitArray, Nil)
Encode a string value into MessagePack format The function returns a Result containing the encoded BitArray or an error. The string is encoded as UTF-8.