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

Implement ObjectStore for trait objects #3865

Closed
Kinrany opened this issue Mar 15, 2023 · 1 comment · Fixed by #3866
Closed

Implement ObjectStore for trait objects #3865

Kinrany opened this issue Mar 15, 2023 · 1 comment · Fixed by #3866
Labels
enhancement Any new improvement worthy of a entry in the changelog object-store Object Store Interface

Comments

@Kinrany
Copy link
Contributor

Kinrany commented Mar 15, 2023

Motivation

I'm writing an application that will use Amazon S3 for long-term storage. I want to also use local file system during development. I'd like to make this configurable: it should be possible to choose the kind of storage at runtime, based on user input.

AWS CLI is one well-known application that would clearly benefit from doing this.

Problem

Generics are common in Rust. object_store itself provides PrefixObjectStore that expects a T: ObjectStore value.

Unfortunately there's no (safe?) way to go back from a trait object to an owned value that implements the trait. That is, unless trait objects explicitly implement the trait.

Solution

impl ObjectStore for Box<dyn ObjectStore>

See #3866

Alternatives

Not sure. For wrappers provided by object_store itself it might be possible to have ObjectStore
provide combinators that return them.

Another approach that only really works for sealed traits is creating an enum that includes all possible trait implementations as variants.

@Kinrany Kinrany added the enhancement Any new improvement worthy of a entry in the changelog label Mar 15, 2023
@tustvold tustvold added the object-store Object Store Interface label Mar 24, 2023
@tustvold
Copy link
Contributor

label_issue.py automatically added labels {'object-store'} from #3866

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog object-store Object Store Interface
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants