Generates a Deserialize trait implementation for a given struct s.
Arguments
s - The struct type definition to generate the implementation for
Returns
A Quoted block containing the generated trait implementation
Requirements
Each struct member type must implement the Deserialize trait (it gets used in the generated code).
Example
For a struct like:
struct MyStruct {
x: AztecAddress,
y: Field,
}
This generates:
impl Deserialize for MyStruct {
let N: u32 = <AztecAddress as Deserialize>::N + <Field as Deserialize>::N;
fn deserialize(fields: [Field; Self::N]) -> Self {
letmut reader = Reader::new(fields);
let result = Self::stream_deserialize(&mut reader);
reader.finish();
result
}
#[inline_always]
fn stream_deserialize<let K: u32>(reader: &mut Reader<K>) -> Self {
let x = <AztecAddress as Deserialize>::stream_deserialize(reader);
let y = <Field as Deserialize>::stream_deserialize(reader);
Self { x, y }
}
}
Generates a
Deserializetrait implementation for a given structs.Arguments
s- The struct type definition to generate the implementation forReturns
A
Quotedblock containing the generated trait implementationRequirements
Each struct member type must implement the
Deserializetrait (it gets used in the generated code).Example
For a struct like:
This generates: