|
|
|
@ -38,12 +38,10 @@ pub extern "C" fn protobuf_encode(buf: Obj, obj: Obj) -> Obj {
|
|
|
|
|
util::try_or_raise(|| {
|
|
|
|
|
let obj = Gc::<MsgObj>::try_from(obj)?;
|
|
|
|
|
|
|
|
|
|
// We assume there are no other refs into `buf` at this point. This specifically
|
|
|
|
|
// means that no fields of `obj` should reference `buf` memory.
|
|
|
|
|
let buf = &mut BufferMut::try_from(buf)?;
|
|
|
|
|
let stream = &mut BufferStream::new(unsafe {
|
|
|
|
|
// SAFETY: We assume there are no other refs into `buf` at this point. This
|
|
|
|
|
// specifically means that no fields of `obj` should reference `buf` memory.
|
|
|
|
|
buf.as_mut()
|
|
|
|
|
});
|
|
|
|
|
let stream = &mut BufferStream::new(buf.as_mut());
|
|
|
|
|
|
|
|
|
|
Encoder.encode_message(stream, &obj.def(), &obj)?;
|
|
|
|
|
|
|
|
|
|