Skip to content

Commit

Permalink
Do not use box
Browse files Browse the repository at this point in the history
  • Loading branch information
adzialocha committed Nov 15, 2024
1 parent f7eba10 commit ff1c9a5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions rhio-blobs/src/bao_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl BaoFileHandle {
///
/// This method returns a handle onto an incomplete BAO file using the expected paths. It
/// doesn't create any files yet or transfer any data.
pub fn new(bucket: Box<Bucket>, paths: Paths, data_size: u64) -> Self {
pub fn new(bucket: Bucket, paths: Paths, data_size: u64) -> Self {
Self {
data: S3File::new(bucket.clone(), paths.data()),
outboard: S3File::new(bucket.clone(), paths.outboard()),
Expand All @@ -77,7 +77,7 @@ impl BaoFileHandle {
/// This method is for taking an existing blob and generating it's accompanying outboard file.
/// It is useful when importing blobs from an s3 bucket directly into the store.
pub async fn create_complete(
bucket: Box<Bucket>,
bucket: Bucket,
path: String,
size: u64,
) -> anyhow::Result<(Self, BaoMeta)> {
Expand Down
4 changes: 2 additions & 2 deletions rhio-blobs/src/s3_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ impl MultiPartBuffer {

#[derive(Debug)]
pub struct S3File {
bucket: Box<Bucket>,
bucket: Bucket,
buffer: MultiPartBuffer,
path: String,
upload_id: Option<String>,
uploaded_parts: Vec<Part>,
}

impl S3File {
pub fn new(bucket: Box<Bucket>, path: String) -> Self {
pub fn new(bucket: Bucket, path: String) -> Self {
Self {
bucket,
path,
Expand Down
8 changes: 4 additions & 4 deletions rhio-blobs/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ use crate::paths::{Paths, META_SUFFIX, NO_PREFIX};
/// Blob data and outboard files are stored in an s3 bucket.
#[derive(Debug, Clone)]
pub struct S3Store {
buckets: Vec<Box<Bucket>>,
buckets: Vec<Bucket>,
inner: Arc<S3StoreInner>,
}

impl S3Store {
/// Create a new S3 blob store interface for p2panda.
pub async fn new(buckets: Vec<Box<Bucket>>) -> Result<Self> {
pub async fn new(buckets: Vec<Bucket>) -> Result<Self> {
let mut store = Self {
buckets,
inner: Default::default(),
Expand All @@ -44,7 +44,7 @@ impl S3Store {
Ok(store)
}

pub fn buckets(&self) -> &Vec<Box<Bucket>> {
pub fn buckets(&self) -> &Vec<Bucket> {
self.buckets.as_ref()
}

Expand Down Expand Up @@ -144,7 +144,7 @@ impl S3Store {
self.inner.0.read().await
}

fn bucket(&self, bucket_name: &str) -> Box<Bucket> {
fn bucket(&self, bucket_name: &str) -> Bucket {
self.buckets
.iter()
.find(|bucket| bucket.name() == bucket_name)
Expand Down
8 changes: 4 additions & 4 deletions rhio/src/blobs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Blobs {

/// Initiates and returns a blob store handler for S3 backends based on the rhio config.
pub async fn store_from_config(config: &Config) -> Result<S3Store> {
let mut buckets: HashMap<String, Box<Bucket>> = HashMap::new();
let mut buckets: HashMap<String, Bucket> = HashMap::new();

let credentials = config
.s3
Expand All @@ -125,7 +125,7 @@ pub async fn store_from_config(config: &Config) -> Result<S3Store> {
for bucket_name in &publish.s3_buckets {
let bucket =
Bucket::new(bucket_name, region.clone(), credentials.clone())?.with_path_style();
buckets.insert(bucket_name.clone(), bucket);
buckets.insert(bucket_name.clone(), *bucket);
}
}

Expand All @@ -134,11 +134,11 @@ pub async fn store_from_config(config: &Config) -> Result<S3Store> {
let bucket_name = scoped_bucket.bucket_name();
let bucket =
Bucket::new(&bucket_name, region.clone(), credentials.clone())?.with_path_style();
buckets.insert(bucket_name, bucket);
buckets.insert(bucket_name, *bucket);
}
}

let buckets: Vec<Box<Bucket>> = buckets.values().cloned().collect();
let buckets: Vec<Bucket> = buckets.values().cloned().collect();
let store = S3Store::new(buckets)
.await
.context("could not initialize s3 interface")?;
Expand Down
1 change: 1 addition & 0 deletions rhio/src/node/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub struct NodeActor {
nats: Nats,
panda: Panda,
blobs: Blobs,
#[allow(dead_code)]
watcher: S3Watcher,
}

Expand Down

0 comments on commit ff1c9a5

Please sign in to comment.