|
10 | 10 | #![allow(clippy::new_without_default)]
|
11 | 11 |
|
12 | 12 | pub use crate::naples::{ParameterTimePoint, ParameterTokenConfig};
|
13 |
| -use crate::struct_accessors::{Getter, Setter, make_accessors}; |
| 13 | +use crate::struct_accessors::{ |
| 14 | + Getter, Setter, make_accessors, make_bitfield_serde, |
| 15 | +}; |
14 | 16 | use crate::token_accessors::{Tokens, TokensMut, make_token_accessors};
|
15 | 17 | use crate::types::Error;
|
16 | 18 | use crate::types::PriorityLevel;
|
@@ -1243,88 +1245,6 @@ impl Default for GROUP_HEADER {
|
1243 | 1245 | }
|
1244 | 1246 | }
|
1245 | 1247 |
|
1246 |
| -/// A variant of the make_accessors macro for modular_bitfields. |
1247 |
| -macro_rules! make_bitfield_serde {( |
1248 |
| - $(#[$struct_meta:meta])* |
1249 |
| - $struct_vis:vis |
1250 |
| - struct $StructName:ident { |
1251 |
| - $( |
1252 |
| - $(#[$field_meta:meta])* |
1253 |
| - $field_vis:vis |
1254 |
| - $field_name:ident |
1255 |
| - $(|| $(#[$serde_field_orig_meta:meta])* $serde_ty:ty : $field_orig_ty:ty)? |
1256 |
| - $(: $field_ty:ty)? |
1257 |
| - $(| $getter_vis:vis get $field_user_ty:ty $(: $setter_vis:vis set $field_setter_user_ty:ty)?)? |
1258 |
| - ),* $(,)? |
1259 |
| - } |
1260 |
| -) => { |
1261 |
| - $(#[$struct_meta])* |
1262 |
| - $struct_vis |
1263 |
| - struct $StructName { |
1264 |
| - $( |
1265 |
| - $(#[$field_meta])* |
1266 |
| - $field_vis |
1267 |
| - $($field_name : $field_ty,)? |
1268 |
| - $($field_name : $field_orig_ty,)? |
1269 |
| - )* |
1270 |
| - } |
1271 |
| - |
1272 |
| - impl $StructName { |
1273 |
| - pub fn builder() -> Self { |
1274 |
| - Self::new() // NOT default |
1275 |
| - } |
1276 |
| - pub fn build(&self) -> Self { |
1277 |
| - self.clone() |
1278 |
| - } |
1279 |
| - } |
1280 |
| - |
1281 |
| - #[cfg(feature = "serde")] |
1282 |
| - impl $StructName { |
1283 |
| - $( |
1284 |
| - paste!{ |
1285 |
| - $( |
1286 |
| - pub(crate) fn [<serde_ $field_name>] (self : &'_ Self) |
1287 |
| - -> Result<$field_ty> { |
1288 |
| - Ok(self.$field_name()) |
1289 |
| - } |
1290 |
| - )? |
1291 |
| - $( |
1292 |
| - pub(crate) fn [<serde_ $field_name>] (self : &'_ Self) |
1293 |
| - -> Result<$serde_ty> { |
1294 |
| - Ok(self.$field_name().into()) |
1295 |
| - } |
1296 |
| - )? |
1297 |
| - $( |
1298 |
| - pub(crate) fn [<serde_with_ $field_name>](self : &mut Self, value: $field_ty) -> &mut Self { |
1299 |
| - self.[<set_ $field_name>](value.into()); |
1300 |
| - self |
1301 |
| - } |
1302 |
| - )? |
1303 |
| - $( |
1304 |
| - pub(crate) fn [<serde_with_ $field_name>](self : &mut Self, value: $serde_ty) -> &mut Self { |
1305 |
| - self.[<set_ $field_name>](value.into()); |
1306 |
| - self |
1307 |
| - } |
1308 |
| - )? |
1309 |
| - } |
1310 |
| - )* |
1311 |
| - } |
1312 |
| - |
1313 |
| - #[cfg(feature = "serde")] |
1314 |
| - paste::paste! { |
1315 |
| - #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] |
1316 |
| - #[cfg_attr(feature = "serde", serde(deny_unknown_fields))] |
1317 |
| - #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] |
1318 |
| - #[cfg_attr(feature = "serde", serde(rename = "" $StructName))] |
1319 |
| - pub(crate) struct [<Serde $StructName>] { |
1320 |
| - $( |
1321 |
| - $(pub $field_name : <$field_ty as Specifier>::InOut,)? |
1322 |
| - $($(#[$serde_field_orig_meta])* pub $field_name : $serde_ty,)? |
1323 |
| - )* |
1324 |
| - } |
1325 |
| - } |
1326 |
| -}} |
1327 |
| - |
1328 | 1248 | make_bitfield_serde! {
|
1329 | 1249 | #[bitfield(bits = 8)]
|
1330 | 1250 | #[repr(u8)]
|
@@ -1512,7 +1432,7 @@ pub mod gnb {
|
1512 | 1432 | use super::{
|
1513 | 1433 | BitfieldSpecifier, EntryCompatible, EntryId, FromBytes, FromPrimitive,
|
1514 | 1434 | Getter, GnbEntryId, Immutable, IntoBytes, KnownLayout, Result, Setter,
|
1515 |
| - ToPrimitive, Unaligned, paste, |
| 1435 | + ToPrimitive, Unaligned, make_bitfield_serde, paste, |
1516 | 1436 | };
|
1517 | 1437 | #[cfg(feature = "serde")]
|
1518 | 1438 | use super::{Deserialize, SerdeHex8, Serialize};
|
|
0 commit comments