+ ($stream: expr, $type: expr, $field: expr, upgradable_required) => {
+ $crate::_encode_tlv!($stream, $type, $field, required);
+ };
+ ($stream: expr, $type: expr, $field: expr, upgradable_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);
+ };
+ ($stream: expr, $type: expr, $field: expr, (option, encoding: $fieldty: ty)) => {
+ $crate::_encode_tlv!($stream, $type, $field, option);
+ };
+ ($stream: expr, $type: expr, $field: expr, (option: $trait: ident $(, $read_arg: expr)?)) => {
+ // Just a read-mapped type
+ $crate::_encode_tlv!($stream, $type, $field, option);
+ };
+}
+
+/// Panics if the last seen TLV type is not numerically less than the TLV type currently being checked.
+/// This is exported for use by other exported macros, do not use directly.
+#[doc(hidden)]
+#[macro_export]
+macro_rules! _check_encoded_tlv_order {
+ ($last_type: expr, $type: expr, (static_value, $value: expr)) => { };
+ ($last_type: expr, $type: expr, $fieldty: tt) => {
+ if let Some(t) = $last_type {
+ #[allow(unused_comparisons)] // Note that $type may be 0 making the following comparison always false
+ (debug_assert!(t < $type))
+ }
+ $last_type = Some($type);
+ };