Amazon ECR examples using SDK for Rust - AWS SDK for Rust

Amazon ECR examples using SDK for Rust

The following code examples show you how to perform actions and implement common scenarios by using the AWS SDK for Rust with Amazon ECR.

Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.

Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.

Topics

Actions

The following code example shows how to use DescribeRepositories.

SDK for Rust
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

async fn show_repos(client: &aws_sdk_ecr::Client) -> Result<(), aws_sdk_ecr::Error> { let rsp = client.describe_repositories().send().await?; let repos = rsp.repositories(); println!("Found {} repositories:", repos.len()); for repo in repos { println!(" ARN: {}", repo.repository_arn().unwrap()); println!(" Name: {}", repo.repository_name().unwrap()); } Ok(()) }

The following code example shows how to use ListImages.

SDK for Rust
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

async fn show_images( client: &aws_sdk_ecr::Client, repository: &str, ) -> Result<(), aws_sdk_ecr::Error> { let rsp = client .list_images() .repository_name(repository) .send() .await?; let images = rsp.image_ids(); println!("found {} images", images.len()); for image in images { println!( "image: {}:{}", image.image_tag().unwrap(), image.image_digest().unwrap() ); } Ok(()) }
  • For API details, see ListImages in AWS SDK for Rust API reference.