Skip to main content

TpmWireBytes

Struct TpmWireBytes 

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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

Returns the backing bytes.

Source

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

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 array is empty.

Source§

impl<const N: usize> TpmWireBytes<N>

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<const N: usize> AsMut<[u8]> for TpmWireBytes<N>

Source§

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

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

impl<const N: usize> AsRef<[u8]> for TpmWireBytes<N>

Source§

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

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

impl<const N: usize> TpmCast for TpmWireBytes<N>

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<const N: usize> TpmCastMut for TpmWireBytes<N>

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§

§

impl<const N: usize> Freeze for TpmWireBytes<N>

§

impl<const N: usize> RefUnwindSafe for TpmWireBytes<N>

§

impl<const N: usize> Send for TpmWireBytes<N>

§

impl<const N: usize> Sync for TpmWireBytes<N>

§

impl<const N: usize> Unpin for TpmWireBytes<N>

§

impl<const N: usize> UnsafeUnpin for TpmWireBytes<N>

§

impl<const N: usize> UnwindSafe for TpmWireBytes<N>

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.