Skip to content

Commit f89dc63

Browse files
committed
Add builder methods and move NvPublic
This commit brings two changes: * implementing `builder` methods on all types that have their own `...Builder` type, so that users are more easily directed to them in the documentation. * moving the `nv` top-level module within the `structures` module to make things a bit more consistent. Signed-off-by: Ionut Mihalcea <[email protected]>
1 parent ca3e739 commit f89dc63

File tree

19 files changed

+77
-19
lines changed

19 files changed

+77
-19
lines changed

tss-esapi/src/abstraction/nv.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ use crate::{
77
constants::{tss::*, CapabilityType, PropertyTag},
88
handles::{NvIndexHandle, NvIndexTpmHandle, TpmHandle},
99
interface_types::resource_handles::NvAuth,
10-
nv::storage::NvPublic,
11-
structures::{CapabilityData, Name},
10+
structures::{CapabilityData, Name, NvPublic},
1211
Context, Error, Result, WrapperErrorKind,
1312
};
1413

tss-esapi/src/abstraction/transient/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,11 @@ impl TransientKeyContext {
521521
}
522522
Ok(key_handle)
523523
}
524+
525+
/// Get a builder for the structure
526+
pub fn builder() -> TransientKeyContextBuilder {
527+
TransientKeyContextBuilder::new()
528+
}
524529
}
525530

526531
/// Build a new `TransientKeyContext`.

tss-esapi/src/attributes/locality.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl LocalityAttributes {
5151
}
5252

5353
/// Returns the builder used to construct LocalAttributes.
54-
pub fn builder() -> LocalityAttributesBuilder {
54+
pub const fn builder() -> LocalityAttributesBuilder {
5555
LocalityAttributesBuilder::new()
5656
}
5757
}

tss-esapi/src/attributes/nv_index.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ impl NvIndexAttributes {
107107

108108
Ok(())
109109
}
110+
111+
/// Get a builder for the structure
112+
pub const fn builder() -> NvIndexAttributesBuilder {
113+
NvIndexAttributesBuilder::new()
114+
}
110115
}
111116

112117
impl TryFrom<TPMA_NV> for NvIndexAttributes {

tss-esapi/src/attributes/object.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ impl ObjectAttributes {
5858
attrs.set_sign_encrypt(true);
5959
attrs
6060
}
61+
62+
/// Get a builder for the structure
63+
pub const fn builder() -> ObjectAttributesBuilder {
64+
ObjectAttributesBuilder::new()
65+
}
6166
}
6267

6368
impl From<ObjectAttributes> for TPMA_OBJECT {

tss-esapi/src/attributes/session.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ bitfield! {
2424
pub audit, _: 7;
2525
}
2626

27+
impl SessionAttributes {
28+
/// Get a builder for the structure
29+
pub const fn builder() -> SessionAttributesBuilder {
30+
SessionAttributesBuilder::new()
31+
}
32+
}
33+
2734
impl From<TPMA_SESSION> for SessionAttributes {
2835
fn from(tss_session_attributes: TPMA_SESSION) -> SessionAttributes {
2936
SessionAttributes(tss_session_attributes)
@@ -53,6 +60,13 @@ bitfield! {
5360
_, use_audit: 7;
5461
}
5562

63+
impl SessionAttributesMask {
64+
/// Get a builder for the structure
65+
pub const fn builder() -> SessionAttributesBuilder {
66+
SessionAttributesBuilder::new()
67+
}
68+
}
69+
5670
impl From<TPMA_SESSION> for SessionAttributesMask {
5771
fn from(tss_session_attributes: TPMA_SESSION) -> SessionAttributesMask {
5872
SessionAttributesMask(tss_session_attributes)
@@ -77,7 +91,7 @@ pub struct SessionAttributesBuilder {
7791
}
7892

7993
impl SessionAttributesBuilder {
80-
pub fn new() -> SessionAttributesBuilder {
94+
pub const fn new() -> SessionAttributesBuilder {
8195
SessionAttributesBuilder {
8296
attributes: SessionAttributes(0),
8397
mask: SessionAttributesMask(0),

tss-esapi/src/context/tpm_commands/non_volatile_storage.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ use crate::{
44
context::handle_manager::HandleDropAction,
55
handles::{AuthHandle, NvIndexHandle},
66
interface_types::resource_handles::{NvAuth, Provision},
7-
nv::storage::NvPublic,
8-
structures::{Auth, MaxNvBuffer, Name},
7+
structures::{Auth, MaxNvBuffer, Name, NvPublic},
98
tss2_esys::*,
109
Context, Error, Result,
1110
};

tss-esapi/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ mod context;
109109
mod error;
110110
pub mod handles;
111111
pub mod interface_types;
112-
pub mod nv;
113112
pub mod structures;
114113
pub mod tcti_ldr;
115114
pub mod traits;

tss-esapi/src/structures/lists/pcr_selection.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ impl PcrSelectionList {
8181
.and_then(|existing_pcr_selection| existing_pcr_selection.deselect_exact(pcr_slot))
8282
})
8383
}
84+
85+
/// Get a builder for this structure
86+
pub fn builder() -> PcrSelectionListBuilder {
87+
PcrSelectionListBuilder::new()
88+
}
8489
}
8590

8691
impl From<PcrSelectionList> for TPML_PCR_SELECTION {

tss-esapi/src/structures/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,9 @@ pub use property::{
198198
algorithm_property::AlgorithmProperty, tagged_pcr_select::TaggedPcrSelect,
199199
tagged_property::TaggedProperty,
200200
};
201+
202+
/////////////////////////////////////////////////////////
203+
/// NV structures
204+
/////////////////////////////////////////////////////////
205+
mod nv;
206+
pub use nv::storage::{NvPublic, NvPublicBuilder};

0 commit comments

Comments
 (0)