Skip to content

Commit 60d7a3c

Browse files
committed
common: Replace APIVersion with the library Version structure
The structures APIVersion defined in common.rs was equivalent to the Version structure defined in the library. Remove APIVersion in favor of the Version structure from the library. Signed-off-by: Anderson Toshiyuki Sasaki <[email protected]>
1 parent bdcc491 commit 60d7a3c

File tree

3 files changed

+7
-19
lines changed

3 files changed

+7
-19
lines changed

keylime-agent/src/common.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,6 @@ use tss_esapi::{
2929
structures::PcrSlot, traits::UnMarshall, utils::TpmsContext,
3030
};
3131

32-
#[derive(Serialize, Deserialize, Debug)]
33-
pub(crate) struct APIVersion {
34-
major: u32,
35-
minor: u32,
36-
}
37-
38-
impl Display for APIVersion {
39-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40-
write!(f, "v{}.{}", self.major, self.minor)
41-
}
42-
}
43-
4432
#[derive(Serialize, Deserialize, Debug)]
4533
pub(crate) struct JsonWrapper<A> {
4634
pub code: u16,

keylime-agent/src/errors_handler.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// SPDX-License-Identifier: Apache-2.0
22
// Copyright 2021 Keylime Authors
33

4-
use crate::{
5-
common::{APIVersion, JsonWrapper},
6-
QuoteData,
7-
};
4+
use crate::{common::JsonWrapper, QuoteData};
85
use actix_web::{
96
body, dev,
107
error::{InternalError, JsonPayloadError, PathError, QueryPayloadError},
118
http,
129
middleware::{ErrorHandlerResponse, ErrorHandlers},
1310
web, Error, HttpRequest, HttpResponse, Responder, Result,
1411
};
12+
use keylime::version::Version;
1513
use log::*;
1614

1715
pub(crate) async fn app_default(
@@ -70,9 +68,9 @@ pub(crate) async fn app_default(
7068

7169
pub(crate) async fn version_not_supported(
7270
req: HttpRequest,
73-
version: web::Path<APIVersion>,
71+
version: web::Path<Version>,
7472
) -> impl Responder {
75-
let message = format!("API version not supported: {version}");
73+
let message = format!("API version not supported: v{version}");
7674

7775
warn!("{} returning 400 response. {}", req.head().method, message);
7876

keylime/src/version.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ where
5252
}
5353
}
5454

55-
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Ord)]
55+
#[derive(
56+
Clone, Debug, Deserialize, Eq, PartialEq, PartialOrd, Ord, Serialize,
57+
)]
5658
pub struct Version {
5759
major: u32,
5860
minor: u32,

0 commit comments

Comments
 (0)