tss_esapi/structures/property/
algorithm_property.rs1use crate::{
5 attributes::AlgorithmAttributes, constants::AlgorithmIdentifier, tss2_esys::TPMS_ALG_PROPERTY,
6 Error, Result,
7};
8use std::convert::{TryFrom, TryInto};
9
10#[derive(Copy, Clone, Debug, PartialEq, Eq)]
17pub struct AlgorithmProperty {
18 algorithm_identifier: AlgorithmIdentifier,
19 algorithm_properties: AlgorithmAttributes,
20}
21
22impl AlgorithmProperty {
23 pub const fn new(
26 algorithm_identifier: AlgorithmIdentifier,
27 algorithm_properties: AlgorithmAttributes,
28 ) -> Self {
29 AlgorithmProperty {
30 algorithm_identifier,
31 algorithm_properties,
32 }
33 }
34
35 pub const fn algorithm_identifier(&self) -> AlgorithmIdentifier {
37 self.algorithm_identifier
38 }
39
40 pub const fn algorithm_properties(&self) -> AlgorithmAttributes {
42 self.algorithm_properties
43 }
44}
45
46impl TryFrom<TPMS_ALG_PROPERTY> for AlgorithmProperty {
47 type Error = Error;
48
49 fn try_from(tpms_algorithm_description: TPMS_ALG_PROPERTY) -> Result<Self> {
50 Ok(AlgorithmProperty {
51 algorithm_identifier: tpms_algorithm_description.alg.try_into()?,
52 algorithm_properties: tpms_algorithm_description.algProperties.into(),
53 })
54 }
55}
56
57impl From<AlgorithmProperty> for TPMS_ALG_PROPERTY {
58 fn from(algorithm_description: AlgorithmProperty) -> Self {
59 TPMS_ALG_PROPERTY {
60 alg: algorithm_description.algorithm_identifier.into(),
61 algProperties: algorithm_description.algorithm_properties.into(),
62 }
63 }
64}