BARE Message Encoding
Binary Application Record Encoding
BARE is a simple binary representation for structured application data.
NOTICE: The BARE encoding is not finalized.
Feedback is welcome.
draft-devault-bare
has been filed with the IETF as an Internet-Draft and represents the latest
authoritative draft of the specification.
BARE at a glance
-
Messages are encoded in binary and compact in size. Messages do not contain
schema information — they are not self-describing.
-
BARE is optimized for small messages. It is not optimized for encoding
large amounts of data in a single message, or efficiently reading a message
with fields of a fixed size. However, all types are aligned to 8 bits,
which does exchange some space for simplicity.
-
BARE's approach to extensibility is conservative: messages encoded today
will be decodable tomorrow, and vice-versa. But extensibility is still
possible; implementations can choose to decode user-defined types at a
higher level and map them onto arbitrary data types.
-
The specification is likewise conservative. Simple implementations of
message decoders and encoders can be written inside of an afternoon.
-
An optional DSL is provided
to document message schemas and provide a source for code generation.
However, if you prefer, you may also define your schema using the type
system already available in your programming language.
Here is a sample schema:
type PublicKey data[128]
type Time str # ISO 8601
type Department enum {
ACCOUNTING
ADMINISTRATION
CUSTOMER_SERVICE
DEVELOPMENT
# Reserved for the CEO
JSMITH = 99
}
type Address list<str>[4] # street, city, state, country
type Customer struct {
name: str
email: str
address: Address
orders: list<struct {
orderId: i64
quantity: i32
}>
metadata: map<str><data>
}
type Employee struct {
name: str
email: str
address: Address
department: Department
hireDate: Time
publicKey: optional<PublicKey>
metadata: map<str><data>
}
type TerminatedEmployee void
type Person union {Customer | Employee | TerminatedEmployee}
Known implementations
- C
- cbare
- Common Lisp
- cl-bare
- D
- bare
- Elm
- elm-bare
- Erlang
- bare
- Go
- go-bare
- Java
- bare-jvm
- JavaScript
- bare-js
- .NET
- BareNET
- OCaml
- bare-ocaml
- PHP
- bare-mess-php
- Python
- bare-py
- pybare
- Ruby
- bare-rb
- Rust
- serde_bare
- Scheme
- kahl
- TypeScript
- bare-ts
- Zig
- zig-bare