Skip to content

Commit

Permalink
Replace async_trait with native RPITIT
Browse files Browse the repository at this point in the history
  • Loading branch information
dmartin committed Jan 3, 2024
1 parent afa667b commit ecada9f
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 22 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-trait = "0.1.77"
aws-config = "1.1.1"
aws-sdk-cloudfront = "1.9.0"
aws-sdk-s3 = "1.11.0"
Expand Down
9 changes: 4 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
mod s3;
mod selfhosted;

use async_trait::async_trait;
use blake2::{Blake2b512, Digest};
use flate2::read::GzDecoder;
use log::{debug, info, trace};
Expand All @@ -12,6 +11,7 @@ use std::collections::HashMap;
use std::error::Error;
use std::fmt::{Debug, Display};
use std::fs;
use std::future::Future;
use std::io::{Read, Seek};
use std::path::Path;
use std::path::PathBuf;
Expand Down Expand Up @@ -58,7 +58,6 @@ pub enum BuildEvent {
Delete(String),
}

#[async_trait]
pub trait Backend: Sized {
// TODO: currently the get_options() methods are not actually called anywhere. It would be nice
// if they were used in the CLI help output or BackendCreationErrors.
Expand Down Expand Up @@ -92,11 +91,11 @@ pub trait Backend: Sized {
///
/// As there is the potential for race conditions when handling build events, backends must
/// process any events with the same build ID serially in the order of their arrival.
async fn run(
fn run(
&self,
cache_dir: &Path,
mut rx: Receiver<BuildEvent>,
) -> Result<(), Box<dyn std::error::Error>>;
rx: Receiver<BuildEvent>,
) -> impl Future<Output = Result<(), Box<dyn std::error::Error>>> + Send;
}

/// Returns the checksum of an artifact tarball.
Expand Down
2 changes: 0 additions & 2 deletions src/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::{
get_cache_dir_checksum, to_filename_str, Backend, BackendCreationError, BuildEvent,
CHECKSUM_FILENAME,
};
use async_trait::async_trait;
use aws_config::BehaviorVersion;
use aws_sdk_cloudfront::types::{InvalidationBatch, Paths};
use aws_sdk_s3::primitives::ByteStream;
Expand All @@ -21,7 +20,6 @@ pub struct S3 {
cloudfront_distribution: Option<String>,
}

#[async_trait]
impl Backend for S3 {
fn get_options() -> &'static [&'static str] {
&["bucket", "path-prefix", "cloudfront-distribution"]
Expand Down
2 changes: 0 additions & 2 deletions src/selfhosted.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::{Backend, BackendCreationError, BuildEvent};
use async_trait::async_trait;
use hyper::service::service_fn;
use hyper::{Request, Response};
use hyper_staticfile::{Body, Static};
Expand Down Expand Up @@ -56,7 +55,6 @@ async fn handle_request<B>(
Ok(res)
}

#[async_trait]
impl Backend for Selfhosted {
fn get_options() -> &'static [&'static str] {
&["address"]
Expand Down

0 comments on commit ecada9f

Please sign in to comment.