aws_sdk_codedeploy/operation/list_deployment_instances/
paginator.rs1pub struct ListDeploymentInstancesPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::list_deployment_instances::builders::ListDeploymentInstancesInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl ListDeploymentInstancesPaginator {
10 pub(crate) fn new(
12 handle: std::sync::Arc<crate::client::Handle>,
13 builder: crate::operation::list_deployment_instances::builders::ListDeploymentInstancesInputBuilder,
14 ) -> Self {
15 Self {
16 handle,
17 builder,
18 stop_on_duplicate_token: true,
19 }
20 }
21
22 pub fn items(self) -> crate::operation::list_deployment_instances::paginator::ListDeploymentInstancesPaginatorItems {
27 crate::operation::list_deployment_instances::paginator::ListDeploymentInstancesPaginatorItems(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_deployment_instances::ListDeploymentInstancesOutput,
51 ::aws_smithy_runtime_api::client::result::SdkError<
52 crate::operation::list_deployment_instances::ListDeploymentInstancesError,
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_deployment_instances::ListDeploymentInstances::operation_runtime_plugins(
61 handle.runtime_plugins.clone(),
62 &handle.conf,
63 ::std::option::Option::None,
64 )
65 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
66 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
67 move |tx| {
68 ::std::boxed::Box::pin(async move {
69 let mut input = match builder
71 .build()
72 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
73 {
74 ::std::result::Result::Ok(input) => input,
75 ::std::result::Result::Err(e) => {
76 let _ = tx.send(::std::result::Result::Err(e)).await;
77 return;
78 }
79 };
80 loop {
81 let resp =
82 crate::operation::list_deployment_instances::ListDeploymentInstances::orchestrate(&runtime_plugins, input.clone()).await;
83 let done = match resp {
85 ::std::result::Result::Ok(ref resp) => {
86 let new_token = crate::lens::reflens_list_deployment_instances_output_output_next_token(resp);
87 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
89 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
90 true
91 } else {
92 input.next_token = new_token.cloned();
93 is_empty
94 }
95 }
96 ::std::result::Result::Err(_) => true,
97 };
98 if tx.send(resp).await.is_err() {
99 return;
101 }
102 if done {
103 return;
104 }
105 }
106 })
107 },
108 ))
109 }
110}
111
112pub struct ListDeploymentInstancesPaginatorItems(ListDeploymentInstancesPaginator);
116
117impl ListDeploymentInstancesPaginatorItems {
118 pub fn send(
125 self,
126 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
127 ::std::result::Result<
128 ::std::string::String,
129 ::aws_smithy_runtime_api::client::result::SdkError<
130 crate::operation::list_deployment_instances::ListDeploymentInstancesError,
131 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
132 >,
133 >,
134 > {
135 ::aws_smithy_async::future::pagination_stream::TryFlatMap::new(self.0.send()).flat_map(|page| {
136 crate::lens::lens_list_deployment_instances_output_output_instances_list(page)
137 .unwrap_or_default()
138 .into_iter()
139 })
140 }
141}