pub struct Tpml<const CAPACITY: usize>(/* private fields */);Expand description
A zero-copy TPML wire view over caller-owned bytes.
Implementations§
Source§impl<const CAPACITY: usize> Tpml<CAPACITY>
impl<const CAPACITY: usize> Tpml<CAPACITY>
Sourcepub fn cast(buf: &[u8]) -> TpmResult<&Self>
pub fn cast(buf: &[u8]) -> TpmResult<&Self>
Casts a byte slice into a TPML wire view.
§Errors
Returns UnexpectedEnd when
buf is shorter than the TPML count field.
Returns TooManyItems when
the declared item count exceeds CAPACITY.
Sourcepub fn cast_items<T: TpmCast + ?Sized>(buf: &[u8]) -> TpmResult<&Self>
pub fn cast_items<T: TpmCast + ?Sized>(buf: &[u8]) -> TpmResult<&Self>
Casts a byte slice into a typed TPML wire view.
§Errors
Returns Err(TpmError) when the TPML header is malformed, the declared
count exceeds CAPACITY, or the typed item area is malformed.
Sourcepub fn cast_prefix_items<T: TpmCast + ?Sized>(
buf: &[u8],
) -> TpmResult<(&Self, &[u8])>
pub fn cast_prefix_items<T: TpmCast + ?Sized>( buf: &[u8], ) -> TpmResult<(&Self, &[u8])>
Casts the first typed TPML wire value in a byte slice into a wire view.
§Errors
Returns Err(TpmError) when the first typed TPML value is malformed.
Sourcepub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
pub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
Casts a byte slice into a TPML wire view without validation.
§Safety
The caller must ensure that buf starts with a complete TPML count
field and that the declared item count does not exceed CAPACITY.
Sourcepub fn cast_mut(buf: &mut [u8]) -> TpmResult<&mut Self>
pub fn cast_mut(buf: &mut [u8]) -> TpmResult<&mut Self>
Casts a mutable byte slice into a mutable TPML wire view.
§Errors
Returns UnexpectedEnd when
buf is shorter than the TPML count field.
Returns TooManyItems when
the declared item count exceeds CAPACITY.
Sourcepub fn cast_items_mut<T: TpmCast + ?Sized>(
buf: &mut [u8],
) -> TpmResult<&mut Self>
pub fn cast_items_mut<T: TpmCast + ?Sized>( buf: &mut [u8], ) -> TpmResult<&mut Self>
Casts a mutable byte slice into a typed TPML wire view.
§Errors
Returns Err(TpmError) when the TPML header is malformed, the declared
count exceeds CAPACITY, or the typed item area is malformed.
Sourcepub fn cast_prefix_items_mut<T: TpmCast + ?Sized>(
buf: &mut [u8],
) -> TpmResult<(&mut Self, &mut [u8])>
pub fn cast_prefix_items_mut<T: TpmCast + ?Sized>( buf: &mut [u8], ) -> TpmResult<(&mut Self, &mut [u8])>
Casts the first mutable typed TPML wire value in a byte slice into a wire view.
§Errors
Returns Err(TpmError) when the first typed TPML value is malformed.
Sourcepub unsafe fn cast_mut_unchecked(buf: &mut [u8]) -> &mut Self
pub unsafe fn cast_mut_unchecked(buf: &mut [u8]) -> &mut Self
Casts a mutable byte slice into a mutable TPML wire view without validation.
§Safety
The caller must ensure that buf starts with a complete TPML count
field and that the declared item count does not exceed CAPACITY. The
returned reference inherits the exclusive access represented by buf.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8]
pub fn as_bytes_mut(&mut self) -> &mut [u8]
Returns the complete mutable TPML byte representation.
Sourcepub fn items_bytes(&self) -> &[u8]
pub fn items_bytes(&self) -> &[u8]
Returns the bytes after the count field.
Sourcepub fn items<T: TpmCast + ?Sized>(&self) -> TpmlIter<'_, T> ⓘ
pub fn items<T: TpmCast + ?Sized>(&self) -> TpmlIter<'_, T> ⓘ
Returns an iterator over typed borrowed items.
Sourcepub fn items_bytes_mut(&mut self) -> &mut [u8]
pub fn items_bytes_mut(&mut self) -> &mut [u8]
Returns the mutable bytes after the count field.
Sourcepub fn validate(buf: &[u8]) -> TpmResult<()>
pub fn validate(buf: &[u8]) -> TpmResult<()>
Validates a TPML header and declared count.
§Errors
Returns Err(TpmError) when the count field is missing or exceeds
CAPACITY.