Skip to main content

TpmWire

Struct TpmWire 

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

A byte-backed TPM wire view.

Implementations§

Source§

impl TpmWire

Source

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

Casts a byte slice into a TPM wire view.

Source

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

Casts a byte slice into a TPM wire view and returns no remainder.

Source

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

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

§Safety

TpmWire has no additional validity requirements beyond the validity of buf. Callers must still ensure any higher-level protocol invariants required by later typed accessors have been validated.

Source

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

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

Source

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

Casts a mutable byte slice into a mutable TPM wire view and returns no remainder.

Source

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

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

§Safety

TpmWire has no additional validity requirements beyond the validity of buf. Callers must still ensure any higher-level protocol invariants required by later typed accessors have been validated. The returned reference inherits the exclusive access represented by buf.

Source

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

Returns the backing bytes.

Source

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

Returns the mutable backing bytes.

Source

pub const fn len(&self) -> usize

Returns the number of backing bytes.

Source

pub const fn is_empty(&self) -> bool

Returns true when the backing byte slice is empty.

Trait Implementations§

Source§

impl AsMut<[u8]> for TpmWire

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 TpmWire

Source§

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

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

impl TpmCast for TpmWire

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 TpmWire

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