mirror of
https://github.com/matter-labs/teepot.git
synced 2025-07-21 07:03:56 +02:00
refactor: improve type ergonomics
This commit is contained in:
parent
0768b0ad67
commit
2ff169da9f
11 changed files with 22 additions and 25 deletions
|
@ -193,7 +193,7 @@ impl ApiClient {
|
|||
}
|
||||
|
||||
/// Checks if a V4-only parameter is provided with a V3 API version.
|
||||
pub(super) fn check_v4_only_param<T>(
|
||||
pub(super) fn check_v4_only_param<T: Copy>(
|
||||
&self,
|
||||
param_value: Option<T>,
|
||||
param_name: &str,
|
||||
|
|
|
@ -24,7 +24,7 @@ fn extract_header_value(
|
|||
.ok_or_else(|| QuoteError::Unexpected(format!("Missing required header: {header_name}")))?
|
||||
.to_str()
|
||||
.map_err(|e| QuoteError::Unexpected(format!("Invalid header value: {e}")))
|
||||
.map(|val| val.to_string())
|
||||
.map(str::to_string)
|
||||
}
|
||||
|
||||
/// Fetch collateral data from Intel's Provisioning Certification Service
|
||||
|
@ -74,14 +74,14 @@ pub(crate) fn get_collateral(quote: &[u8]) -> Result<Collateral, QuoteError> {
|
|||
let (collateral, pck_crl, pck_issuer_chain) = result;
|
||||
|
||||
// Convert QuoteCollateralV3 to Collateral
|
||||
convert_to_collateral(collateral, pck_crl, pck_issuer_chain)
|
||||
convert_to_collateral(collateral, &pck_crl, &pck_issuer_chain)
|
||||
}
|
||||
|
||||
// Helper function to convert QuoteCollateralV3 to Collateral
|
||||
fn convert_to_collateral(
|
||||
collateral: QuoteCollateralV3,
|
||||
pck_crl: String,
|
||||
pck_issuer_chain: Bytes,
|
||||
pck_crl: &str,
|
||||
pck_issuer_chain: &[u8],
|
||||
) -> Result<Collateral, QuoteError> {
|
||||
let QuoteCollateralV3 {
|
||||
tcb_info_issuer_chain,
|
||||
|
@ -119,7 +119,7 @@ fn convert_to_collateral(
|
|||
root_ca_crl: Box::new([]),
|
||||
|
||||
// Converted values
|
||||
pck_crl_issuer_chain: pck_issuer_chain.as_ref().into(),
|
||||
pck_crl_issuer_chain: pck_issuer_chain.into(),
|
||||
pck_crl: pck_crl.as_bytes().into(),
|
||||
tcb_info_issuer_chain: to_bytes_with_nul(tcb_info_issuer_chain, "tcb_info_issuer_chain")?,
|
||||
tcb_info: to_bytes_with_nul(tcb_info_json, "tcb_info")?,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue