From 4f568db968cced94eb282d1353e43625ee8811bb Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Tue, 23 Jul 2024 19:21:03 -0400 Subject: Retire the `result` module. It didn't add much to have our own Result definition, over using `anyhow::Result` directly. --- src/apply.rs | 2 +- src/autoscaling.rs | 3 +-- src/bin/aws-autoscaling-dns.rs | 6 +++--- src/cli.rs | 5 ++--- src/converge.rs | 3 +-- src/dns.rs | 6 ++---- src/ec2.rs | 2 +- src/lib.rs | 1 - src/result.rs | 4 ---- src/route53.rs | 3 +-- 10 files changed, 12 insertions(+), 23 deletions(-) delete mode 100644 src/result.rs diff --git a/src/apply.rs b/src/apply.rs index 8a94642..abf579f 100644 --- a/src/apply.rs +++ b/src/apply.rs @@ -1,6 +1,6 @@ +use anyhow::Result; use aws_sdk_route53::types::{Change, ChangeAction, ChangeBatch, ResourceRecordSet}; -use crate::result::Result; use crate::route53::Route53; pub enum ApplyMode { diff --git a/src/autoscaling.rs b/src/autoscaling.rs index 6c96279..81b9961 100644 --- a/src/autoscaling.rs +++ b/src/autoscaling.rs @@ -1,8 +1,7 @@ -use anyhow::anyhow; +use anyhow::{anyhow, Result}; use aws_sdk_autoscaling as autoscaling; use aws_sdk_autoscaling::types::AutoScalingGroup; -use crate::result::Result; use crate::single::Single; pub trait AutoScaling { diff --git a/src/bin/aws-autoscaling-dns.rs b/src/bin/aws-autoscaling-dns.rs index 6999b6b..589f9d5 100644 --- a/src/bin/aws-autoscaling-dns.rs +++ b/src/bin/aws-autoscaling-dns.rs @@ -1,9 +1,9 @@ use clap::Parser; -use aws_autoscaling_dns::cli; +use aws_autoscaling_dns::cli::Args; #[tokio::main] -async fn main() -> cli::Result { - let args = cli::Args::parse(); +async fn main() -> anyhow::Result<()> { + let args = Args::parse(); args.run().await } diff --git a/src/cli.rs b/src/cli.rs index 75bb5ef..96758be 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,5 +1,6 @@ use std::fmt::Debug; +use anyhow::Result; use clap::Parser; use trust_dns_proto::rr::Name; @@ -38,10 +39,8 @@ pub struct Args { apply: bool, } -pub type Result = crate::result::Result<()>; - impl Args { - pub async fn run(self) -> Result { + pub async fn run(self) -> Result<()> { let args = Args::parse(); let name = args.autoscaling_group; diff --git a/src/converge.rs b/src/converge.rs index a858347..5e6b817 100644 --- a/src/converge.rs +++ b/src/converge.rs @@ -1,6 +1,6 @@ use std::fmt::Debug; -use anyhow::anyhow; +use anyhow::{anyhow, Result}; use aws_sdk_autoscaling::types::AutoScalingGroup; use aws_sdk_route53::types::ResourceRecordSet; use futures::try_join; @@ -10,7 +10,6 @@ use crate::autoscaling::{asg_by_name, AutoScaling}; use crate::dns::AutoScalingGroupConfig; use crate::ec2::{instance_recordsets, Ec2}; use crate::hashable::Hashable; -use crate::result::Result; use crate::route53::{zone_for_domain, zone_suffix_recordsets, Route53}; #[derive(Debug)] diff --git a/src/dns.rs b/src/dns.rs index 13e3650..3a91290 100644 --- a/src/dns.rs +++ b/src/dns.rs @@ -1,12 +1,10 @@ use std::convert::TryFrom; use std::fmt::Debug; -use anyhow::anyhow; +use anyhow::{anyhow, Result}; use aws_sdk_autoscaling::types::{AutoScalingGroup, Instance, LifecycleState}; use trust_dns_proto::rr::Name; -use crate::result::{Error, Result}; - #[derive(Debug)] pub struct AutoScalingGroupConfig { pub name: String, @@ -34,7 +32,7 @@ impl AutoScalingGroupConfig { } impl TryFrom<&AutoScalingGroup> for AutoScalingGroupConfig { - type Error = Error; + type Error = anyhow::Error; fn try_from(autoscaling_group: &AutoScalingGroup) -> Result { let name = autoscaling_group diff --git a/src/ec2.rs b/src/ec2.rs index 28169e7..6e8af57 100644 --- a/src/ec2.rs +++ b/src/ec2.rs @@ -1,5 +1,6 @@ use std::collections::HashSet; +use anyhow::Result; use aws_sdk_ec2 as ec2; use aws_sdk_ec2::types::Filter; use aws_sdk_route53::types::{ResourceRecordSet, RrType}; @@ -8,7 +9,6 @@ use trust_dns_proto::rr::Name; use crate::dns::absolute; use crate::hashable::Hashable; -use crate::result::Result; use crate::route53::recordset; pub trait Ec2 { diff --git a/src/lib.rs b/src/lib.rs index 7de39bd..6eddc65 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -6,6 +6,5 @@ mod converge; mod dns; mod ec2; mod hashable; -mod result; mod route53; mod single; diff --git a/src/result.rs b/src/result.rs deleted file mode 100644 index 7c607c5..0000000 --- a/src/result.rs +++ /dev/null @@ -1,4 +0,0 @@ -use anyhow; - -pub type Error = anyhow::Error; -pub type Result = std::result::Result; diff --git a/src/route53.rs b/src/route53.rs index 67bccb5..89f4b03 100644 --- a/src/route53.rs +++ b/src/route53.rs @@ -1,14 +1,13 @@ use std::collections::HashSet; use std::str::FromStr; -use anyhow::anyhow; +use anyhow::{anyhow, Result}; use aws_sdk_route53 as route53; use aws_sdk_route53::types::{HostedZone, ResourceRecord, ResourceRecordSet, RrType}; use trust_dns_proto::rr::Name; use crate::dns::suffixes; use crate::hashable::Hashable; -use crate::result::Result; pub trait Route53 { fn route53(&self) -> &route53::Client; -- cgit v1.2.3