Skip to main content

TpmCommand

Struct TpmCommand 

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

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

Implementations§

Source§

impl TpmCommand

Source

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

Casts a byte slice into a TPM command wire view.

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

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

Casts the first TPM command frame in a byte slice into a wire view.

§Errors

Returns Err(TpmError) when the command envelope is malformed or incomplete.

Source

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

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

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

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

Casts the first mutable TPM command frame in a byte slice into a wire view.

§Errors

Returns Err(TpmError) when the command envelope is malformed or incomplete.

Source

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

Returns the complete command frame bytes.

Source

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

Returns the mutable command frame bytes.

Source

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

Returns the command tag.

§Errors

Returns VariantNotAvailable when the tag value is not defined.

Source

pub fn size(&self) -> u32

Returns the command frame size field.

Source

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

Returns the command code.

§Errors

Returns InvalidCc when the command code has no dispatch entry.

Source

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

Sets the command tag without changing the frame shape.

Source

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

Sets the command code without changing the frame shape.

§Errors

Returns InvalidCc when the command code has no dispatch entry.

Source

pub fn handles(&self) -> TpmResult<&[u8]>

Returns the command handle area bytes.

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

pub fn handles_mut(&mut self) -> TpmResult<&mut [u8]>

Returns the mutable command handle area bytes.

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

pub fn auth_area(&self) -> TpmResult<&[u8]>

Returns the command authorization area bytes.

§Errors

Returns Err(TpmError) when the command has no sessions or its authorization area is malformed.

Source

pub fn auth_area_mut(&mut self) -> TpmResult<&mut [u8]>

Returns the mutable command authorization area bytes.

§Errors

Returns Err(TpmError) when the command has no sessions or its authorization area is malformed.

Source

pub fn parameters(&self) -> TpmResult<&[u8]>

Returns the command parameter area bytes.

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

pub fn parameters_mut(&mut self) -> TpmResult<&mut [u8]>

Returns the mutable command parameter area bytes.

§Errors

Returns Err(TpmError) when the command envelope is malformed.

Source

pub fn validate(&self) -> TpmResult<()>

Validates command frame structure without constructing an owned command body.

§Errors

Returns Err(TpmError) when the command frame is malformed.

Source

pub const fn is_empty(&self) -> bool

Returns true when the command frame contains no bytes.

Source

pub const fn len(&self) -> usize

Returns the command frame length.

Source§

impl TpmCommand

Source

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

Casts a byte slice into this wire view without validation.

§Safety

The caller must ensure buf satisfies every invariant required by the checked constructors for this view.

Source

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

Casts a mutable byte slice into this wire view without validation.

§Safety

The caller must ensure buf satisfies every invariant required by the checked constructors for this view. The returned reference inherits the exclusive access represented by buf.

Trait Implementations§

Source§

impl AsMut<[u8]> for TpmCommand

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 TpmCommand

Source§

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

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

impl TpmCast for TpmCommand

Source§

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

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

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

Casts the first wire value in buf into Self and returns the remainder. 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 TpmCommand

Source§

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

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

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

Casts the first mutable wire value in buf into Self and returns the remainder. 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
Source§

impl<'a, T> TpmField<'a> for T
where T: TpmCast + 'a + ?Sized,

Source§

type View = &'a T

Source§

fn cast_prefix_field( buf: &'a [u8], ) -> Result<(<T as TpmField<'a>>::View, &'a [u8]), TpmError>

Reads the first field from buf and returns the remaining bytes. Read more