pub struct Tpm2b<const CAPACITY: usize>(/* private fields */);Expand description
A zero-copy TPM2B wire view over caller-owned bytes.
Implementations§
Source§impl<const CAPACITY: usize> Tpm2b<CAPACITY>
impl<const CAPACITY: usize> Tpm2b<CAPACITY>
Sourcepub fn cast(buf: &[u8]) -> TpmResult<&Self>
pub fn cast(buf: &[u8]) -> TpmResult<&Self>
Casts a byte slice into a TPM2B wire view.
§Errors
Returns UnexpectedEnd when
buf is shorter than the TPM2B header or declared payload size.
Returns TrailingData when
buf contains bytes after the declared payload.
Returns TooManyBytes when
the declared payload exceeds CAPACITY.
Sourcepub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
pub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
Casts a byte slice into a TPM2B wire view without validation.
§Safety
The caller must ensure that buf contains exactly one complete TPM2B
value and that its declared payload length 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 TPM2B wire view.
§Errors
Returns UnexpectedEnd when
buf is shorter than the TPM2B header or declared payload size.
Returns TrailingData when
buf contains bytes after the declared payload.
Returns TooManyBytes when
the declared payload 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 TPM2B wire view without validation.
§Safety
The caller must ensure that buf contains exactly one complete TPM2B
value and that its declared payload length 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 TPM2B byte representation.