aws_sdk_codestarconnections/operation/list_hosts/
paginator.rs1pub struct ListHostsPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::list_hosts::builders::ListHostsInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl ListHostsPaginator {
10 pub(crate) fn new(handle: std::sync::Arc<crate::client::Handle>, builder: crate::operation::list_hosts::builders::ListHostsInputBuilder) -> 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.max_results = ::std::option::Option::Some(limit);
24 self
25 }
26
27 pub fn stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
35 self.stop_on_duplicate_token = stop_on_duplicate_token;
36 self
37 }
38
39 pub fn send(
44 self,
45 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
46 ::std::result::Result<
47 crate::operation::list_hosts::ListHostsOutput,
48 ::aws_smithy_runtime_api::client::result::SdkError<
49 crate::operation::list_hosts::ListHostsError,
50 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
51 >,
52 >,
53 > {
54 let builder = self.builder;
56 let handle = self.handle;
57 let runtime_plugins = crate::operation::list_hosts::ListHosts::operation_runtime_plugins(
58 handle.runtime_plugins.clone(),
59 &handle.conf,
60 ::std::option::Option::None,
61 )
62 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
63 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
64 move |tx| {
65 ::std::boxed::Box::pin(async move {
66 let mut input = match builder
68 .build()
69 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
70 {
71 ::std::result::Result::Ok(input) => input,
72 ::std::result::Result::Err(e) => {
73 let _ = tx.send(::std::result::Result::Err(e)).await;
74 return;
75 }
76 };
77 loop {
78 let resp = crate::operation::list_hosts::ListHosts::orchestrate(&runtime_plugins, input.clone()).await;
79 let done = match resp {
81 ::std::result::Result::Ok(ref resp) => {
82 let new_token = crate::lens::reflens_list_hosts_output_output_next_token(resp);
83 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
85 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
86 true
87 } else {
88 input.next_token = new_token.cloned();
89 is_empty
90 }
91 }
92 ::std::result::Result::Err(_) => true,
93 };
94 if tx.send(resp).await.is_err() {
95 return;
97 }
98 if done {
99 return;
100 }
101 }
102 })
103 },
104 ))
105 }
106}