Previewed at Re:invent, the new AWS SDKs for Rust, Kotlin, and Swift provide idiomatic wrappers around AWS APIs that will allow developers to interact with AWS services in a more familiar and consistent way.
According to Amazon, each SDK leverages common best practices for each language and takes advantage of advanced language syntax. For example, the Rust SDK uses recent features such as async/await, non-blocking IO, and builders. Similarly, the Swift SDK uses Swift 5.5 concurrency features and provide multi-platform support. Additionally, the Rust SDK is relies on fast serializers and deserializers to minimize unnecessary copies and allocations and reduce CPU and memory utilization.
Each SDK supports most AWS APIs through distinct packages, one for each service, with the exact number varying slightly with each SDK. All major APIs are included, such as Amazon S3, Amazon EC2, DynamoDB, and hundreds more. Such granularity allows developers to only use the libraries they actually require, thus reducing build size and time.
This is how you can list all DynamoDB tables using Rust and its new AWS SDK:
async fn list_tables(client: &Client) -> Result<(), Error> {
let resp = client.list_tables().send().await?;
println!("Tables:");
let names = resp.table_names().unwrap_or_default();
let len = names.len();
for name in names {
println!(" {}", name);
}
println!("Found {} tables", len);
Ok(())
}
The same task can be carried through in Swift like in the following snippet:
func listAllTables(ddb: DynamoDbClient) {
ddb.listTables(input: ListTablesInput()) { result in
switch(result) {
case .success(let response):
guard let namesOfTables = response.tableNames else {
return
}
for currName in namesOfTables {
print("Table name is \(currName)")
}
case .failure(let err):
print(err)
}
}
}
Previous to AWS official SDK for Rust, Rust developers could already use a native SDK to access AWS services thanks to Rusoto, which has recently entered maintenance mode.
Rust, Kotlin, and Swift are only the latest additions to a long list of supported languages, which includes JavaScript, Python, PHP, .NET (C#), Ruby, Java, Go, Node.js, and C++. All of the new SDKs are still in developer preview, therefore their API could change before reaching general availability based on developers' feedback.