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 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 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_bytes_mut(&mut self) -> &mut [u8]
pub fn items_bytes_mut(&mut self) -> &mut [u8]
Returns the mutable bytes after the count field.