pub struct TpmUint16(/* private fields */);Implementations§
Source§impl TpmUint16
impl TpmUint16
pub const fn new(value: u16) -> Self
pub const fn value(self) -> u16
pub const fn get(&self) -> u16
pub const fn set(&mut self, value: u16)
pub const fn as_bytes(&self) -> &[u8; 2]
pub fn as_bytes_mut(&mut self) -> &mut [u8; 2]
pub fn to_be_bytes(self) -> [u8; 2]
pub const fn from_be_bytes(bytes: [u8; 2]) -> Self
Sourcepub fn cast(buf: &[u8]) -> TpmResult<&Self>
pub fn cast(buf: &[u8]) -> TpmResult<&Self>
Casts a byte slice into a TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
Returns TrailingData when
buf is larger than this integer’s wire size.
Sourcepub fn validate(buf: &[u8]) -> TpmResult<()>
pub fn validate(buf: &[u8]) -> TpmResult<()>
Validates an exact TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
Returns TrailingData when
buf is larger than this integer’s wire size.
Sourcepub fn validate_prefix(buf: &[u8]) -> TpmResult<()>
pub fn validate_prefix(buf: &[u8]) -> TpmResult<()>
Validates that buf starts with a TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
Sourcepub fn cast_prefix(buf: &[u8]) -> TpmResult<(&Self, &[u8])>
pub fn cast_prefix(buf: &[u8]) -> TpmResult<(&Self, &[u8])>
Casts the first bytes in a slice into a TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
Sourcepub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
pub unsafe fn cast_unchecked(buf: &[u8]) -> &Self
Casts a byte slice into a TPM integer wire view without validation.
§Safety
The caller must ensure that buf.len() equals this integer’s
wire size and that any containing protocol structure has been
validated as needed.
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 TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
Returns TrailingData when
buf is larger than this integer’s wire size.
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 mutable bytes in a slice into a TPM integer wire view.
§Errors
Returns UnexpectedEnd when
buf is smaller than this integer’s wire size.
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 TPM integer wire view without validation.
§Safety
The caller must ensure that buf.len() equals this integer’s
wire size and that any containing protocol structure has been
validated as needed. The returned reference inherits the
exclusive access represented by buf.