intel_dcap_api/lib.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 Matter Labs
3
4//! Intel API Client
5//!
6//! This module provides an API client for interacting with the Intel API for Trusted Services.
7//! The API follows the documentation found at [Intel API Documentation](https://api.portal.trustedservices.intel.com/content/documentation.html).
8//!
9//! Create an [`ApiClient`] to interface with the Intel API.
10//!
11//! # Rate Limiting
12//!
13//! The Intel API implements rate limiting and may return HTTP 429 (Too Many Requests) responses.
14//! This client automatically handles rate limiting by retrying requests up to 3 times by default,
15//! waiting for the duration specified in the `Retry-After` header. You can configure the retry
16//! behavior using [`ApiClient::set_max_retries`]. If all retries are exhausted, the client
17//! returns an [`IntelApiError::TooManyRequests`] error.
18//!
19//! Example
20//! ```rust,no_run
21//! use intel_dcap_api::{ApiClient, IntelApiError, TcbInfoResponse};
22//!
23//! #[tokio::main]
24//! async fn main() -> Result<(), IntelApiError> {
25//! let client = ApiClient::new()?;
26//!
27//! // Example: Get SGX TCB Info
28//! let fmspc_example = "00606A000000"; // Example FMSPC from docs
29//! match client.get_sgx_tcb_info(fmspc_example, None, None).await {
30//! Ok(TcbInfoResponse {
31//! tcb_info_json,
32//! issuer_chain,
33//! }) => println!(
34//! "SGX TCB Info for {}:\n{}\nIssuer Chain: {}",
35//! fmspc_example, tcb_info_json, issuer_chain
36//! ),
37//! Err(e) => eprintln!("Error getting SGX TCB info: {}", e),
38//! }
39//!
40//! Ok(())
41//! }
42//! ```
43
44#![deny(missing_docs)]
45#![deny(clippy::all)]
46
47mod client;
48mod error;
49mod requests;
50mod responses;
51mod types;
52
53// Re-export public items
54pub use client::ApiClient;
55pub use error::IntelApiError;
56pub use responses::{
57 AddPackageResponse, EnclaveIdentityJson, EnclaveIdentityResponse, FmspcJsonResponse,
58 PckCertificateResponse, PckCertificatesResponse, PckCrlResponse, TcbEvaluationDataNumbersJson,
59 TcbEvaluationDataNumbersResponse, TcbInfoJson, TcbInfoResponse,
60};
61pub use types::{ApiVersion, CaType, CrlEncoding, PlatformFilter, UpdateType};