($stream: expr, $type: expr, $field: expr, ignorable) => {
$crate::_encode_tlv!($stream, $type, $field, required);
};
+ ($stream: expr, $type: expr, $field: expr, ignorable_option) => {
+ $crate::_encode_tlv!($stream, $type, $field, 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: expr, $type: expr, $field: expr, ignorable) => {
$crate::_get_varint_length_prefixed_tlv_length!($len, $type, $field, required);
};
+ ($len: expr, $type: expr, $field: expr, ignorable_option) => {
+ $crate::_get_varint_length_prefixed_tlv_length!($len, $type, $field, option);
+ };
}
/// See the documentation of [`write_tlv_fields`].
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
+ ($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, ignorable_option) => {{
+ // no-op
+ }};
($last_seen_type: expr, $typ: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
// no-op
}};
($last_seen_type: expr, $type: expr, $field: ident, ignorable) => {{
// no-op
}};
+ ($last_seen_type: expr, $type: expr, $field: ident, ignorable_option) => {{
+ // no-op
+ }};
($last_seen_type: expr, $type: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
// no-op
}};
($reader: expr, $field: ident, ignorable) => {{
$field = $crate::util::ser::MaybeReadable::read(&mut $reader)?;
}};
+ ($reader: expr, $field: ident, ignorable_option) => {{
+ $field = $crate::util::ser::MaybeReadable::read(&mut $reader)?;
+ }};
($reader: expr, $field: ident, (option: $trait: ident $(, $read_arg: expr)?)) => {{
$field = Some($trait::read(&mut $reader $(, $read_arg)*)?);
}};
($field: ident, ignorable) => {
if $field.is_none() { return Ok(None); } else { $field.unwrap() }
};
+ ($field: ident, ignorable_option) => {
+ $field
+ };
($field: ident, required) => {
$field.0.unwrap()
};
($field: ident, ignorable) => {
let mut $field = None;
};
+ ($field: ident, ignorable_option) => {
+ let mut $field = None;
+ };
}
/// Equivalent to running [`_init_tlv_field_var`] then [`read_tlv_fields`].