Skip to content

Commit 37740c2

Browse files
committed
fix: apply fmt
1 parent f6fe0bd commit 37740c2

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

cvmassistants/quote-generator/src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use thiserror::Error;
2-
use std::io;
31
use std::array::TryFromSliceError;
2+
use std::io;
3+
use thiserror::Error;
44

55
#[derive(Error, Debug)]
66
pub enum QuoteGeneratorError {
@@ -24,4 +24,4 @@ pub enum QuoteGeneratorError {
2424

2525
#[error("Failed to write quote file: {0}")]
2626
WriteQuoteFile(#[from] io::Error),
27-
}
27+
}

cvmassistants/quote-generator/src/main.rs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ const TDX_UUID_SIZE: usize = 16;
5555
/// # Errors
5656
///
5757
/// Returns `QuoteGeneratorError::ReportDataConversion` if input bytes length doesn't match `REPORT_DATA_SIZE`.
58-
fn create_report_data(input_bytes: &[u8]) -> Result<tdx_attest_rs::tdx_report_data_t, QuoteGeneratorError> {
58+
fn create_report_data(
59+
input_bytes: &[u8],
60+
) -> Result<tdx_attest_rs::tdx_report_data_t, QuoteGeneratorError> {
5961
let report_data = tdx_attest_rs::tdx_report_data_t {
6062
d: input_bytes.try_into()?,
6163
};
@@ -75,7 +77,9 @@ fn create_report_data(input_bytes: &[u8]) -> Result<tdx_attest_rs::tdx_report_da
7577
/// # Errors
7678
///
7779
/// Returns `QuoteGeneratorError::TdxReportFailed` if the report generation fails.
78-
fn create_tdx_report(report_data: &tdx_attest_rs::tdx_report_data_t) -> Result<tdx_attest_rs::tdx_report_t, QuoteGeneratorError> {
80+
fn create_tdx_report(
81+
report_data: &tdx_attest_rs::tdx_report_data_t,
82+
) -> Result<tdx_attest_rs::tdx_report_t, QuoteGeneratorError> {
7983
let mut tdx_report = tdx_attest_rs::tdx_report_t {
8084
d: [0; REPORT_SIZE],
8185
};
@@ -106,7 +110,9 @@ fn create_tdx_report(report_data: &tdx_attest_rs::tdx_report_data_t) -> Result<t
106110
///
107111
/// * `QuoteGeneratorError::TdxQuoteFailed` - if the quote generation API call fails.
108112
/// * `QuoteGeneratorError::TdxQuoteEmpty` - if the API succeeds but returns no quote data.
109-
fn create_quote(report_data: &tdx_attest_rs::tdx_report_data_t) -> Result<Vec<u8>, QuoteGeneratorError> {
113+
fn create_quote(
114+
report_data: &tdx_attest_rs::tdx_report_data_t,
115+
) -> Result<Vec<u8>, QuoteGeneratorError> {
110116
let mut selected_att_key_id = tdx_attest_rs::tdx_uuid_t {
111117
d: [0; TDX_UUID_SIZE],
112118
};
@@ -118,11 +124,9 @@ fn create_quote(report_data: &tdx_attest_rs::tdx_report_data_t) -> Result<Vec<u8
118124
);
119125

120126
match result {
121-
tdx_attest_rs::tdx_attest_error_t::TDX_ATTEST_SUCCESS => {
122-
match quote {
123-
Some(q) => Ok(q),
124-
None => Err(QuoteGeneratorError::TdxQuoteEmpty),
125-
}
127+
tdx_attest_rs::tdx_attest_error_t::TDX_ATTEST_SUCCESS => match quote {
128+
Some(q) => Ok(q),
129+
None => Err(QuoteGeneratorError::TdxQuoteEmpty),
126130
},
127131
_ => {
128132
error!("Failed to get TDX quote: {:?}", result);
@@ -143,7 +147,10 @@ fn main() -> Result<(), QuoteGeneratorError> {
143147
let input = &args[1];
144148
let input_bytes = input.as_bytes();
145149
if input_bytes.len() > REPORT_DATA_SIZE {
146-
return Err(QuoteGeneratorError::ReportDataTooLarge { max: REPORT_DATA_SIZE, actual: input_bytes.len() });
150+
return Err(QuoteGeneratorError::ReportDataTooLarge {
151+
max: REPORT_DATA_SIZE,
152+
actual: input_bytes.len(),
153+
});
147154
}
148155

149156
let mut report_bytes = [0u8; REPORT_DATA_SIZE];

0 commit comments

Comments
 (0)