aws_sdk_ec2/operation/describe_network_interface_permissions/
paginator.rs1pub struct DescribeNetworkInterfacePermissionsPaginator {
4 handle: std::sync::Arc<crate::client::Handle>,
5 builder: crate::operation::describe_network_interface_permissions::builders::DescribeNetworkInterfacePermissionsInputBuilder,
6 stop_on_duplicate_token: bool,
7}
8
9impl DescribeNetworkInterfacePermissionsPaginator {
10 pub(crate) fn new(
12 handle: std::sync::Arc<crate::client::Handle>,
13 builder: crate::operation::describe_network_interface_permissions::builders::DescribeNetworkInterfacePermissionsInputBuilder,
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 items(self) -> crate::operation::describe_network_interface_permissions::paginator::DescribeNetworkInterfacePermissionsPaginatorItems {
35 crate::operation::describe_network_interface_permissions::paginator::DescribeNetworkInterfacePermissionsPaginatorItems(self)
36 }
37
38 pub fn stop_on_duplicate_token(mut self, stop_on_duplicate_token: bool) -> Self {
46 self.stop_on_duplicate_token = stop_on_duplicate_token;
47 self
48 }
49
50 pub fn send(
55 self,
56 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
57 ::std::result::Result<
58 crate::operation::describe_network_interface_permissions::DescribeNetworkInterfacePermissionsOutput,
59 ::aws_smithy_runtime_api::client::result::SdkError<
60 crate::operation::describe_network_interface_permissions::DescribeNetworkInterfacePermissionsError,
61 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
62 >,
63 >,
64 > {
65 let builder = self.builder;
67 let handle = self.handle;
68 let runtime_plugins =
69 crate::operation::describe_network_interface_permissions::DescribeNetworkInterfacePermissions::operation_runtime_plugins(
70 handle.runtime_plugins.clone(),
71 &handle.conf,
72 ::std::option::Option::None,
73 )
74 .with_operation_plugin(crate::sdk_feature_tracker::paginator::PaginatorFeatureTrackerRuntimePlugin::new());
75 ::aws_smithy_async::future::pagination_stream::PaginationStream::new(::aws_smithy_async::future::pagination_stream::fn_stream::FnStream::new(
76 move |tx| {
77 ::std::boxed::Box::pin(async move {
78 let mut input = match builder
80 .build()
81 .map_err(::aws_smithy_runtime_api::client::result::SdkError::construction_failure)
82 {
83 ::std::result::Result::Ok(input) => input,
84 ::std::result::Result::Err(e) => {
85 let _ = tx.send(::std::result::Result::Err(e)).await;
86 return;
87 }
88 };
89 loop {
90 let resp = crate::operation::describe_network_interface_permissions::DescribeNetworkInterfacePermissions::orchestrate(
91 &runtime_plugins,
92 input.clone(),
93 )
94 .await;
95 let done = match resp {
97 ::std::result::Result::Ok(ref resp) => {
98 let new_token = crate::lens::reflens_describe_network_interface_permissions_output_output_next_token(resp);
99 let is_empty = new_token.map(|token| token.is_empty()).unwrap_or(true);
101 if !is_empty && new_token == input.next_token.as_ref() && self.stop_on_duplicate_token {
102 true
103 } else {
104 input.next_token = new_token.cloned();
105 is_empty
106 }
107 }
108 ::std::result::Result::Err(_) => true,
109 };
110 if tx.send(resp).await.is_err() {
111 return;
113 }
114 if done {
115 return;
116 }
117 }
118 })
119 },
120 ))
121 }
122}
123
124pub struct DescribeNetworkInterfacePermissionsPaginatorItems(DescribeNetworkInterfacePermissionsPaginator);
128
129impl DescribeNetworkInterfacePermissionsPaginatorItems {
130 pub fn send(
137 self,
138 ) -> ::aws_smithy_async::future::pagination_stream::PaginationStream<
139 ::std::result::Result<
140 crate::types::NetworkInterfacePermission,
141 ::aws_smithy_runtime_api::client::result::SdkError<
142 crate::operation::describe_network_interface_permissions::DescribeNetworkInterfacePermissionsError,
143 ::aws_smithy_runtime_api::client::orchestrator::HttpResponse,
144 >,
145 >,
146 > {
147 ::aws_smithy_async::future::pagination_stream::TryFlatMap::new(self.0.send()).flat_map(|page| {
148 crate::lens::lens_describe_network_interface_permissions_output_output_network_interface_permissions(page)
149 .unwrap_or_default()
150 .into_iter()
151 })
152 }
153}