-
Notifications
You must be signed in to change notification settings - Fork 18
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
Inability to fully specify type of Repository
#227
Comments
In case the suggested change is acceptable, I've created TilBlechschmidt@7467cd7 where I tested whether it works (it does) and based on which I could create a PR 🙂 |
Thanks for opening this issue @TilBlechschmidt! Note that the Repository type might change in future as we are not fully settled how to best model it. But anyway that would be a breaking change and hopefully not much work for you in an dependency update. |
Hi @aawsome! Will do. I had the same thought about the integration test but did not have the time to look into that the other day, a good idea for sure though. I'll put that on my list and send a PR your way soon™ Future breaking changes are totally fine, I am using a very small set of API functions anyway. Honestly, opening up these types muddies the current abstraction a little so it makes total sense that there are some changes in the pipeline 🤷♂️ Either way, thanks for working on and maintaining |
I've opened a PR which includes an integration test, let me know if there is anything else 🙂 FYI It seems that the snapshot tests are semi-broken on macOS due to some OS-specific file attribute (related to sandboxing) that gets added to the restored files. I did run my test in isolation and it works just fine, so we will have to see what the pipeline has to say about that 🤷 ┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈
48 60 │ "inode": "[inode]",
49 61 │ "device_id": "[device_id]",
50 62 │ "size": 21,
51 63 │ "links": 2,
64 │+ "extended_attributes": [
65 │+ ExtendedAttribute(
66 │+ name: "com.apple.provenance",
67 │+ value: "AQAAiAZZUZMQbLQ=",
68 │+ ),
69 │+ ],
52 70 │ "content": Some([
53 71 │ Id("649b8b471e7d7bc175eec758a7006ac693c434c8297c07db15286788c837154a"),
54 72 │ ]),
55 73 │ },
┈┈┈┈┈┈┈┈┈┈┈┈┼┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ |
See #227 for more details. I've added a test-case which constructs a minimal wrapper type around a Repository that implements `IndexedFull`, puts two instances into a collection (the primary motivator behind this), and hands them to a function that relies on the trait.
fixed in #229 |
Hey there 👋
I was trying to use
rustic_core
to read files from an on-disk backup and wanted to dynamically create and cache repositories (i.e. store them in a collection). However, while designing my internal API, I ran into the issue that the type of an opened and fully indexed Repository can not be fully specified:The problem is that while the
repository::IndexedFull
trait is re-exported, the concrete typesrepository::IndexedStatus
andrepository::FullIndex
are not.When directly using the return value of
Repository::new(...).open().to_indexed()
this does not matter, since the methods can be called regardless. Returning this value from a function is also possible usingimpl IndexedFull
. However, when for example constructing a wrapping struct like so:It becomes impossible to define the type since the previously mentioned concrete types are not public. It is possible to work around this by using generics and the
IndexedFull
trait.However, this forces one to push the creation of the repository far up the call stack (i.e. passing it in as a parameter in the code below) and litters the entire codebase with generics that will only ever have one representation. It also becomes impossible to dynamically create and store Repositories in a collection.
I also tried using dynamic dispatch instead by wrapping the repository in a
Box
orArc
and usingdyn IndexedFull
. However, this runs into the same issue where the associated type parameterI
needs to be specified which resolves toindex::GlobalIndex
which unfortunately is also private.My suggestion would be to re-export the two types
FullIndex
andIndexedStatus
inlib.rs#L151
as follows:There might be a way to put dynamically created Repositories into a collection through some type magic, though I could not find one 🤷 😢
The text was updated successfully, but these errors were encountered: