Hacker News new | ask | show | jobs
by kentonv 3571 days ago
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).
1 comments

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.