Hacker News new | ask | show | jobs
by easytiger 3572 days ago
From reading the examples, it looks like one can only serialise to a file descriptor. What if i wan to serialise to a byte array? Am I perhaps missing something obvious?
1 comments

You can certainly serialize to a byte array. The example uses a file descriptor but in fact the code defines an abstract stream type which you can implement any way you want, and you can also obtain pointers to the message's underlying storage in order to extract the bytes directly (avoiding a copy).
Great thanks. I'll give it a go again for a current project I'm kicking off.
i've had a look in kj/io.h

I see the classes: ArrayOutputStream/VectorOutputStream, i assumed these are the ones you are discussing.