dstack Crate
This crate provides rust clients for communicating with both the current dstack server and the legacy tappd service, which are available inside dstack.
Installation
[]
= { = "https://github.com/Dstack-TEE/dstack.git" }
Basic Usage
DstackClient (Current API)
use DstackClient;
async
TappdClient (Legacy API)
use TappdClient;
async
Features
DstackClient Initialization
let client = new;
endpoint: Optional HTTP URL or Unix socket path (/var/run/dstack.sockby default)- Will use the
DSTACK_SIMULATOR_ENDPOINTenvironment variable if set
TappdClient Initialization (Legacy API)
let client = new;
endpoint: Optional HTTP URL or Unix socket path (/var/run/tappd.sockby default)- Will use the
TAPPD_SIMULATOR_ENDPOINTenvironment variable if set - Supports the legacy tappd.sock API for backwards compatibility
API Methods
DstackClient Methods
info(): InfoResponse
Fetches metadata and measurements about the CVM instance.
get_key(path: Option<String>, purpose: Option<String>) -> GetKeyResponse
Derives a key for a specified path and optional purpose.
key: Private key in hex formatsignature_chain: Vec of X.509 certificate chain entries
get_quote(report_data: Vec<u8>) -> GetQuoteResponse
Generates a TDX quote with a custom 64-byte payload.
quote: Hex-encoded quoteevent_log: Serialized list of eventsreplay_rtmrs(): Reconstructs RTMR values from the event log
emit_event(event: String, payload: Vec<u8>)
Sends an event log with associated binary payload to the runtime.
get_tls_key(...) -> GetTlsKeyResponse
Requests a key and X.509 certificate chain for RA-TLS or server/client authentication.
TappdClient Methods (Legacy API)
info(): TappdInfoResponse
Fetches metadata and measurements about the CVM instance.
derive_key(path: &str) -> DeriveKeyResponse
Derives a key for a specified path.
key: ECDSA P-256 private key in PEM formatcertificate_chain: Vec of X.509 certificate chain entriesto_bytes(): Extracts and returns the raw ECDSA P-256 private key bytes (32 bytes)
derive_key_with_subject(path: &str, subject: &str) -> DeriveKeyResponse
Derives a key with a custom certificate subject.
derive_key_with_subject_and_alt_names(path: &str, subject: Option<&str>, alt_names: Option<Vec<String>>) -> DeriveKeyResponse
Derives a key with full certificate customization.
get_quote(report_data: Vec<u8>) -> TdxQuoteResponse
Generates a TDX quote with exactly 64 bytes of raw report data.
Structures
-
GetKeyResponse: Holds derived key and signature chain -
GetQuoteResponse: Contains the TDX quote and event log, with RTMR replay support -
InfoResponse: CVM instance metadata, including image and runtime measurements
API Reference
Running the Simulator
For local development without TDX devices, you can use the simulator under sdk/simulator.
Run the simulator with:
Set the endpoint in your environment:
export DSTACK_SIMULATOR_ENDPOINT=/path/to/dstack-simulator/dstack.sock
Examples
See the examples/ directory for comprehensive usage examples:
examples/dstack_client_usage.rs- Complete example using the current DstackClient APIexamples/tappd_client_usage.rs- Complete example using the legacy TappdClient API
Run examples with:
License
Apache License