MCPcopy Create free account
hub / github.com/Dstack-TEE/dstack / main

Function main

sdk/rust/examples/tappd_client_usage.rs:8–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6
7#[tokio::main]
8async fn main() -> anyhow::Result<()> {
9 // Create a TappdClient with default endpoint (/var/run/tappd.sock)
10 let client = TappdClient::new(None);
11
12 // Or create with a custom endpoint
13 // let client = TappdClient::new(Some("/custom/path/tappd.sock"));
14
15 // Or create with HTTP endpoint for simulator
16 // let client = TappdClient::new(Some("http://localhost:8080"));
17
18 println!("TappdClient created successfully!");
19
20 // Example usage (these will fail without a running tappd service):
21
22 // 1. Derive a key
23 let response = client.derive_key("my/key/path").await?;
24 println!("Key derived successfully!");
25 println!(
26 "Certificate chain length: {}",
27 response.certificate_chain.len()
28 );
29 let ecdsa_p256_key = response.decode_key().unwrap();
30 println!("ECDSA P-256 key length: {}", ecdsa_p256_key.len());
31
32 // 2. Get a quote with 64 bytes of report data
33 let mut report_data = b"Hello, world!".to_vec();
34 // Pad to exactly 64 bytes for get_quote
35 report_data.resize(64, 0);
36 let response = client.get_quote(report_data).await?;
37 println!("Quote generated successfully!");
38 println!("Quote length: {}", response.quote.len());
39
40 // 3. Get instance info
41 let response = client.info().await?;
42 println!("Instance info retrieved successfully!");
43 println!("App ID: {}", response.app_id);
44 println!("Instance ID: {}", response.instance_id);
45 println!("App Name: {}", response.app_name);
46
47 Ok(())
48}

Callers

nothing calls this directly

Calls 5

to_vecMethod · 0.80
derive_keyMethod · 0.45
decode_keyMethod · 0.45
get_quoteMethod · 0.45
infoMethod · 0.45

Tested by

no test coverage detected