From: Jarkko Sakkinen <jarkko@kernel.org>
To: tpm-protocol@lists.linux.dev
Cc: tpm2@lists.linux.dev, Jarkko Sakkinen <jarkko@kernel.org>
Subject: [PATCH] refactor!(message): decouple TpmHeader from the build trait
Date: Sun, 31 Aug 2025 19:25:28 +0300 [thread overview]
Message-ID: <20250831162528.482704-1-jarkko@kernel.org> (raw)
In order to make the command build trait more symmetrical with the parse
trait, decouple `TpmHeader` from the trait. Rename the trait as
`TpmCommandBuild`.
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
---
I think I'll backport this too to the 0.10.x as it by pracical means
does not affect the consumed API and user volumes are still low.
src/macro/struct.rs | 6 +++---
src/message/build.rs | 4 ++--
src/message/mod.rs | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/macro/struct.rs b/src/macro/struct.rs
index 01e2cfb..ad5303f 100644
--- a/src/macro/struct.rs
+++ b/src/macro/struct.rs
@@ -36,12 +36,12 @@ macro_rules! tpm_struct {
impl $crate::TpmBuild for $name {
#[allow(unused_variables)]
fn build(&self, writer: &mut $crate::TpmWriter) -> $crate::TpmResult<()> {
- <Self as $crate::message::TpmHeaderCommand>::build_handles(self, writer)?;
- <Self as $crate::message::TpmHeaderCommand>::build_parameters(self, writer)
+ <Self as $crate::message::TpmCommandBuild>::build_handles(self, writer)?;
+ <Self as $crate::message::TpmCommandBuild>::build_parameters(self, writer)
}
}
- impl $crate::message::TpmHeaderCommand for $name {
+ impl $crate::message::TpmCommandBuild for $name {
#[allow(unused_variables)]
fn build_handles(&self, writer: &mut $crate::TpmWriter) -> $crate::TpmResult<()> {
$($crate::TpmBuild::build(&self.$handle_field, writer)?;)*
diff --git a/src/message/build.rs b/src/message/build.rs
index 4170513..41a7fee 100644
--- a/src/message/build.rs
+++ b/src/message/build.rs
@@ -4,7 +4,7 @@
use crate::{
data::{TpmRc, TpmSt, TpmsAuthCommand, TpmsAuthResponse},
- message::{TpmHeader, TpmHeaderCommand, TPM_HEADER_SIZE},
+ message::{TpmCommandBuild, TpmHeader, TPM_HEADER_SIZE},
TpmBuild, TpmErrorKind, TpmResult, TpmSized,
};
use core::mem::size_of;
@@ -21,7 +21,7 @@ pub fn tpm_build_command<C>(
writer: &mut crate::TpmWriter,
) -> TpmResult<()>
where
- C: TpmHeaderCommand,
+ C: TpmHeader + TpmCommandBuild,
{
match tag {
TpmSt::NoSessions => {
diff --git a/src/message/mod.rs b/src/message/mod.rs
index eb0d3f0..2d02361 100644
--- a/src/message/mod.rs
+++ b/src/message/mod.rs
@@ -60,7 +60,7 @@ pub trait TpmHeader: TpmBuild + Debug {
}
/// A trait for building command bodies in separate handle and parameter sections.
-pub trait TpmHeaderCommand: TpmHeader {
+pub trait TpmCommandBuild {
/// Builds the handle area of the command.
///
/// # Errors
--
2.39.5
next reply other threads:[~2025-08-31 16:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-31 16:25 Jarkko Sakkinen [this message]
2025-08-31 16:29 ` [PATCH] refactor!(message): decouple TpmHeader from the build trait Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250831162528.482704-1-jarkko@kernel.org \
--to=jarkko@kernel.org \
--cc=tpm-protocol@lists.linux.dev \
--cc=tpm2@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox