+
+ # Like `write_to` but return a new Bytes (may be quite large)
+ #
+ # This functionality is anecdotal, since the point
+ # of a streamable object is to be efficiently written to a
+ # stream without having to allocate and concatenate buffers.
+ #
+ # Nevertheless, you might need this method if you want to know
+ # the byte size of a writable object.
+ fun write_to_bytes: Bytes
+ do
+ var stream = new BytesWriter
+ write_to(stream)
+ return stream.bytes
+ end