In vm/src/types/program.rs:
pub fn serialize(&self) -> Result<Vec<u8>, ProgramError> {
let program_serializer: ProgramSerializer = ProgramSerializer::from(self);
let bytes: Vec<u8> = serde_json::to_vec(&program_serializer)?;
Ok(bytes)
}
pub fn deserialize(
program_serializer_bytes: &[u8],
entrypoint: Option<&str>,
) -> Result<Program, ProgramError> {
let program_serializer: ProgramSerializer =
serde_json::from_slice(program_serializer_bytes)?;
let program_json = ProgramJson::from(program_serializer);
let program = parse_program_json(program_json, entrypoint)?;
Ok(program)
}
Program does not implement the traits Serialize/Deserialize, but instead those two methods who do the same thing, only in a way that is not compatible with the serde crate.
Why? I break upstream usage of the traits. If I have a struct that contains a Program (like blockifier::ContractClassV1Inner ), I cannot derive the correct trait onto it.
Why not just implement the trait?
In
vm/src/types/program.rs:Programdoes not implement the traits Serialize/Deserialize, but instead those two methods who do the same thing, only in a way that is not compatible with theserdecrate.Why? I break upstream usage of the traits. If I have a struct that contains a
Program(likeblockifier::ContractClassV1Inner), I cannot derive the correct trait onto it.Why not just implement the trait?