I have the following situation, a field in my protobuf (when stored in rust) needs encoding to bytes before it can get stored in the protobuf. I would like to avoid the temporary allocation of storing it in a Vec, and directly write it into the WriterBackend.
// Code I would like to write
fn write_message<W: WriterBackend>(&self, w: &mut Writer<W>) -> quick_protobuf::Result<()> {
w.write_with_tag(10, |w| {
let len = self.foo.encoded_len();
w.write_varint(len as u64)?;
self.foo.write(w)?;
Ok(())
})?;
// ..
Ok(())
}
I have the following situation, a field in my protobuf (when stored in rust) needs encoding to bytes before it can get stored in the protobuf. I would like to avoid the temporary allocation of storing it in a
Vec
, and directly write it into theWriterBackend
.