use alloc::{vec, vec::Vec};
use ark_serialize::{CanonicalDeserialize, CanonicalSerialize, SerializationError};
pub trait SerializableToBytes: CanonicalSerialize + CanonicalDeserialize {
const SERIALIZED_BYTES_SIZE: usize;
fn to_bytes(&self) -> Vec<u8> {
let mut serialized_representation: Vec<u8> = vec![0; Self::SERIALIZED_BYTES_SIZE];
self.serialize_compressed(&mut serialized_representation[..])
.unwrap();
return serialized_representation;
}
fn from_bytes(bytes: &[u8]) -> Result<Self, SerializationError> {
Self::deserialize_compressed(bytes)
}
}