Blain Smith on Nostr: Messing around with Hare last night putting together a simple binary buffer ...
Messing around with Hare last night putting together a simple binary buffer reader/writer with length-prefixed strings.
```
const buf = memio::dynamic();
// A new big-endian writer using u16 for string length prefixes
const w = newwriter(&buf, endian::big, lensz::U16);
// Write some numbers
write_u16(&w, 10u16)!;
write_u32(&w, 10u32)!;
write_u64(&w, 10u64)!;
// Write a string
// [.. 00 06 b i n b u f]
io::write(&w, strings::toutf8("binbuf"))!;
```
#HareLang
```
const buf = memio::dynamic();
// A new big-endian writer using u16 for string length prefixes
const w = newwriter(&buf, endian::big, lensz::U16);
// Write some numbers
write_u16(&w, 10u16)!;
write_u32(&w, 10u32)!;
write_u64(&w, 10u64)!;
// Write a string
// [.. 00 06 b i n b u f]
io::write(&w, strings::toutf8("binbuf"))!;
```
#HareLang