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.
Translates pretty well (from_slice is lacking some RC related checks just PoC code):
pub struct TpmRcCast<'a>(TpmUint32<'a>);
impl<'a> crate::TpmCast<'a> for TpmRcCast<'a> {
fn from_slice(slice: &'a [u8]) -> TpmResult<Self> {
Ok(TpmRcCast(TpmUint32::from_slice(slice)?))
}
fn as_slice(&self) -> &'a [u8] {
self.0.as_slice()
}
}