pub struct SerializeHelper { /* fields omitted */ }
SerializeHelper make it easy to obtain serialize function.
Create a new instance of SerializeHelper
let helper = SerializeHelper::new();
Get the size of the serialized buffer of the target.
Use encode to serialize a target type. The target must impl the tarit Serializable.
The function return a Option::Some of Vec<u8>
, if something error, return Option::None.
#[derive(Serializable, DeSerializable)]
struct TestSturct {
a1: u32,
a2: u32,
}
let a = TestEnum::EnumStruct {a1: 2017, a2:829};
let helper = SerializeHelper::new();
let data = helper.encode(a).unwrap();