mcap icon indicating copy to clipboard operation
mcap copied to clipboard

rust: expose api to write messages directly

Open neilisaac opened this issue 2 years ago • 2 comments

Currently Writer::write_to_known_channel takes a byte slice argument, so messages must be encoded into a buffer before writing to the log. In order to efficiently write protobuf messages to mcap (https://github.com/foxglove/mcap/issues/688) without encoding into a vec first, we would like the Writer to provide a method that exposes std::io::Write.

Writer could potentially expose a method to borrow the a Write object ex. Writer<W>::message_writer(&'a mut self, channel_id, sequence, log_time, publish_time) -> MessageWriter<'a, W> where MessageWriter implements Write and computes the message length for you. This would allow us to encode protobuf messages using protobuf::MessageDyn::write_to_writer_dyn(&self, w: &mut dyn Write).

neilisaac avatar Nov 01 '22 20:11 neilisaac