hauleth

hauleth

I do not know how many of you are familiar with BARE encoding format which was designed by Drew DeVault. It is super simple format for binary encoding of messages with structure known ahead-of-time (so it isn’t self-descriptive like CBOR). Now it got Erlang implementation (currently without compiler for building structure definition form text definitions).

Library usage is pretty simple (here with Elixir syntax):

spec = {:struct, [foo: :uint, bar: :string]}

encoded = :bare.encode(%{foo: 10, bar: "Hełło"}, spec)
:bare.decode(encoded, spec)
#=> {:ok, %{foo: 10, bar: "Hełło"}, <<>>}

Supported types are:

  • :uint/:int - variable width unsigned/signed integer (specs limit size of these integers to max 64-bit integers)
  • :u8/:u16/:u32/:u64 - fixed width unsigned integers
  • :i8/:i16/:i32/:i64 - fixed width signed integers
  • :bool - boolean values (aka true and false atoms)
  • :f32/:f64 - floating points of given size, currently encoding is limited to finite values, but encoding supports not-finite values which are returned as atoms
  • {:enum, [atom(), ...]} - which will encode known set of atoms as uint
  • :data and data<N> - which will encode arbitrary/fixed-length binaries
  • :string - UTF-8 encoded chartist or binary
  • :void - empty type that can encode only []
  • {:optional, type} - optional value of type
  • {:array, type} - list of type
  • {:array, type, size} - fixed length list of type
  • {:map, key_type, value_type} - map with keys of key_type and values of value_type
  • {:union, [type(), ...]} - tagged union of types which can encode values in form of {type(), data} where data is of type()
  • {:struct, keyword(type())} - structure with given keys that can encode maps with atom keys and values of specified types

Let me know what you think about it, either here or via mailing list.


In future I plan to implement web tokens with BARE and PASETO to make web tokens implementation that for me will be near ideal solution. I will ping you back when I will have something done.

Where Next? Top

Trending in Announcing Top

bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
387 15136 120
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
shahryarjb
The Chelekom project is a library of Phoenix and LiveView components generated via Mix tasks to fit developer needs seamlessly. One of i...
New
woylie
Phoenix components for pagination, sortable tables and filter forms with Flop and (optionally) Ecto. pagination cursor pagination sorta...
New
kip
Please say hi to a new lib, Astro that aims to deliver easy-to-consume astronomy calculations of practical use. For now it only calculat...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

Other Trending Topics Top

juhalehtonen
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
alexslade
Fly’s CEO posted this recently - Turn And Face The Strange · The Fly Blog It says that Fly is going all-in on sprites, which is a worry ...
New
bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New

We're in Beta

About us Mission Statement