This patch changes the Entries::in_collection() interface to return a
Result<()>. This is needed because the fs backend implementation should
be able to check whether a directory actually exists whenever we change
the iterator.
If the implementation detects that the directory does not exist, we can
fail early and error out.
All usages of the interface are adapted by the patch as well.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This function needs to be removed because of the following problem:
When linking from one entry to another, and then removing the link in
the first entry with ::set_internal_links(vec![]), we end up with a
dangling link in the second entry, because the ::set_internal_links()
function does not take care of removing the links in the "other"
entries.
Actually, it is not even able to do so, because it would need to
`Store::get()` those entries, but it does not have access to the store.
Adding a `store` parameter to the function would be possible, but only
increase its complexity unnecessarily. This is why I opt for removing
this function (which is btw not used once in the whole imag codebase).
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
With this patch we move the codebase to Rust-2018.
The diff was generated by executing
cargo fix --all --all-features --edition
on the codebase.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This function can be used to override the basepath setting from the
header of the entry so that another basepath is used for looking
up/constructing the actual filepath.
This might come in handy at some point.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
The setting in the header should reflect the name of the setting in the
configuration file, for a better user experience.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Because the code was so complex before, we had to create an object and
then cast that object into a `StoreId` rather than just creating a
`StoreId` object right away.
With this patch, we're using the code-generation approach to generate a
function that creates a `StoreId` object based on the name of the
current module. That's way easier and error handling was also improved
by the switch to the new implementation.
The patch also includes a rewrite of all usages of ModuleEntryPath and
changes them to `module_path::new_id()` calls.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
The beta compiler reports duplicated input:
error: the item `IntoValues` is imported redundantly
--> lib/entry/libimagentrylink/src/internal.rs:398:13
|
36 | use self::iter::IntoValues;
| ---------------------- the item `IntoValues` is already imported here
...
398 | use internal::iter::IntoValues;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
so we fix this here.
Other imports were fixed as well.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This moves the helper function for getting the `Config` object from the
configuration file via the runtime.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
The previous implementation did not strip the prefix of the "relpath"
header value, which resulted in the whole path being in the header,
which is obviously wrong.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
The documentation of the function kind of explains why this change is
necessary. It might get changed in the future so that the user has more
flexibility.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
* Remove old code
* Rewrite with tests
This implements a fassade pattern for ref library
With the fassade, we can specify the hasher in a rather easy way, which
is not possible with default generics for traits.
The "default" part in "default generic type" is not properly implemented
yet (as visible in the tests), as I don't know how to realize this.
For simplicity, the `hasher` module exports a `default` module with a
`DefaultHasher` type, which resolves to the `Sha1Hasher`.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
The function is for checking whether a flag is set. If the flag is not
available, the flag is obviously not set.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>