If you try to derive just Encode on a struct, using transparent, you are required to add skip_deserializing to all but one struct field, even if you aren't deriving Decode.
Example:
#[derive(Debug, Clone, PartialEq, Encode)]
#[ssz(struct_behaviour = "transparent")]
pub struct RuntimeVariableList<T: Encode> {
vec: Vec<T>,
#[ssz(skip_serializing)]
max_len: usize,
}
The above results in:
error: proc-macro derive panicked
--> beacon_node/lighthouse_network/src/rpc/methods.rs:346:35
|
346 | #[derive(Debug, Clone, PartialEq, Encode)]
| ^^^^^^
|
= help: message: A "transparent" struct must have exactly one non-skipped field (2 fields found)
error: could not compile `lighthouse_network` (lib) due to previous error
Whereas the following compiles fine:
#[derive(Debug, Clone, PartialEq, Encode)]
#[ssz(struct_behaviour = "transparent")]
pub struct RuntimeVariableList<T: Encode> {
vec: Vec<T>,
#[ssz(skip_serializing, skip_deserializing)]
max_len: usize,
}
If you try to derive just
Encodeon a struct, usingtransparent, you are required to addskip_deserializingto all but one struct field, even if you aren't derivingDecode.Example:
The above results in:
Whereas the following compiles fine: