- tags: Solana
- source: https://github.com/solana-labs/solana/blob/eabe1070667e87f447b9cb892e2d916ca5b68e34/sdk/src/offchain_message.rs#L237-L240
/// Serialize the off-chain message to bytes including full header
pub fn serialize(&self) -> Result<Vec<u8>, SanitizeError> {
// serialize signing domain
let mut data = Self::SIGNING_DOMAIN.to_vec();
// serialize version and call version specific serializer
match self {
Self::V0(msg) => {
data.push(0);
msg.serialize(&mut data)?;
}
}
Ok(data)
}