Skip to main content

ByteParser

Trait ByteParser 

Source
pub trait ByteParser<P> {
    type Bytes: AsRef<[u8]>;

    const EXPECTED_LEN: Option<usize> = None;

    // Provided methods
    fn from_bytes_with(bytes: &[u8], params: P) -> Result<Self, Error>
       where Self: Sized + Decoder<P> { ... }
    fn to_bytes_with(&self, params: P) -> Result<Self::Bytes, Error>
       where Self: Encoder<P>,
             Self::Bytes: TryFrom<Vec<u8>> { ... }
    fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
       where Self: Sized + Decoder<()> { ... }
    fn to_bytes(&self) -> Result<Self::Bytes, Error>
       where Self: Encoder<()>,
             Self::Bytes: TryFrom<Vec<u8>> { ... }
}
Expand description

Adapter trait: convert to/from an owned byte container using Encoder/Decoder.

Provided Associated Constants§

Source

const EXPECTED_LEN: Option<usize> = None

Expected size of the byte container

Required Associated Types§

Source

type Bytes: AsRef<[u8]>

Byte container definition Must be constructible and mutable as bytes for encoding,

Provided Methods§

Source

fn from_bytes_with(bytes: &[u8], params: P) -> Result<Self, Error>
where Self: Sized + Decoder<P>,

Decode from an owned byte container with params.

Source

fn to_bytes_with(&self, params: P) -> Result<Self::Bytes, Error>
where Self: Encoder<P>, Self::Bytes: TryFrom<Vec<u8>>,

Encode into an owned byte container with params.

Source

fn from_bytes(bytes: &[u8]) -> Result<Self, Error>
where Self: Sized + Decoder<()>,

Helper from_bytes Function in case no parameters are needed

Source

fn to_bytes(&self) -> Result<Self::Bytes, Error>
where Self: Encoder<()>, Self::Bytes: TryFrom<Vec<u8>>,

Helper to_bytes function in case no parameters are needed

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ByteParser<()> for i8

Source§

type Bytes = [u8; 1]

Source§

impl ByteParser<()> for i16

Source§

type Bytes = [u8; 2]

Source§

impl ByteParser<()> for i32

Source§

type Bytes = [u8; 4]

Source§

impl ByteParser<()> for i64

Source§

type Bytes = [u8; 8]

Source§

impl ByteParser<()> for i128

Source§

type Bytes = [u8; 16]

Source§

impl ByteParser<()> for isize

Source§

type Bytes = [u8; 8]

Source§

impl ByteParser<()> for u8

Source§

type Bytes = [u8; 1]

Source§

impl ByteParser<()> for u16

Source§

type Bytes = [u8; 2]

Source§

impl ByteParser<()> for u32

Source§

type Bytes = [u8; 4]

Source§

impl ByteParser<()> for u64

Source§

type Bytes = [u8; 8]

Source§

impl ByteParser<()> for u128

Source§

type Bytes = [u8; 16]

Source§

impl ByteParser<()> for usize

Source§

type Bytes = [u8; 8]

Source§

impl ByteParser<()> for Vec<u8>

Source§

type Bytes = Vec<u8>

Source§

fn from_bytes(slice: &[u8]) -> Result<Self>

Source§

fn to_bytes(&self) -> Result<Self::Bytes>

Source§

impl<const N: usize> ByteParser<()> for [u8; N]

Source§

const EXPECTED_LEN: Option<usize>

Source§

type Bytes = [u8; N]

Source§

fn from_bytes(slice: &[u8]) -> Result<Self>

Source§

fn to_bytes(&self) -> Result<Self::Bytes>

Implementors§

Source§

impl ByteParser<Generation> for SnpPlatformStatus

Source§

impl ByteParser<Generation> for TcbVersion

Source§

impl ByteParser<Generation> for WrappedVlekHashstick

Source§

impl ByteParser<()> for ReportVariant

Source§

impl ByteParser<()> for CertType

Source§

impl ByteParser<()> for Signature

Source§

impl ByteParser<()> for AttestationReport

Source§

impl ByteParser<()> for GuestPolicy

Source§

impl ByteParser<()> for KeyInfo

Source§

impl ByteParser<()> for PlatformInfo

Source§

impl ByteParser<()> for Version

Source§

impl ByteParser<()> for CertTableEntry

Source§

impl ByteParser<()> for MaskId

Source§

impl ByteParser<()> for PlatformInit

Source§

impl ByteParser<()> for PlatformPolicy