What is Nostr?
Blain Smith /
npub1r4z…0prv
2024-04-23 13:04:31

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
Author Public Key
npub1r4z0ear55ftw88y76w7vgwm9fwlrlrznca6hjq0ytn4773uvk2nsf30prv