MCPcopy Create free account
hub / github.com/bytecodealliance/wstd / main

Function main

aws-example/src/bin/s3.rs:73–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71
72#[wstd::main]
73async fn main() -> Result<()> {
74 let opts = Opts::parse();
75 let region = opts.region;
76 let bucket = opts.bucket;
77
78 let config = aws_config::defaults(BehaviorVersion::latest())
79 .region(Region::new(region))
80 .sleep_impl(aws_smithy_wasm::wasi::WasiSleep)
81 .http_client(aws_smithy_wasm::wasi::WasiHttpClientBuilder::new().build())
82 .load()
83 .await;
84
85 let client = Client::new(&config);
86
87 match opts.command.as_ref().unwrap_or(&Command::List) {
88 Command::List => {
89 let output = list(&bucket, &client).await?;
90 print!("{}", output);
91 }
92 Command::Get { key, out } => {
93 let contents = get(&bucket, &client, key).await?;
94 let output: &str = if let Some(out) = out {
95 out.as_str()
96 } else {
97 key.as_str()
98 };
99 std::fs::write(output, contents)?;
100 }
101 }
102 Ok(())
103}
104
105async fn list(bucket: &str, client: &Client) -> Result<String> {
106 let mut listing = client

Callers

nothing calls this directly

Calls 2

listFunction · 0.85
getFunction · 0.85

Tested by

no test coverage detected