mod collections;
mod error;
pub mod generated;
mod protocol;
pub use error::PersistenceError;
pub use miden_protobuf;
pub use prost;
pub trait ProtobufValue: Sized {
type Message: prost::Message + Default;
fn to_proto(&self) -> Self::Message;
fn from_proto(message: Self::Message) -> Result<Self, PersistenceError>;
}
pub fn encode<T: ProtobufValue>(value: &T) -> Vec<u8> {
prost::Message::encode_to_vec(&value.to_proto())
}
pub fn decode<T: ProtobufValue>(bytes: &[u8]) -> Result<T, PersistenceError> {
let message = <T::Message as prost::Message>::decode(bytes)?;
T::from_proto(message)
}
#[cfg(test)]
mod tests;