use anyhow::Result;
pub trait MessageExt: prost::Message {
/// Serialize this protobuf message as a byte vector.
fn to_bytes(&self) -> Result<Vec<u8>>;
}
impl<M> MessageExt for M
where
M: prost::Message,
{
fn to_bytes(&self) -> Result<Vec<u8>> {
let mut bytes = Vec::new();
prost::Message::encode(self, &mut bytes)?;
Ok(bytes)
}
}