aws_sdk_kms/operation/list_keys/
paginator.rs1pub struct ListKeysPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::list_keys::builders::ListKeysInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl ListKeysPaginator {
10 pub(crate) fn new(handle: std::sync::Arc<crate::client::Handle>, builder: crate::operation::list_keys::builders::ListKeysInputBuilder) -> Self {
12 Self {
13 handle,
14 builder,
15 stop_on_duplicate_token: true,
16 }
17 }
18
19 pub fn page_size(mut self, limit: i32) -> Self {
23 self.builder.limit = ::std::option::Option::Some(limit);
24 self
25 }
26
27 pub fn items(self) -> crate::operation::list_keys::paginator::ListKeysPaginatorItems {
32 crate::operation::list_keys::paginator::ListKeysPaginatorItems(self)
33 }
34
35 pub fn stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
43 self.stop_on_duplicate_token = stop_on_duplicate_token;
44 self
45 }
46
47 pub fn send(
52 self,
53 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
54 ::std::result::Result<
55 crate::operation::list_keys::ListKeysOutput,
56 ::aws_smithy_runtime_api::client::result::SdkError<
57 crate::operation::list_keys::ListKeysError,
58 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
59 >,
60 >,
61 > {
62 let builder = self.builder;
64 let handle = self.handle;
65 let runtime_plugins = crate::operation::list_keys::ListKeys::operation_runtime_plugins(
66 handle.runtime_plugins.clone(),
67 &handle.conf,
68 ::std::option::Option::None,
69 )
70 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
71 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
72 move |tx| {
73 ::std::boxed::Box::pin(async move {
74 let mut input = match builder
76 .build()
77 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
78 {
79 ::std::result::Result::Ok(input) => input,
80 ::std::result::Result::Err(e) => {
81 let _ = tx.send(::std::result::Result::Err(e)).await;
82 return;
83 }
84 };
85 loop {
86 let resp = crate::operation::list_keys::ListKeys::orchestrate(&runtime_plugins, input.clone()).await;
87 let done = match resp {
89 ::std::result::Result::Ok(ref resp) => {
90 let new_token = crate::lens::reflens_list_keys_output_output_next_marker(resp);
91 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
93 if !is_empty && new_token == input.marker.as_ref() && self.stop_on_duplicate_token {
94 true
95 } else {
96 input.marker = new_token.cloned();
97 is_empty
98 }
99 }
100 ::std::result::Result::Err(_) => true,
101 };
102 if tx.send(resp).await.is_err() {
103 return;
105 }
106 if done {
107 return;
108 }
109 }
110 })
111 },
112 ))
113 }
114}
115
116pub struct ListKeysPaginatorItems(ListKeysPaginator);
120
121impl ListKeysPaginatorItems {
122 pub fn send(
129 self,
130 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
131 ::std::result::Result<
132 crate::types::KeyListEntry,
133 ::aws_smithy_runtime_api::client::result::SdkError<
134 crate::operation::list_keys::ListKeysError,
135 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
136 >,
137 >,
138 > {
139 ::aws_smithy_async::future::pagination_stream::TryFlatMap::new(self.0.send())
140 .flat_map(|page| crate::lens::lens_list_keys_output_output_keys(page).unwrap_or_default().into_iter())
141 }
142}