GithubHelp home page GithubHelp logo

hauleth / bare-erlang Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 15 KB

Implementation of BARE encoding in Erlang (mirror)

Home Page: https://git.sr.ht/~hauleth/BARE-Erlang

License: Apache License 2.0

Erlang 99.35% Nix 0.65%
baremessages bare erlang serialization

bare-erlang's Introduction

BARE

builds.sr.ht status Hex version

Implementation of BARE encoding in Erlang.

Usage

Spec = {struct, [{name, string}, {age, uint}]},

Binary = bare:encode(#{name => "hauleth", age => 28}, Spec),
#{name => <<"hauleth">>, age => 28} = bare:decode(Binary, Spec)

Types

| BARE name         | Spec format                    | Erlang type                                      |
| :                 | :                              | :                                                |
| `uint`            | `uint`                         | `non_neg_integer()`                              |
| `int`             | `int`                          | `integer()`                                      |
| `u8`              | `u8`                           | `non_neg_integer()`                              |
| `u16`             | `u16`                          | `non_neg_integer()`                              |
| `u32`             | `u32`                          | `non_neg_integer()`                              |
| `u64`             | `u64`                          | `non_neg_integer()`                              |
| `i8`              | `i8`                           | `integer()`                                      |
| `i16`             | `i16`                          | `integer()`                                      |
| `i32`             | `i32`                          | `integer()`                                      |
| `i64`             | `i64`                          | `integer()`                                      |
| `f32`             | `f32`                          | float or `qnan`/`snan`/`infinity`/`neg_infinity` |
| `f64`             | `f64`                          | float or `qnan`/`snan`/`infinity`/`neg_infinity` |
| `string`          | `string`                       | `unicode:chardata()`                             |
| `data`            | `data`                         | `binary()`                                       |
| `data<N>`         | `{data, N}`                    | `binary()` with `byte_size(Bin) =:= N`           |
| `void`            | `void`                         | `[]` (empty list)                                |
| `enum`            | `{enum, [atom(), ...]`         | `atom()` that is listed in the spec              |
| `optional<type>`  | `{optional, Type}`             | `undefined` or one of the other types            |
| `[size]type`      | `{array, Type, Size}`          | list of `type` that has exactly `Size` elements  |
| `[]type`          | `{array, Type}`                | list of `type`                                   |
| `map[key]type`    | `{map, KeyType, ValueType}`    | map in form of `#{KeyType => ValueType}`         |
| `(type1 | type2)` | `{union, [Type1, Type2], ...}` | tuple in form of `{Type, Data}`                  |
| `struct`          | `{struct, [{Key, Type}, ...]}` | map                                              |

TODO

  • Implement compiler for BARE description files

License

Apache 2.0

bare-erlang's People

Contributors

hauleth avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.