Skip to content
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 MultipartUpload blanket implementation for Box<W> #5919

Merged
merged 4 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions object_store/src/upload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,21 @@ pub trait MultipartUpload: Send + std::fmt::Debug {
async fn abort(&mut self) -> Result<()>;
}

#[async_trait]
impl<W: MultipartUpload + ?Sized> MultipartUpload for Box<W> {
fn put_part(&mut self, data: PutPayload) -> UploadPart {
(**self).put_part(data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered why the ** was necessary, so I tried to remove it and got the error:

97 |     fn put_part(&mut self, data: PutPayload) -> UploadPart {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot return without recursing
98 |         self.put_part(data)
   |         ------------------- recursive call site

As in the dereference is required to find the correct impl

}

async fn complete(&mut self) -> Result<PutResult> {
(**self).complete().await
}

async fn abort(&mut self) -> Result<()> {
(**self).abort().await
}
}

/// A synchronous write API for uploading data in parallel in fixed size chunks
///
/// Uses multiple tokio tasks in a [`JoinSet`] to multiplex upload tasks in parallel
Expand Down
Loading