tss_esapi/traits.rs
1// Copyright 2021 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3use crate::Result;
4
5/// Trait for types that can be converted into
6/// TPM marshalled data.
7pub trait Marshall: Sized {
8 const BUFFER_SIZE: usize;
9 /// Returns the type in the form of marshalled data
10 fn marshall(&self) -> Result<Vec<u8>>;
11}
12
13/// Trait for types that can be created from
14/// TPM marshalled data.
15pub trait UnMarshall: Sized {
16 /// Creates the type from marshalled data.
17 fn unmarshall(marshalled_data: &[u8]) -> Result<Self>;
18}