aws_sdk_kms/operation/describe_custom_key_stores/
paginator.rs1pub struct DescribeCustomKeyStoresPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::describe_custom_key_stores::builders::DescribeCustomKeyStoresInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl DescribeCustomKeyStoresPaginator {
10 pub(crate) fn new(
12 handle: std::sync::Arc<crate::client::Handle>,
13 builder: crate::operation::describe_custom_key_stores::builders::DescribeCustomKeyStoresInputBuilder,
14 ) -> Self {
15 Self {
16 handle,
17 builder,
18 stop_on_duplicate_token: true,
19 }
20 }
21
22 pub fn page_size(mut self, limit: i32) -> Self {
26 self.builder.limit = ::std::option::Option::Some(limit);
27 self
28 }
29
30 pub fn items(self) -> crate::operation::describe_custom_key_stores::paginator::DescribeCustomKeyStoresPaginatorItems {
35 crate::operation::describe_custom_key_stores::paginator::DescribeCustomKeyStoresPaginatorItems(self)
36 }
37
38 pub fn stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
46 self.stop_on_duplicate_token = stop_on_duplicate_token;
47 self
48 }
49
50 pub fn send(
55 self,
56 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
57 ::std::result::Result<
58 crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresOutput,
59 ::aws_smithy_runtime_api::client::result::SdkError<
60 crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError,
61 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
62 >,
63 >,
64 > {
65 let builder = self.builder;
67 let handle = self.handle;
68 let runtime_plugins = crate::operation::describe_custom_key_stores::DescribeCustomKeyStores::operation_runtime_plugins(
69 handle.runtime_plugins.clone(),
70 &handle.conf,
71 ::std::option::Option::None,
72 )
73 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
74 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
75 move |tx| {
76 ::std::boxed::Box::pin(async move {
77 let mut input = match builder
79 .build()
80 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
81 {
82 ::std::result::Result::Ok(input) => input,
83 ::std::result::Result::Err(e) => {
84 let _ = tx.send(::std::result::Result::Err(e)).await;
85 return;
86 }
87 };
88 loop {
89 let resp =
90 crate::operation::describe_custom_key_stores::DescribeCustomKeyStores::orchestrate(&runtime_plugins, input.clone()).await;
91 let done = match resp {
93 ::std::result::Result::Ok(ref resp) => {
94 let new_token = crate::lens::reflens_describe_custom_key_stores_output_output_next_marker(resp);
95 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
97 if !is_empty && new_token == input.marker.as_ref() && self.stop_on_duplicate_token {
98 true
99 } else {
100 input.marker = new_token.cloned();
101 is_empty
102 }
103 }
104 ::std::result::Result::Err(_) => true,
105 };
106 if tx.send(resp).await.is_err() {
107 return;
109 }
110 if done {
111 return;
112 }
113 }
114 })
115 },
116 ))
117 }
118}
119
120pub struct DescribeCustomKeyStoresPaginatorItems(DescribeCustomKeyStoresPaginator);
124
125impl DescribeCustomKeyStoresPaginatorItems {
126 pub fn send(
133 self,
134 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
135 ::std::result::Result<
136 crate::types::CustomKeyStoresListEntry,
137 ::aws_smithy_runtime_api::client::result::SdkError<
138 crate::operation::describe_custom_key_stores::DescribeCustomKeyStoresError,
139 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
140 >,
141 >,
142 > {
143 ::aws_smithy_async::future::pagination_stream::TryFlatMap::new(self.0.send()).flat_map(|page| {
144 crate::lens::lens_describe_custom_key_stores_output_output_custom_key_stores(page)
145 .unwrap_or_default()
146 .into_iter()
147 })
148 }
149}