An enum implements de/serialization via
`impl_writeable_tlv_based_enum_upgradable` currently cannot contain
an object that only implements `MaybeReadable`.
This solves that by implementing the required blocks for
`ignorable`, opting to return `Ok(None)` in the top-level read in
cases where the inner field read returns `Ok(None)`.
field.write($stream)?;
}
};
field.write($stream)?;
}
};
+ ($stream: expr, $type: expr, $field: expr, ignorable) => {
+ $crate::_encode_tlv!($stream, $type, $field, required);
+ };
($stream: expr, $type: expr, $field: expr, (option, encoding: ($fieldty: ty, $encoding: ident))) => {
$crate::_encode_tlv!($stream, $type, $field.map(|f| $encoding(f)), option);
};
($stream: expr, $type: expr, $field: expr, (option, encoding: ($fieldty: ty, $encoding: ident))) => {
$crate::_encode_tlv!($stream, $type, $field.map(|f| $encoding(f)), option);
};
$len.0 += field_len;
}
};
$len.0 += field_len;
}
};
+ ($len: expr, $type: expr, $field: expr, ignorable) => {
+ $crate::_get_varint_length_prefixed_tlv_length!($len, $type, $field, required);
+ };
}
/// See the documentation of [`write_tlv_fields`].
}
/// See the documentation of [`write_tlv_fields`].
($field: ident, option) => {
$field
};
($field: ident, option) => {
$field
};
+ ($field: ident, ignorable) => {
+ if $field.is_none() { return Ok(None); } else { $field.unwrap() }
+ };
($field: ident, required) => {
$field.0.unwrap()
};
($field: ident, required) => {
$field.0.unwrap()
};
($field: ident, option) => {
let mut $field = None;
};
($field: ident, option) => {
let mut $field = None;
};
+ ($field: ident, ignorable) => {
+ let mut $field = None;
+ };
}
/// Equivalent to running [`_init_tlv_field_var`] then [`read_tlv_fields`].
}
/// Equivalent to running [`_init_tlv_field_var`] then [`read_tlv_fields`].