()
| 8 | |
| 9 | #[tokio::main] |
| 10 | async fn main() -> anyhow::Result<()> { |
| 11 | // Create a DstackClient with default endpoint (/var/run/dstack.sock) |
| 12 | let client = DstackClient::new(None); |
| 13 | |
| 14 | // Or create with a custom endpoint |
| 15 | // let client = DstackClient::new(Some("/custom/path/dstack.sock")); |
| 16 | |
| 17 | // Or create with HTTP endpoint for simulator |
| 18 | // let client = DstackClient::new(Some("http://localhost:8000")); |
| 19 | |
| 20 | println!("DstackClient created successfully!"); |
| 21 | |
| 22 | // Example usage (these will fail without a running dstack service): |
| 23 | |
| 24 | // 1. Get system info |
| 25 | let info = client.info().await?; |
| 26 | println!("System info retrieved successfully!"); |
| 27 | println!(" App ID: {}", info.app_id); |
| 28 | println!(" Instance ID: {}", info.instance_id); |
| 29 | println!(" App Name: {}", info.app_name); |
| 30 | println!(" Device ID: {}", info.device_id); |
| 31 | println!(" Compose Hash: {}", info.compose_hash); |
| 32 | println!(" TCB Info - MRTD: {}", info.tcb_info.mrtd); |
| 33 | println!(" TCB Info - RTMR0: {}", info.tcb_info.rtmr0); |
| 34 | |
| 35 | // 2. Derive a key |
| 36 | let response = client |
| 37 | .get_key(Some("my-app".to_string()), Some("encryption".to_string())) |
| 38 | .await?; |
| 39 | println!("Key derived successfully!"); |
| 40 | println!(" Key length: {}", response.key.len()); |
| 41 | println!( |
| 42 | " Signature chain length: {}", |
| 43 | response.signature_chain.len() |
| 44 | ); |
| 45 | |
| 46 | // Decode the key |
| 47 | let key_bytes = response.decode_key()?; |
| 48 | println!(" Decoded key bytes length: {}", key_bytes.len()); |
| 49 | |
| 50 | // 3. Generate TDX quote |
| 51 | let report_data = b"Hello, dstack world!".to_vec(); |
| 52 | let response = client.get_quote(report_data).await?; |
| 53 | println!("TDX quote generated successfully!"); |
| 54 | println!(" Quote length: {}", response.quote.len()); |
| 55 | println!(" Event log length: {}", response.event_log.len()); |
| 56 | |
| 57 | // Decode the quote |
| 58 | let quote_bytes = response.decode_quote()?; |
| 59 | println!(" Decoded quote bytes length: {}", quote_bytes.len()); |
| 60 | |
| 61 | // Replay RTMRs from event log |
| 62 | let rtmrs = response.replay_rtmrs()?; |
| 63 | println!(" Replayed RTMRs: {} entries", rtmrs.len()); |
| 64 | for (idx, rtmr) in rtmrs.iter() { |
| 65 | println!(" RTMR{}: {}", idx, rtmr); |
| 66 | } |
| 67 |
nothing calls this directly
no test coverage detected