aws_sdk_lexmodelbuilding/operation/get_bots/
paginator.rs1pub struct GetBotsPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::get_bots::builders::GetBotsInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl GetBotsPaginator {
10 pub(crate) fn new(handle: std::sync::Arc<crate::client::Handle>, builder: crate::operation::get_bots::builders::GetBotsInputBuilder) -> 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::get_bots::GetBotsOutput,
48 ::aws_smithy_runtime_api::client::result::SdkError<
49 crate::operation::get_bots::GetBotsError,
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 =
58 crate::operation::get_bots::GetBots::operation_runtime_plugins(handle.runtime_plugins.clone(), &handle.conf, ::std::option::Option::None)
59 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
60 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
61 move |tx| {
62 ::std::boxed::Box::pin(async move {
63 let mut input = match builder
65 .build()
66 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
67 {
68 ::std::result::Result::Ok(input) => input,
69 ::std::result::Result::Err(e) => {
70 let _ = tx.send(::std::result::Result::Err(e)).await;
71 return;
72 }
73 };
74 loop {
75 let resp = crate::operation::get_bots::GetBots::orchestrate(&runtime_plugins, input.clone()).await;
76 let done = match resp {
78 ::std::result::Result::Ok(ref resp) => {
79 let new_token = crate::lens::reflens_get_bots_output_output_next_token(resp);
80 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
82 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
83 true
84 } else {
85 input.next_token = new_token.cloned();
86 is_empty
87 }
88 }
89 ::std::result::Result::Err(_) => true,
90 };
91 if tx.send(resp).await.is_err() {
92 return;
94 }
95 if done {
96 return;
97 }
98 }
99 })
100 },
101 ))
102 }
103}