tlsn_core/serialize.rs
1/// Canonical serialization of TLSNotary types.
2///
3/// This trait is used to serialize types into a canonical byte representation.
4pub(crate) trait CanonicalSerialize {
5 /// Serializes the type.
6 fn serialize(&self) -> Vec<u8>;
7}
8
9impl<T> CanonicalSerialize for T
10where
11 T: serde::Serialize,
12{
13 fn serialize(&self) -> Vec<u8> {
14 // For now we use BCS for serialization. In future releases we will want to
15 // consider this further, particularly with respect to EVM compatibility.
16 bcs::to_bytes(self).unwrap()
17 }
18}