aws_sdk_mobile/operation/list_projects/
paginator.rs1pub struct ListProjectsPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::list_projects::builders::ListProjectsInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl ListProjectsPaginator {
10 pub(crate) fn new(
12 handle: std::sync::Arc<crate::client::Handle>,
13 builder: crate::operation::list_projects::builders::ListProjectsInputBuilder,
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 stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
38 self.stop_on_duplicate_token = stop_on_duplicate_token;
39 self
40 }
41
42 pub fn send(
47 self,
48 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
49 ::std::result::Result<
50 crate::operation::list_projects::ListProjectsOutput,
51 ::aws_smithy_runtime_api::client::result::SdkError<
52 crate::operation::list_projects::ListProjectsError,
53 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
54 >,
55 >,
56 > {
57 let builder = self.builder;
59 let handle = self.handle;
60 let runtime_plugins = crate::operation::list_projects::ListProjects::operation_runtime_plugins(
61 handle.runtime_plugins.clone(),
62 &handle.conf,
63 ::std::option::Option::None,
64 );
65 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
66 move |tx| {
67 ::std::boxed::Box::pin(async move {
68 let mut input = match builder
70 .build()
71 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
72 {
73 ::std::result::Result::Ok(input) => input,
74 ::std::result::Result::Err(e) => {
75 let _ = tx.send(::std::result::Result::Err(e)).await;
76 return;
77 }
78 };
79 loop {
80 let resp = crate::operation::list_projects::ListProjects::orchestrate(&runtime_plugins, input.clone()).await;
81 let done = match resp {
83 ::std::result::Result::Ok(ref resp) => {
84 let new_token = crate::lens::reflens_list_projects_output_output_next_token(resp);
85 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
87 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
88 true
89 } else {
90 input.next_token = new_token.cloned();
91 is_empty
92 }
93 }
94 ::std::result::Result::Err(_) => true,
95 };
96 if tx.send(resp).await.is_err() {
97 return;
99 }
100 if done {
101 return;
102 }
103 }
104 })
105 },
106 ))
107 }
108}