~theothornhill/cl-bare

39fe45f7fdea65511187ae10cef03336ce7e2cbb — Theodor Thornhill a month ago 255cddb
Add some instructions awaiting real api
1 files changed, 26 insertions(+), 1 deletions(-)

M README.md
M README.md => README.md +26 -1
@@ 4,8 4,33 @@ A library to encode and decode bare messages, as described in
[baremessages.org](https://baremessages.org)


# How it works (right now)
Until I've implemented a proper API for this, I'll just explain a little about
lisp-binary, which `cl-bare` heavily relies
on. [lisp-binary](https://github.com/j3pic/lisp-binary) defines a small DSL,
`defbinary` which sort-of works like the `defstruct` in common lisp.

For each binary type we define we get these functions (assume type is uint):
  - `copy-uint`
  - `make-uint`
  - `uint`
  - `uint-p`
  - `uint-value`
  
Using these we can compose different aggregated types based on a (to come) schema.

```lisp
;; Assume we have two types, 'uint' and 'u8'
(let ((x (make-uint :value 31231))
      (y (make-u8 :value 2)))
  (print (uint-value x))
  (print (u8-value y)))
```

If read from stream we can chain them together, and read and write.

# todo
  - instructions
  - real API
  - tagged union
  - structs
  - schema