pub struct BufferWriter { /* private fields */ }Expand description
Serializes values into the WeaveFFI buffer format.
The #[weaveffi::module] expansion writes record fields, enum payloads,
collection elements, and error payloads through one of these, then hands
the finished bytes across the ABI (via
lower_bytes for returns, or borrowed directly for
callback arguments).
Implementations§
Source§impl BufferWriter
impl BufferWriter
Sourcepub fn write_bool(&mut self, v: bool)
pub fn write_bool(&mut self, v: bool)
Write a bool as one byte (0 or 1).
Sourcepub fn write_i32(&mut self, v: i32)
pub fn write_i32(&mut self, v: i32)
Write an i32 little-endian. Also the encoding of C-style enum values
and rich-enum tags.
Sourcepub fn write_len(&mut self, len: usize)
pub fn write_len(&mut self, len: usize)
Write a length or element count as a u32.
§Panics
Panics when len exceeds u32::MAX; truncating would corrupt the
stream, and a value that large cannot round-trip through the format.
Sourcepub fn write_string(&mut self, v: &str)
pub fn write_string(&mut self, v: &str)
Write a string as a u32 byte length followed by its UTF-8 bytes.
Interior NUL bytes round-trip unchanged (the format is not
NUL-terminated).
Sourcepub fn write_bytes(&mut self, v: &[u8])
pub fn write_bytes(&mut self, v: &[u8])
Write a byte buffer as a u32 length followed by the raw bytes.
Sourcepub fn write_option_flag(&mut self, present: bool)
pub fn write_option_flag(&mut self, present: bool)
Write an optional’s presence flag: 0 for absent, 1 for present.
When present, the caller writes the inner value next.