pub fn serialize_to_vec<T: Serialize>(data: &T) -> Result<Vec<u8>>
Serialize data with error handling