aws_sdk_honeycode/operation/list_table_rows/
paginator.rs1pub struct ListTableRowsPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::list_table_rows::builders::ListTableRowsInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl ListTableRowsPaginator {
10 pub(crate) fn new(
12 handle: std::sync::Arc<crate::client::Handle>,
13 builder: crate::operation::list_table_rows::builders::ListTableRowsInputBuilder,
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.max_results = ::std::option::Option::Some(limit);
27 self
28 }
29
30 pub fn items(self) -> crate::operation::list_table_rows::paginator::ListTableRowsPaginatorItems {
35 crate::operation::list_table_rows::paginator::ListTableRowsPaginatorItems(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::list_table_rows::ListTableRowsOutput,
59 ::aws_smithy_runtime_api::client::result::SdkError<
60 crate::operation::list_table_rows::ListTableRowsError,
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::list_table_rows::ListTableRows::operation_runtime_plugins(
69 handle.runtime_plugins.clone(),
70 &handle.conf,
71 ::std::option::Option::None,
72 );
73 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
74 move |tx| {
75 ::std::boxed::Box::pin(async move {
76 let mut input = match builder
78 .build()
79 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
80 {
81 ::std::result::Result::Ok(input) => input,
82 ::std::result::Result::Err(e) => {
83 let _ = tx.send(::std::result::Result::Err(e)).await;
84 return;
85 }
86 };
87 loop {
88 let resp = crate::operation::list_table_rows::ListTableRows::orchestrate(&runtime_plugins, input.clone()).await;
89 let done = match resp {
91 ::std::result::Result::Ok(ref resp) => {
92 let new_token = crate::lens::reflens_list_table_rows_output_output_next_token(resp);
93 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
94 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
95 true
96 } else {
97 input.next_token = new_token.cloned();
98 is_empty
99 }
100 }
101 ::std::result::Result::Err(_) => true,
102 };
103 if tx.send(resp).await.is_err() {
104 return;
106 }
107 if done {
108 return;
109 }
110 }
111 })
112 },
113 ))
114 }
115}
116
117pub struct ListTableRowsPaginatorItems(ListTableRowsPaginator);
121
122impl ListTableRowsPaginatorItems {
123 pub fn send(
130 self,
131 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
132 ::std::result::Result<
133 crate::types::TableRow,
134 ::aws_smithy_runtime_api::client::result::SdkError<
135 crate::operation::list_table_rows::ListTableRowsError,
136 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
137 >,
138 >,
139 > {
140 ::aws_smithy_async::future::pagination_stream::TryFlatMap::new(self.0.send())
141 .flat_map(|page| crate::lens::lens_list_table_rows_output_output_rows(page).unwrap_or_default().into_iter())
142 }
143}