#![cfg_attr(not(feature = "std"), no_std)]
#[cfg(feature = "postcard")]
pub(crate) mod postcard;
#[cfg(feature = "prost")]
pub(crate) mod prost;
#[cfg(feature = "rkyv")]
pub(crate) mod rkyv;
#[cfg(feature = "postcard")]
pub use postcard::PostcardCodec;
#[cfg(feature = "prost")]
pub use prost::ProstCodec;
#[cfg(feature = "rkyv")]
pub use rkyv::RkyvCodec;
pub trait Codec: core::marker::Sized {
type Error: core::fmt::Debug;
}
pub trait CodecFor<T>: Codec {
type Decoded<'buf>: 'buf
where
T: 'buf;
fn encode(msg: &T, buf: &mut [u8]) -> core::result::Result<usize, Self::Error>;
fn decode<'buf>(buf: &'buf [u8]) -> core::result::Result<Self::Decoded<'buf>, Self::Error>
where
T: 'buf;
}
#[cfg(feature = "rkyv")]
pub use consortium_codec_macros::TrustedArchive;
#[cfg(feature = "rkyv")]
pub use crate::rkyv::TrustedArchive;