steering_docs/rust-tech.md
# Development
cargo check # Check compilation without building
cargo build # Build project
cargo build --release # Build optimized release version
# Testing
cargo test # Run all tests
cargo test --test integration # Run integration tests
cargo test -- --nocapture # Run tests with output
# Execution
cargo run --bin hello # Run hello scenario
cargo run --bin getting-started # Run getting started scenario
cargo run --bin {scenario-name} # Run specific scenario
CRITICAL: Rust examples follow a specific directory structure pattern. Always examine existing Rust examples (like EC2) before creating new ones.
rustv1/examples/{service}/
├── Cargo.toml
├── README.md
├── src/
│ ├── lib.rs
│ ├── {service}.rs # Service wrapper
│ ├── bin/
│ │ ├── hello.rs # MANDATORY: Hello scenario
│ │ ├── {action-one}.rs # Individual action file
│ │ ├── {action-two}.rs # Individual action file, etc.
│ │ └── {scenario-name}.rs # Other scenario entry points
│ └── {scenario_name}/
│ ├── mod.rs
│ ├── scenario.rs # Main scenario logic
│ └── tests/
│ └── mod.rs # Integration tests
src/bin/hello.rs as the simplest examplesrc/{service}.rs (e.g., src/comprehend.rs){scenario_name}/tests/mod.rs for integration testing{action}.rs in src/bin/ directory{service}.rs in src/ directory{scenario_name}/mod.rs and scenario.rssrc/bin/hello.rsmain() function as entry point with tokio::main attributemod.rs files for module organizationtokio runtime for async operationsuse aws_sdk_s3::{Client, Error};
use aws_config::meta::region::RegionProviderChain;
#[tokio::main]
async fn main() -> Result<(), Error> {
let region_provider = RegionProviderChain::default_provider().or_else("us-east-1");
let config = aws_config::from_env().region(region_provider).load().await;
let client = Client::new(&config);
match client.list_buckets().send().await {
Ok(response) => {
// Handle successful response
println!("Buckets: {:?}", response.buckets());
Ok(())
}
Err(e) => {
// Handle error
eprintln!("Error: {}", e);
Err(e)
}
}
}
{scenario_name}/tests/mod.rs#[cfg(test)] modules in source files#[tokio::test] for async test functions[package]
name = "{service}-examples"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "hello"
path = "src/bin/hello.rs"
[[bin]]
name = "{action-name}"
path = "src/bin/{action-name}.rs"
[dependencies]
aws-config = "1.0"
aws-sdk-{service} = "1.0"
tokio = { version = "1.0", features = ["full"] }
tracing-subscriber = "0.3"
//! for module-level docs/// for function documentationsrc/bin/hello.rs filerustv1/examples/ec2/ structure firstBefore creating Rust code examples:
coding-standards-KB for "Rust-code-example-standards"Rust-premium-KB for "Rust implementation patterns"