Skip to main content

Tpml

Struct Tpml 

Source
pub struct Tpml<const CAPACITY: usize>(/* private fields */);
Expand description

A zero-copy TPML wire view over caller-owned bytes.

Implementations§

Source§

impl<const CAPACITY: usize> Tpml<CAPACITY>

Source

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

Casts a byte slice into a TPML wire view.

§Errors

Returns UnexpectedEnd when buf is shorter than the TPML count field. Returns TooManyItems when the declared item count exceeds CAPACITY.

Source

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

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

§Safety

The caller must ensure that buf starts with a complete TPML count field and that the declared item count does not exceed CAPACITY.

Source

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

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

§Errors

Returns UnexpectedEnd when buf is shorter than the TPML count field. Returns TooManyItems when the declared item count exceeds CAPACITY.

Source

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

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

§Safety

The caller must ensure that buf starts with a complete TPML count field and that the declared item count does not exceed CAPACITY. The returned reference inherits the exclusive access represented by buf.

Source

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

Returns the complete TPML byte representation.

Source

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

Returns the complete mutable TPML byte representation.

Source

pub fn count(&self) -> usize

Returns the declared item count.

Source

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

Returns the bytes after the count field.

Source

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

Returns the mutable bytes after the count field.

Source

pub const fn len(&self) -> usize

Returns the complete TPML wire length.

Source

pub fn is_empty(&self) -> bool

Returns true when the declared item count is zero.

Trait Implementations§

Source§

impl<const CAPACITY: usize> AsMut<[u8]> for Tpml<CAPACITY>

Source§

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

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

impl<const CAPACITY: usize> AsRef<[u8]> for Tpml<CAPACITY>

Source§

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

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

impl<const CAPACITY: usize> TpmCast for Tpml<CAPACITY>

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<const CAPACITY: usize> TpmCastMut for Tpml<CAPACITY>

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§

§

impl<const CAPACITY: usize> Freeze for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> RefUnwindSafe for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> Send for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> !Sized for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> Sync for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> Unpin for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> UnsafeUnpin for Tpml<CAPACITY>

§

impl<const CAPACITY: usize> UnwindSafe for Tpml<CAPACITY>

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