Skip to content

Commit

Permalink
Remove Self lifetime bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
jdisanti committed Oct 12, 2023
1 parent c0fc1ea commit 591e76f
Show file tree
Hide file tree
Showing 13 changed files with 20 additions and 77 deletions.
10 changes: 2 additions & 8 deletions aws/rust-runtime/aws-config/src/ecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -752,21 +752,15 @@ mod test {
}

impl ResolveDns for TestDns {
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a>
where
Self: 'a,
{
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a> {
DnsFuture::ready(Ok(self.addrs.get(name).unwrap_or(&self.fallback).clone()))
}
}

#[derive(Debug)]
struct NeverDns;
impl ResolveDns for NeverDns {
fn resolve_dns<'a>(&'a self, _name: &'a str) -> DnsFuture<'a>
where
Self: 'a,
{
fn resolve_dns<'a>(&'a self, _name: &'a str) -> DnsFuture<'a> {
DnsFuture::new(async {
Never::new().await;
unreachable!()
Expand Down
5 changes: 1 addition & 4 deletions aws/rust-runtime/aws-config/src/imds/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,7 @@ struct ImdsEndpointResolver {
}

impl EndpointResolver for ImdsEndpointResolver {
fn resolve_endpoint<'a>(&'a self, _: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a,
{
fn resolve_endpoint<'a>(&'a self, _: &'a EndpointResolverParams) -> EndpointFuture<'a> {
EndpointFuture::new(async move {
self.endpoint_source
.endpoint(self.mode_override.clone())
Expand Down
5 changes: 1 addition & 4 deletions aws/rust-runtime/aws-config/src/imds/client/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,7 @@ fn parse_token_response(response: &HttpResponse, now: SystemTime) -> Result<Toke
}

impl IdentityResolver for TokenResolver {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
IdentityFuture::new(async {
let preloaded_token = self
.inner
Expand Down
5 changes: 1 addition & 4 deletions aws/rust-runtime/aws-runtime/src/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ pub mod credentials {
}

impl IdentityResolver for CredentialsIdentityResolver {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
let cache = self.credentials_cache.clone();
IdentityFuture::new(async move {
let credentials = cache.as_ref().provide_cached_credentials().await?;
Expand Down
9 changes: 2 additions & 7 deletions rust-runtime/aws-smithy-runtime-api/src/client/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ new_type_future! {
/// Trait for resolving domain names
pub trait ResolveDns: fmt::Debug + Send + Sync {
/// Asynchronously resolve the given domain name
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a>
where
Self: 'a;
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a>;
}

/// Shared instance of [`ResolveDns`].
Expand All @@ -64,10 +62,7 @@ impl SharedDnsResolver {
}

impl ResolveDns for SharedDnsResolver {
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a>
where
Self: 'a,
{
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a> {
self.0.resolve_dns(name)
}
}
Expand Down
9 changes: 2 additions & 7 deletions rust-runtime/aws-smithy-runtime-api/src/client/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ impl Storable for EndpointResolverParams {
/// Configurable endpoint resolver implementation.
pub trait EndpointResolver: Send + Sync + fmt::Debug {
/// Asynchronously resolves an endpoint to use from the given endpoint parameters.
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a;
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a>;
}

/// Shared endpoint resolver.
Expand All @@ -64,10 +62,7 @@ impl SharedEndpointResolver {
}

impl EndpointResolver for SharedEndpointResolver {
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a,
{
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a> {
self.0.resolve_endpoint(params)
}
}
Expand Down
9 changes: 2 additions & 7 deletions rust-runtime/aws-smithy-runtime-api/src/client/identity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ new_type_future! {
/// There is no fallback to other auth schemes in the absence of an identity.
pub trait IdentityResolver: Send + Sync + Debug {
/// Asynchronously resolves an identity for a request using the given config.
fn resolve_identity<'a>(&'a self, config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a;
fn resolve_identity<'a>(&'a self, config_bag: &'a ConfigBag) -> IdentityFuture<'a>;
}

/// Container for a shared identity resolver.
Expand All @@ -51,10 +49,7 @@ impl SharedIdentityResolver {
}

impl IdentityResolver for SharedIdentityResolver {
fn resolve_identity<'a>(&'a self, config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
self.0.resolve_identity(config_bag)
}
}
Expand Down
10 changes: 2 additions & 8 deletions rust-runtime/aws-smithy-runtime-api/src/client/identity/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,7 @@ impl From<String> for Token {
}

impl IdentityResolver for Token {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
IdentityFuture::ready(Ok(Identity::new(self.clone(), self.0.expiration)))
}
}
Expand Down Expand Up @@ -126,10 +123,7 @@ impl Login {
}

impl IdentityResolver for Login {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
IdentityFuture::ready(Ok(Identity::new(self.clone(), self.0.expiration)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -579,10 +579,7 @@ impl RuntimeComponentsBuilder {
#[derive(Debug)]
struct FakeEndpointResolver;
impl EndpointResolver for FakeEndpointResolver {
fn resolve_endpoint<'a>(&'a self, _: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a,
{
fn resolve_endpoint<'a>(&'a self, _: &'a EndpointResolverParams) -> EndpointFuture<'a> {
unreachable!("fake endpoint resolver must be overridden for this test")
}
}
Expand All @@ -609,10 +606,7 @@ impl RuntimeComponentsBuilder {
#[derive(Debug)]
struct FakeIdentityResolver;
impl IdentityResolver for FakeIdentityResolver {
fn resolve_identity<'a>(&'a self, _: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _: &'a ConfigBag) -> IdentityFuture<'a> {
unreachable!("fake identity resolver must be overridden for this test")
}
}
Expand Down
5 changes: 1 addition & 4 deletions rust-runtime/aws-smithy-runtime/src/client/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ mod tokio {
}

impl ResolveDns for TokioDnsResolver {
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a>
where
Self: 'a,
{
fn resolve_dns<'a>(&'a self, name: &'a str) -> DnsFuture<'a> {
let name = name.to_string();
DnsFuture::new(async move {
let result = tokio::task::spawn_blocking(move || (name, 0).to_socket_addrs()).await;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ impl NoAuthIdentityResolver {
}

impl IdentityResolver for NoAuthIdentityResolver {
fn resolve_identity<'a>(&'a self, _: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _: &'a ConfigBag) -> IdentityFuture<'a> {
IdentityFuture::ready(Ok(Identity::new(NoAuthIdentity::new(), None)))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,7 @@ mod tests {
#[derive(Debug)]
struct TestIdentityResolver;
impl IdentityResolver for TestIdentityResolver {
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a>
where
Self: 'a,
{
fn resolve_identity<'a>(&'a self, _config_bag: &'a ConfigBag) -> IdentityFuture<'a> {
IdentityFuture::ready(Ok(Identity::new("doesntmatter", None)))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ impl StaticUriEndpointResolver {
}

impl EndpointResolver for StaticUriEndpointResolver {
fn resolve_endpoint<'a>(&'a self, _params: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a,
{
fn resolve_endpoint<'a>(&'a self, _params: &'a EndpointResolverParams) -> EndpointFuture<'a> {
EndpointFuture::ready(Ok(Endpoint::builder()
.url(self.endpoint.to_string())
.build()))
Expand Down Expand Up @@ -104,10 +101,7 @@ impl<Params> EndpointResolver for DefaultEndpointResolver<Params>
where
Params: Debug + Send + Sync + 'static,
{
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a>
where
Self: 'a,
{
fn resolve_endpoint<'a>(&'a self, params: &'a EndpointResolverParams) -> EndpointFuture<'a> {
let ep = match params.get::<Params>() {
Some(params) => self.inner.resolve_endpoint(params).map_err(Box::new),
None => Err(Box::new(ResolveEndpointError::message(
Expand Down

0 comments on commit 591e76f

Please sign in to comment.