Commit Graph

308 Commits

Author SHA1 Message Date
Matthias Beyer 1ffdb72315 Remove obsolete (internal) function 2019-06-22 12:00:02 +02:00
Matthias Beyer 5dc6829354 Rename module: linker -> linkable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-21 23:22:48 +02:00
Matthias Beyer ef17930c29 Rename interface
With this patch, the libimagentrylink library interface gets renamed.

The trait gets renamed to the more descriptive name "Linkable", the
functions get renamed to not contain any notion of "internal" anymore.

This patch also adapts the whole source tree for the new libimagentrylink
interface, also renaming variables to not contain "_internal_" anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-21 23:22:47 +02:00
Matthias Beyer f21b6e53a2 Merge branch 'libimagentrylink-split' into master 2019-06-15 16:48:50 +02:00
Matthias Beyer 901502b67e Split "internal" module into several submodules
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer d02d53594e Fix debug output message 2019-05-31 12:48:00 +02:00
Matthias Beyer d2a5e8fb59 Rename functions: *_external_link -> *_url
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 7f2e4c8442 Adapt tested path 2019-05-31 12:48:00 +02:00
Matthias Beyer 8b66672772 Fix libimagentrymarkdown for new url lib 2019-05-31 12:48:00 +02:00
Matthias Beyer c33c29e8e2 Fix import for new libimagentryurl lib
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 098d25db89 Move code from external libimagentrylink module to libimagentryurl
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-31 12:48:00 +02:00
Matthias Beyer 5cb641044f Add libimagentryurl
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 17:51:33 +02:00
Matthias Beyer 11955f699f Change interface of Viewer to propagate io errors
Because we need to catch errors that are caused by a borken pipe when
writing to stdout (for example), this patch changes the interface of the
Viewer trait to return an error enum that can be used to check whether
an IO error happened.

The calling code can then decide whether to ignore a broken pipe error
or whether to handle it properly.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 11:12:43 +02:00
Matthias Beyer 151e4d0aa8 Replace deprecated functioncall
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30 10:09:43 +02:00
Matthias Beyer a7d53e47d1 Update toml-query to 0.9.0
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
Matthias Beyer 1482f70320 Update dependency: toml: 0.4 -> 0.5
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29 18:39:25 +02:00
Matthias Beyer 5ff2c3e8e3 Remove lazy_static
we don't need lazy static here, so remove it and the dependency as well.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-25 10:43:24 +02:00
Matthias Beyer 5c8af4460e Fix: Entries::in_collection() should be able to return error
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>
2019-05-18 13:37:46 +02:00
Matthias Beyer 5a250bd991 Remove InternalLinker::set_internal_links()
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>
2019-05-18 02:31:03 +02:00
Matthias Beyer 27b75ba2fc Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 5ebbcb774a Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer b808658648 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer f540a317b0 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer c02b2f88de Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer c7ea58eda2 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer d8bcb8ca8e Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer f44e10e295 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 322c063450 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 6e0a179550 Add more context in error messages
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18 00:55:10 +02:00
Matthias Beyer 1d89844613 Run 'cargo fix' for rust-2018
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>
2019-05-18 00:20:59 +02:00
Matthias Beyer 427eac76fe Add Ref::get_path_with_basepath_setting()
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>
2019-04-22 14:40:07 +02:00
Matthias Beyer cf234437d7 Implement Partial for Config
With this implemented, we can fetch the appropriate configuration easily
from the configuration.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 13:06:26 +02:00
Matthias Beyer 2854e88dcc Rename: "ref.collection" to "ref.basepath"
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>
2019-04-22 13:06:26 +02:00
Matthias Beyer 7ae2d926cc Use toml-query master branch during development
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-22 13:06:26 +02:00
Matthias Beyer 31e3116b48 Revert "Remove GetIter"
This reverts commit a49522dc86770a741d61d548351ad69dfc56d1fa.
2019-04-14 00:16:47 +02:00
Matthias Beyer aa3fdb88d5 Remove GetIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer 4afebbe9e4 Remove FilterLinksIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer 1f515b1d0d Remove DeleteUnlinkedIter
Because the code is not used.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-14 00:16:47 +02:00
Matthias Beyer cb4d5367e4 Rewrite all usages of ModuleEntryPath
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>
2019-04-13 22:39:39 +02:00
Matthias Beyer de522ec0f2 Fix for rust beta compiler
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>
2019-04-13 22:06:53 +02:00
Matthias Beyer 19622f41ae Do not ignore errors when collecting links
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer 581da9c9cf Remove old comment
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 13:30:12 +01:00
Matthias Beyer 9af10fd2eb Fix indention
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:40 +01:00
Matthias Beyer 734112b856 Simplify
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:20 +01:00
Matthias Beyer d19020c3f5 Remove unnecessary Error::from() call
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-09 12:24:09 +01:00
Matthias Beyer d32f41aeab Outsource hashing itself so that we can re-use it
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-22 11:23:57 +01:00
Matthias Beyer b2fbf1e462 Add debug and trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 23:14:43 +01:00
Matthias Beyer dfc02a5679 Move helper function to libimagentref::util
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>
2019-02-20 16:22:52 +01:00
Matthias Beyer 0a62548173 Add function to get relative file path
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:21 +01:00
Matthias Beyer ed862db76f Fix: Strip the prefix of the path
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>
2019-02-20 12:31:37 +01:00