Skip to main content

TpmCast

Trait TpmCast 

Source
pub trait TpmCast {
    // Required methods
    fn cast(buf: &[u8]) -> TpmResult<&Self>;
    unsafe fn cast_unchecked(buf: &[u8]) -> &Self;

    // Provided method
    fn cast_prefix(buf: &[u8]) -> TpmResult<(&Self, &[u8])> { ... }
}
Expand description

Casts caller-owned bytes into a TPM wire view.

Required Methods§

Source

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

Casts buf into Self after validating the wire-view invariants.

§Errors

Returns Err(TpmError) when buf does not satisfy the invariants for Self.

Source

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

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

§Safety

The caller must ensure that buf satisfies the same invariants checked by TpmCast::cast.

Provided Methods§

Source

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

Casts the first wire value in buf into Self and returns the remainder.

§Errors

Returns Err(TpmError) when buf does not start with a valid Self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§