Trait kitsune_p2p_types::codec::Codec
source · pub trait Codec: Clone + Sized {
fn variant_type(&self) -> &'static str;
fn encode<W>(&self, w: &mut W) -> Result<(), Error>
where
W: Write;
fn decode<R>(r: &mut R) -> Result<Self, Error>
where
R: Read;
fn encode_vec(&self) -> Result<Vec<u8>, Error> { ... }
fn decode_ref(r: &[u8]) -> Result<(u64, Self), Error> { ... }
}
Expand description
Apply to a data item to indicate it can be encoded / decoded.
Required Methods§
sourcefn variant_type(&self) -> &'static str
fn variant_type(&self) -> &'static str
Variant identifier (for debugging or as a cheap discriminant).