Skip to content

Commit

Permalink
[examples] Sync SDK examples from awsdocs/aws-doc-sdk-examples
Browse files Browse the repository at this point in the history
Includes commit(s):
  693bda563da5a91bb58c7391c298cc01afdfc252
  66ef9428ed23b612ef38c669bd52cfa12ce9bb0f

Co-authored-by: Jason Quesenberry <[email protected]>
  • Loading branch information
aws-sdk-rust-ci and beqqrry-aws committed Aug 8, 2022
1 parent f4a3d2f commit e9d4557
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
4 changes: 4 additions & 0 deletions examples/qldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ version = "0.17.0"
version = "1"
features = ["full"]

[dependencies.tokio-stream]
version = "0.1.9"
features = ["default"]

[dependencies.structopt]
version = "0.3"
default-features = false
Expand Down
20 changes: 9 additions & 11 deletions examples/qldb/src/bin/list-ledgers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
*/

use aws_config::meta::region::RegionProviderChain;
use aws_sdk_qldb::{Client, Error, Region, PKG_VERSION};
use aws_sdk_qldb::{Client as QLDBClient, Error, Region, PKG_VERSION};
use structopt::StructOpt;
use tokio_stream::StreamExt;

#[derive(Debug, StructOpt)]
struct Opt {
Expand All @@ -20,16 +21,13 @@ struct Opt {

// List ledgers.
// snippet-start:[qldb.rust.list-ledgers]
async fn show_ledgers(client: &Client) -> Result<(), Error> {
let result = client.list_ledgers().send().await?;
async fn show_ledgers(client: &QLDBClient) -> Result<(), Error> {
let mut pages = client.list_ledgers().into_paginator().page_size(2).send();

if let Some(ledgers) = result.ledgers() {
for ledger in ledgers {
println!("* {:?}", ledger);
}

if result.next_token().is_some() {
todo!("pagination is not yet demonstrated")
while let Some(page) = pages.next().await {
println!("* {:?}", page); //Prints an entire page of ledgers.
for ledger in page.unwrap().ledgers().unwrap() {
println!("* {:?}", ledger); //Prints the LedgerSummary of a single ledger.
}
}

Expand Down Expand Up @@ -66,7 +64,7 @@ async fn main() -> Result<(), Error> {
}

let shared_config = aws_config::from_env().region(region_provider).load().await;
let client = Client::new(&shared_config);
let client = QLDBClient::new(&shared_config);

show_ledgers(&client).await
}
4 changes: 2 additions & 2 deletions versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
smithy_rs_revision = '65e53ab87a9bf6fdc45f85e29fddaaaf7b482a1b'
aws_doc_sdk_examples_revision = '00b3c7344ae0ff27dd0e515e5c36e4331c5cefa9'
smithy_rs_revision = 'db48039065bec890ef387385773b37154b555b14'
aws_doc_sdk_examples_revision = '66ef9428ed23b612ef38c669bd52cfa12ce9bb0f'

[manual_interventions]
crates_to_remove = []
Expand Down

0 comments on commit e9d4557

Please sign in to comment.