Skip to content

Commit

Permalink
Merge pull request #83 from Kuadrant/refactor-unstable-library-feature
Browse files Browse the repository at this point in the history
policy.rs: refactor unstable .inspect_err feature for rust <=1.75
  • Loading branch information
alexsnaps authored Sep 12, 2024
2 parents 7c7fa22 + c7cf5ea commit 33e70d2
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,19 @@ impl Policy {
}
// TODO(eastizle): not all fields are strings
// https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/advanced/attributes
Some(attribute_bytes) => Attribute::parse(attribute_bytes)
.inspect_err(|e| debug!("#{} build_single_descriptor: failed to parse selector value: {}, error: {}",
filter.context_id, attribute_path, e))
.ok()?,
Some(attribute_bytes) => match Attribute::parse(attribute_bytes) {
Ok(attr_str) => attr_str,
Err(e) => {
debug!("#{} build_single_descriptor: failed to parse selector value: {}, error: {}",
filter.context_id, attribute_path, e);
return None;
}
},
// Alternative implementation (for rust >= 1.76)
// Attribute::parse(attribute_bytes)
// .inspect_err(|e| debug!("#{} build_single_descriptor: failed to parse selector value: {}, error: {}",
// filter.context_id, attribute_path, e))
// .ok()?,
};
let mut descriptor_entry = RateLimitDescriptor_Entry::new();
descriptor_entry.set_key(descriptor_key);
Expand Down

0 comments on commit 33e70d2

Please sign in to comment.