Open
Description
Hey, here's the basic test code i have to create a message in a slice:
pub fn create_serialized_message<const N: usize>(buffer: &mut [u8]) {
let mut tmp_buffer = [0; N];
let mut allocator = capnp::message::SingleSegmentAllocator::new(tmp_buffer.as_mut_slice());
let mut message = capnp::message::Builder::new(&mut allocator);
let foo_builder = message.init_root::<foo::foo::Builder>();
let mut numbers = foo_builder.init_numbers(3);
numbers.set(0, 1);
numbers.set(1, 2);
capnp::serialize::write_message(buffer, &message).expect("yay?");
}
The question is, is it possible to, even in theory, to write a message without having a copy in an intermediate buffer ? I couldn't figure it out.
By reading the code, it doesn't currently seem possible, as write_segment_table
needs to write 8 bytes to the head of the buffer - after the message has been constructed. And write_segment_table
is not public, so i can't manually partition the slice for writing the single-segment header and the message.
Metadata
Metadata
Assignees
Labels
No labels