Skip to main content

TpmResponse

Struct TpmResponse 

Source
pub struct TpmResponse(/* private fields */);
Expand description

A zero-copy TPM response wire view over caller-owned bytes.

Implementations§

Source§

impl TpmResponse

Source

pub fn cast(buf: &[u8]) -> TpmResult<&Self>

Casts a byte slice into a TPM response wire view.

§Errors

Returns Err(TpmProtocolError) when the response envelope is malformed.

Source

pub unsafe fn cast_unchecked(buf: &[u8]) -> &Self

Casts a byte slice into a TPM response wire view without validation.

§Safety

The caller must ensure that buf contains exactly one complete TPM response frame.

Source

pub fn cast_mut(buf: &mut [u8]) -> TpmResult<&mut Self>

Casts a mutable byte slice into a mutable TPM response wire view.

§Errors

Returns Err(TpmProtocolError) when the response envelope is malformed.

Source

pub unsafe fn cast_mut_unchecked(buf: &mut [u8]) -> &mut Self

Casts a mutable byte slice into a mutable TPM response wire view without validation.

§Safety

The caller must ensure that buf contains exactly one complete TPM response frame. The returned reference inherits the exclusive access represented by buf.

Source

pub const fn as_bytes(&self) -> &[u8]

Returns the complete response frame bytes.

Source

pub fn as_bytes_mut(&mut self) -> &mut [u8]

Returns the mutable response frame bytes.

Source

pub fn tag(&self) -> TpmResult<TpmSt>

Returns the response tag.

§Errors

Returns VariantNotAvailable when the tag value is not defined.

Source

pub fn size(&self) -> u32

Returns the response frame size field.

Source

pub fn rc(&self) -> TpmResult<TpmRc>

Returns the response code.

§Errors

Returns Err(TpmProtocolError) when the response code is malformed.

Source

pub fn set_tag(&mut self, tag: TpmSt)

Sets the response tag without changing the frame shape.

Source

pub fn set_rc(&mut self, rc: TpmRc)

Sets the response code without changing the frame shape.

Source

pub fn body(&self) -> &[u8]

Returns the response body bytes after the TPM header.

Source

pub fn body_mut(&mut self) -> &mut [u8]

Returns the mutable response body bytes after the TPM header.

Source

pub fn validate(&self, cc: TpmCc) -> TpmResult<()>

Validates response frame structure without constructing an owned response body.

§Errors

Returns Err(TpmProtocolError) when the response frame is malformed or cc has no dispatch entry.

Source

pub const fn is_empty(&self) -> bool

Returns true when the response frame contains no bytes.

Source

pub const fn len(&self) -> usize

Returns the response frame length.

Trait Implementations§

Source§

impl AsMut<[u8]> for TpmResponse

Source§

fn as_mut(&mut self) -> &mut [u8]

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl AsRef<[u8]> for TpmResponse

Source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl TpmCast for TpmResponse

Source§

fn cast(buf: &[u8]) -> TpmResult<&Self>

Casts buf into Self after validating the wire-view invariants. Read more
Source§

unsafe fn cast_unchecked(buf: &[u8]) -> &Self

Casts buf into Self without validating the wire-view invariants. Read more
Source§

impl TpmCastMut for TpmResponse

Source§

fn cast_mut(buf: &mut [u8]) -> TpmResult<&mut Self>

Casts buf into mutable Self after validating the wire-view invariants. Read more
Source§

unsafe fn cast_mut_unchecked(buf: &mut [u8]) -> &mut Self

Casts buf into mutable Self without validating the wire-view invariants. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more