-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add lifetimes to async traits that take args by reference #3061
Changes from 1 commit
c0fc1ea
591e76f
46084bd
ba59c10
d187f61
99ef24d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ use crate::http_credential_provider::HttpCredentialProvider; | |
use crate::provider_config::ProviderConfig; | ||
use aws_credential_types::provider::{self, error::CredentialsError, future, ProvideCredentials}; | ||
use aws_smithy_http::endpoint::apply_endpoint; | ||
use aws_smithy_runtime_api::client::dns::{DnsResolver, ResolveDnsError, SharedDnsResolver}; | ||
use aws_smithy_runtime_api::client::dns::{ResolveDns, ResolveDnsError, SharedDnsResolver}; | ||
use aws_smithy_runtime_api::client::http::HttpConnectorSettings; | ||
use aws_smithy_runtime_api::shared::IntoShared; | ||
use aws_smithy_types::error::display::DisplayErrorContext; | ||
|
@@ -272,9 +272,9 @@ impl Builder { | |
|
||
/// Override the DNS resolver used to validate URIs | ||
/// | ||
/// URIs must refer to loopback addresses. The [`DnsResolver`](aws_smithy_runtime_api::client::dns::DnsResolver) | ||
/// is used to retrieve IP addresses for a given domain. | ||
pub fn dns(mut self, dns: impl DnsResolver + 'static) -> Self { | ||
/// URIs must refer to loopback addresses. The [`ResolveDns`](aws_smithy_runtime_api::client::dns::ResolveDns) | ||
/// implementation is used to retrieve IP addresses for a given domain. | ||
pub fn dns(mut self, dns: impl ResolveDns + 'static) -> Self { | ||
self.dns = Some(dns.into_shared()); | ||
self | ||
} | ||
|
@@ -399,7 +399,7 @@ async fn validate_full_uri( | |
Ok(addr) => addr.is_loopback(), | ||
Err(_domain_name) => { | ||
let dns = dns.ok_or(InvalidFullUriErrorKind::NoDnsResolver)?; | ||
dns.resolve_dns(host.to_owned()) | ||
dns.resolve_dns(host) | ||
.await | ||
.map_err(|err| InvalidFullUriErrorKind::DnsLookupFailed(ResolveDnsError::new(err)))? | ||
.iter() | ||
|
@@ -751,16 +751,22 @@ mod test { | |
} | ||
} | ||
|
||
impl DnsResolver for TestDns { | ||
fn resolve_dns(&self, name: String) -> DnsFuture { | ||
DnsFuture::ready(Ok(self.addrs.get(&name).unwrap_or(&self.fallback).clone())) | ||
impl ResolveDns for TestDns { | ||
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a> | ||
where | ||
Self: 'a, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I initially added it because the |
||
{ | ||
DnsFuture::ready(Ok(self.addrs.get(name).unwrap_or(&self.fallback).clone())) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
struct NeverDns; | ||
impl DnsResolver for NeverDns { | ||
fn resolve_dns(&self, _name: String) -> DnsFuture { | ||
impl ResolveDns for NeverDns { | ||
fn resolve_dns<'a>(&'a self, _name: &'a str) -> DnsFuture<'a> | ||
where | ||
Self: 'a, | ||
{ | ||
DnsFuture::new(async { | ||
Never::new().await; | ||
unreachable!() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 for verb + noun convention.