Cast version TPM structures starts to shape:
use crate::{tpm_struct_cast, TpmUint32, TpmUint64, TpmUint8};
tpm_struct_cast! {
name: TpmsClockInfoCast,
field_enum: TpmsClockInfoField,
field_ref_enum: TpmsClockInfoFieldRef,
fields: {
(pub clock: TpmUint64<'a>),
(pub reset_count: TpmUint32<'a>),
(pub restart_count: TpmUint32<'a>),
(pub safe: TpmUint8<'a>),
}
}
And after migration is completed:
use crate::{tpm_struct_cast, TpmUint32, TpmUint64, TpmUint8};
tpm_struct! {
name: TpmsClockInfo,
field_enum: TpmsClockInfoField,
field_ref_enum: TpmsClockInfoFieldRef,
fields: {
(pub clock: TpmUint64<'a>),
(pub reset_count: TpmUint32<'a>),
(pub restart_count: TpmUint32<'a>),
(pub safe: TpmUint8<'a>),
}
}
no SIZE constant anymore in the new TpmSized as no stack allocation is required:
/// Provides a `dyn`-safe way to get the exact size of a zero-copy cast object.
pub trait TpmSizedCast {
/// Returns the exact serialized size of the object.
fn len(&self) -> usize;
/// Returns `true` if the object has a serialized length of zero.
fn is_empty(&self) -> bool {
self.len() == 0
}
}
This ought to be renamed as TpmSized as full migration is over :-) Applies also to all other *Cast.