Borsh.Encode (borsh v0.1.2)
This module contains functions for encoding Elixir data structures into BORSH binary format.
usage
Usage
defmodule ParentStruct do
@type t() :: %__MODULE__{first_name: String.t(), last_name: String.t(), age: integer}
defstruct [
:first_name,
:last_name,
:age
]
use Borsh,
schema: [
first_name: :string,
last_name: :string,
age: :u8
]
end
borsh_struct = %ParentStruct{first_name: "Boris", last_name: "Johnson", age: 58}
Borsh.Encode.encode(borsh_struct)
<<5, 0, 0, 0, 66, 111, 114, 105, 115, 7, 0, 0, 0, 74, 111, 104, 110, 115, 111, 110, 58>>
Link to this section Summary
Functions
Encodes structs according to the schema into the bitstring
Link to this section Functions
Link to this function
borsh_encode(obj)
Encodes structs according to the schema into the bitstring
Link to this function