pub trait Protobuf: Sized {
fn encode(&self) -> Vec<u8>;
fn decode(buf: impl prost::bytes::Buf) -> Result<Self, prost::DecodeError>;
}
#[expect(
dead_code,
reason = "experimental feature, we might have use for this one in the future"
)]
pub(crate) fn encode<M: prost::Message>(
thing: impl Into<M>,
buf: &mut impl prost::bytes::BufMut,
) -> Result<(), prost::EncodeError> {
thing.into().encode(buf)
}
pub(crate) fn encode_to_vec<M: prost::Message>(thing: impl Into<M>) -> Vec<u8> {
thing.into().encode_to_vec()
}
use std::default::Default;
pub(crate) fn decode<M: prost::Message + Default, T: From<M>>(
buf: impl prost::bytes::Buf,
) -> Result<T, prost::DecodeError> {
M::decode(buf).map(T::from)
}
pub(crate) fn try_decode<M: prost::Message + Default, E, T: TryFrom<M, Error = E>>(
buf: impl prost::bytes::Buf,
) -> Result<Result<T, E>, prost::DecodeError> {
M::decode(buf).map(T::try_from)
}