pub struct TpmWireBytes<const N: usize>(/* private fields */);Expand description
A byte-backed TPM wire view with a fixed byte length.
Implementations§
Source§impl<const N: usize> TpmWireBytes<N>
impl<const N: usize> TpmWireBytes<N>
Sourcepub fn cast(buf: &[u8]) -> TpmResult<&Self>
pub fn cast(buf: &[u8]) -> TpmResult<&Self>
Casts a byte slice into a fixed-size TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
Returns TrailingData when
buf is larger than N bytes.
Sourcepub fn validate(buf: &[u8]) -> TpmResult<()>
pub fn validate(buf: &[u8]) -> TpmResult<()>
Validates an exact fixed-size TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
Returns TrailingData when
buf is larger than N bytes.
Sourcepub fn validate_prefix(buf: &[u8]) -> TpmResult<()>
pub fn validate_prefix(buf: &[u8]) -> TpmResult<()>
Validates that buf starts with a fixed-size TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
Sourcepub fn cast_prefix(buf: &[u8]) -> TpmResult<(&Self, &[u8])>
pub fn cast_prefix(buf: &[u8]) -> TpmResult<(&Self, &[u8])>
Casts the first N bytes into a fixed-size TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
Sourcepub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
pub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
Casts a byte slice into a fixed-size TPM wire view without validation.
§Safety
The caller must ensure that buf.len() == N. Callers must also ensure
any higher-level protocol invariants required by later typed accessors
have been validated.
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 fixed-size mutable TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
Returns TrailingData when
buf is larger than N bytes.
Sourcepub fn cast_prefix_mut(buf: &mut [u8]) -> TpmResult<(&mut Self, &mut [u8])>
pub fn cast_prefix_mut(buf: &mut [u8]) -> TpmResult<(&mut Self, &mut [u8])>
Casts the first N mutable bytes into a fixed-size TPM wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than N bytes.
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 fixed-size mutable TPM wire view without validation.
§Safety
The caller must ensure that buf.len() == N. Callers must also ensure
any higher-level protocol invariants required by later typed accessors
have been validated. The returned reference inherits the exclusive
access represented by buf.
Sourcepub fn as_bytes_mut(&mut self) -> &mut [u8; N]
pub fn as_bytes_mut(&mut self) -> &mut [u8; N]
Returns the mutable backing bytes.