pub struct DescribeReservedElasticsearchInstanceOfferingsPaginator {
handle: std::sync::Arc<crate::client::Handle>,
builder:
crate::operation::describe_reserved_elasticsearch_instance_offerings::builders::DescribeReservedElasticsearchInstanceOfferingsInputBuilder,
stop_on_duplicate_token: bool,
}
impl DescribeReservedElasticsearchInstanceOfferingsPaginator {
pub(crate) fn new(
handle: std::sync::Arc<crate::client::Handle>,
builder: crate::operation::describe_reserved_elasticsearch_instance_offerings::builders::DescribeReservedElasticsearchInstanceOfferingsInputBuilder,
) -> Self {
Self {
handle,
builder,
stop_on_duplicate_token: true,
}
}
pub fn page_size(mut self, limit: i32) -> Self {
self.builder.max_results = ::std::option::Option::Some(limit);
self
}
pub fn stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
self.stop_on_duplicate_token = stop_on_duplicate_token;
self
}
pub fn send(
self,
) -> impl ::tokio_stream::Stream<
Item = ::std::result::Result<
crate::operation::describe_reserved_elasticsearch_instance_offerings::DescribeReservedElasticsearchInstanceOfferingsOutput,
::aws_smithy_http::result::SdkError<
crate::operation::describe_reserved_elasticsearch_instance_offerings::DescribeReservedElasticsearchInstanceOfferingsError,
::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
>,
>,
> + ::std::marker::Unpin {
let builder = self.builder;
let handle = self.handle;
let runtime_plugins = crate::operation::describe_reserved_elasticsearch_instance_offerings::DescribeReservedElasticsearchInstanceOfferings::operation_runtime_plugins(
handle.runtime_plugins.clone(),
&handle.conf,
::std::option::Option::None,
);
::aws_smithy_async::future::fn_stream::FnStream::new(move |tx| {
::std::boxed::Box::pin(async move {
let mut input = match builder.build().map_err(::aws_smithy_http::result::SdkError::construction_failure) {
::std::result::Result::Ok(input) => input,
::std::result::Result::Err(e) => {
let _ = tx.send(::std::result::Result::Err(e)).await;
return;
}
};
loop {
let resp = crate::operation::describe_reserved_elasticsearch_instance_offerings::DescribeReservedElasticsearchInstanceOfferings::orchestrate(&runtime_plugins, input.clone()).await;
let done = match resp {
::std::result::Result::Ok(ref resp) => {
let new_token = crate::lens::reflens_describe_reserved_elasticsearch_instance_offerings_output_next_token(resp);
let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
true
} else {
input.next_token = new_token.cloned();
is_empty
}
}
::std::result::Result::Err(_) => true,
};
if tx.send(resp).await.is_err() {
return;
}
if done {
return;
}
}
})
})
}
}