sbed / readme.md
streaming binary encoder/decoder
git clone http://git.nthia.dev/sbed

# sbed

streaming binary encoder/decoder

status: very early, in progress

when it's fully baked you'll be able to write streaming parsers for binary data
on the fly such as:

```
sbed v:msg_len u8[msg_len]:[
  v:msg_type
  u8[4]:req_id
  u8[4]:circuit_id
  v:ttl
  switch[msg_type]:[
    case[0]:[
      v:hash_count
      [u8[32]][hash_count]:hashes
      println:[hashes --json]
    ]
    case[1]:[
      loop:[
        v:data_len
        u8[data_len]:data
        if[data_len=0]:[break]
        println:[{data} --json]
      ]
    ]
  ]
]
```

this way your command-line tools can handle more textual formats (lines of csv,
json, etc) that they work better with.

but right now you can only do simple non-recursive statements such as:

```
$ echo -e '\x05hello' | ./sbed v:data_len u8[data_len]:data println:[data_len]
5
```

and with only a very few types