

文档 AWS SDK 示例 GitHub 存储库中还有更多 [S AWS DK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)。

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用 Amazon Cognito 同步的代码示例 AWS SDKs
<a name="cognito-sync_code_examples"></a>

以下代码示例向您展示了如何将 Amazon Cognito Sync 与 AWS 软件开发套件 (SDK) 一起使用。

*操作*是大型程序的代码摘录，必须在上下文中运行。您可以通过操作了解如何调用单个服务函数，还可以通过函数相关场景的上下文查看操作。

**更多资源**
+  **[Amazon Cognito Sync 开发人员指南](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-sync.html)**——有关 Amazon Cognito Sync 的更多信息。
+ **[Amazon Cognito Sync API 参考](https://docs.aws.amazon.com/cognitosync/latest/APIReference/Welcome.html)**——有关所有可用的 Amazon Cognito Sync 操作的详细信息。
+ **[AWS 开发者中心](https://aws.amazon.com/developer/code-examples/?awsf.sdk-code-examples-product=product%23cognito)** — 您可以按类别或全文搜索筛选的代码示例。
+ **[AWS SDK 示例](https://github.com/awsdocs/aws-doc-sdk-examples)** — 包含首选语言完整代码的 GitHub 存储库。包括有关设置和运行代码的说明。

**Contents**
+ [基本功能](cognito-sync_code_examples_basics.md)
  + [操作](cognito-sync_code_examples_actions.md)
    + [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# 使用 Amazon Cognito 同步的基本示例 AWS SDKs
<a name="cognito-sync_code_examples_basics"></a>

以下代码示例展示了如何使用 Amazon Cognito Sync 的基础知识。 AWS SDKs

**Contents**
+ [操作](cognito-sync_code_examples_actions.md)
  + [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# 使用 Amazon Cognito 同步的操作 AWS SDKs
<a name="cognito-sync_code_examples_actions"></a>

以下代码示例演示了如何使用执行各个 Amazon Cognito 同步操作。 AWS SDKs每个示例都包含一个指向的链接 GitHub，您可以在其中找到有关设置和运行代码的说明。

 以下示例仅包括最常用的操作。有关完整列表，请参阅 [Amazon Cognito 同步 API 参考](https://docs.aws.amazon.com/cognitosync/latest/APIReference/Welcome.html)。

**Topics**
+ [`ListIdentityPoolUsage`](cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section.md)

# 与 AWS SDK `ListIdentityPoolUsage` 配合使用
<a name="cognito-sync_example_cognito-sync_ListIdentityPoolUsage_section"></a>

以下代码示例演示了如何使用 `ListIdentityPoolUsage`。

------
#### [ Rust ]

**适用于 Rust 的 SDK**  
 还有更多相关信息 GitHub。在 [AWS 代码示例存储库](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/rustv1/examples/cognitosync#code-examples)中查找完整示例，了解如何进行设置和运行。

```
async fn show_pools(client: &Client) -> Result<(), Error> {
    let response = client
        .list_identity_pool_usage()
        .max_results(10)
        .send()
        .await?;

    let pools = response.identity_pool_usages();
    println!("Identity pools:");

    for pool in pools {
        println!(
            "  Identity pool ID:    {}",
            pool.identity_pool_id().unwrap_or_default()
        );
        println!(
            "  Data storage:        {}",
            pool.data_storage().unwrap_or_default()
        );
        println!(
            "  Sync sessions count: {}",
            pool.sync_sessions_count().unwrap_or_default()
        );
        println!(
            "  Last modified:       {}",
            pool.last_modified_date().unwrap().to_chrono_utc()?
        );
        println!();
    }

    println!("Next token: {}", response.next_token().unwrap_or_default());

    Ok(())
}
```
+  有关 API 的详细信息，请参阅适用[ListIdentityPoolUsage](https://docs.rs/aws-sdk-cognitosync/latest/aws_sdk_cognitosync/client/struct.Client.html#method.list_identity_pool_usage)于 *Rust 的AWS SDK API 参考*。

------