summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/route53.rs45
1 files changed, 17 insertions, 28 deletions
diff --git a/src/route53.rs b/src/route53.rs
index 3c34e9c..cf7277d 100644
--- a/src/route53.rs
+++ b/src/route53.rs
@@ -19,41 +19,30 @@ where
{
let names = suffixes(name.clone());
- // Outer pagination loop needs to be pulled out to a trait - this is some hot nonsense.
let mut zone = None;
let mut depth = None;
- let mut zones_marker = None;
- loop {
- let zones_resp = aws_context
- .route53()
- .list_hosted_zones()
- .set_marker(zones_marker)
- .send()
- .await?;
+ let mut zones = aws_context
+ .route53()
+ .list_hosted_zones()
+ .into_paginator()
+ .items()
+ .send();
- let zones = zones_resp.hosted_zones();
- for candidate_zone in zones.iter() {
- let zone_name = Name::from_str(candidate_zone.name())?;
- let match_position = names.iter().position(|name| *name == zone_name);
- match (depth, match_position) {
- (None, Some(matched_depth)) => {
+ while let Some(candidate_zone) = zones.try_next().await? {
+ let zone_name = Name::from_str(candidate_zone.name())?;
+ let match_position = names.iter().position(|name| *name == zone_name);
+ match (depth, match_position) {
+ (None, Some(matched_depth)) => {
+ zone = Some(candidate_zone.clone());
+ depth = Some(matched_depth);
+ }
+ (Some(found_depth), Some(matched_depth)) => {
+ if matched_depth < found_depth {
zone = Some(candidate_zone.clone());
depth = Some(matched_depth);
}
- (Some(found_depth), Some(matched_depth)) => {
- if matched_depth < found_depth {
- zone = Some(candidate_zone.clone());
- depth = Some(matched_depth);
- }
- }
- (_, _) => {}
}
- }
-
- if zones_resp.is_truncated() {
- zones_marker = zones_resp.next_marker().map(String::from);
- } else {
- break;
+ (_, _) => {}
}
}