import { Message } from "https://deno.land/x/capnp_ts@0.1.0/mod.ts";
Constructors
A Cap'n Proto message.
SECURITY WARNING: In nodejs do not pass a Buffer's internal array buffer into this constructor. Pass the buffer directly and everything will be fine. If not, your message will potentially be initialized with random memory contents!
The constructor method creates a new Message, optionally using a provided arena for segment allocation, or a buffer to read from.
Methods
Create a pretty-printed string dump of this message; incredibly useful for debugging.
WARNING: Do not call this method on large messages!
Get a struct pointer for the root of this message. This is primarily used when reading a message; it will not overwrite existing data.
Get a segment by its id.
This will lazily allocate the first segment if it doesn't already exist.
Initialize a new message using the provided struct type as the root.
Set the root of the message to a copy of the given pointer. Used internally to make copies of pointers for default values.
Combine the contents of this message's segments into a single array buffer and prepend a stream framing header containing information about the following segment data.
Like toArrayBuffer()
, but also applies the packing algorithm to the output. This is typically what you want to
use if you're sending the message over a network link or other slow I/O interface where size matters.