Commit Graph

815 Commits

Author SHA1 Message Date
Matthias Beyer a819aeb6ed Rewrite libimagmail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +01:00
Matthias Beyer f84cc8169f Revert "Remove libimagmail"
This reverts commit 74045e1800.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 16:22:52 +01:00
Matthias Beyer 34d9f3429f Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 14:43:29 +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 37bf2ce191 Fix: Use StoreIdWithBase::from_full_path
We iterate over full pathes to store entries here, which causes
`StoreId::new()` to error. But if we use the internal parsing helper
`StoreIdWithBase::from_full_path()` and then call `::into_storeid()` on
the resulting object, everything is fine.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20 12:31:37 +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
Matthias Beyer 04e006154c Fix: Use "ref.relpath" as path to header value
The header value for the relative path is at "ref.relpath". This fixes
the wrong selector.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
Matthias Beyer 22c239c212 Add output about logger settings in logging setup
This way we can get trace-level information about the logger itself when
it is generated. Because from time to time we might want to have a look
at that.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-19 21:51:44 +01:00
Matthias Beyer b5fe48b564 Remove serializing where result was unused
I'm not sure why this was still there, it seems that this was left out
when deleting older code.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-18 16:02:49 +01:00
Matthias Beyer 74045e1800 Remove libimagmail
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 11:09:48 +01:00
Matthias Beyer ac5a3c0298 Reimplement LinkProcessor::process() for new libimagentryref API
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>
2019-02-17 11:09:48 +01:00
Matthias Beyer d8ad741fc2 Rewrite libimagentrymarkdown imports 2019-02-17 11:09:48 +01:00
Matthias Beyer db7121ccba Rewrite library
* 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>
2019-02-17 11:09:48 +01:00
Matthias Beyer 820ac41443 Add trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-17 10:47:46 +01:00
Matthias Beyer 84c6a1981e Fix: If the field is not available, return false
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>
2019-02-17 10:47:46 +01:00
Matthias Beyer a6ad19a14f Merge branch 'redefine-storeid'
Finally merging the redefine of the StoreId implementation, which allows
easier handling of StoreId objects.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:58 +01:00
Matthias Beyer 9af7e9a9ab Remove unused variable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:15:06 +01:00
Matthias Beyer 6fd2c9b958 Remove irrelevant tests
Because StoreId objects do not contain bases anymore, we do not need
these tests anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 22:10:49 +01:00
Matthias Beyer 0888e4345c Use StoreId::local_display_string() for less errorhandling here
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 444ca2d424 Adapt to new all_contacts() return type
because we return `libimagstore::iter::Entries` here now, we do not have
to pass the store anymore.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 8fb4bcf0c6 Fix for new StoreId::new() interface
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 972cba7c31 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 207fd88c3d Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer d2c031920a Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer ebf3f309a6 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 187b948985 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 83415e78b9 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer f64b87b4a8 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer c6cc1804e7 Adapt to new libimagstore::iter::Entries API
Use Entries::into_storeid_iter() for transforming iterator into right
type.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b4f401675e Add Entries::into_storeid_iter()
This is a more complicated functionality (implementation-wise) of the
`Entries` iterator, which allows a callee to transform it into a
`StoreIdIterator`.

It uses the crate internal `PathIterator` type and a function to extract
the internals of that iterator which is then turned into an iterator
over `Result<StoreId>`, which can be used to build a `StoreIdIterator`.

The implementation is ugly, but we need to be able to transform a
`Entries` iterator into a `StoreIdIterator` in the
`libimagentryannotation`, and possibly in more cases where we want to be
agnostic over iterators.

Maybe there is a cleaner solution to this, hence the comment about
whether this should be removed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 2e7c17d5dc Fix libimagcontact for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer b383e082fb Fix libimagtodo for new StoreId interface with Entries iterator
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 14a2485a8a Change signature: Link::exists(&Store)
This change is necessary because we need the store now to check whether
a StoreId exists.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 429ef9bc4c Fix libimagentrylink for new StoreId API
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:29 +01:00
Matthias Beyer 642702b724 Rewrite: StoreId::new_baseless() -> StoreId::new()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer b66371f79b Rewrite Store::new* API: libimagstore does not export backend types
With this change applied, libimagstore does not export backend
representing types anymore.

This change is necessar because when we want to switch the `StoreId`
implementation from "complex and stateful" to "Stateless and Cow<'_,
&str>", we need to be able to have a type which represents a "`StoreId`
plus the path of the Store itself".
This "the path of the Store itself" is passed around as reference, to
minimize runtime impact.

Because such a type should not be exported by the libimagstore crate, we
make it `pub(crate)` internally. But because the backend APIs also have
to use this type, we would export the (private) type in the APIs of the
backend.

Because of that we make the backend API also non-visible to crate users,
which also decreases the surface of the libimagstore API itself.

Besides:
Remove function `Link::with_base()` which is not needed anymore (was
used in tests only).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 35a500f91c Delete unused code
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer 04a8c5f721 Move to simpler implementation of Storeid
This changes the implementation of the StoreId type to be less complex.
Before we always had to re-attach the path of the store itself each time
a StoreId object was passed to the store. Now we do not do this anymore,
hopefully we can move to a implementation of the Store API which takes
references of StoreId objects in the future.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 20:53:28 +01:00
Matthias Beyer dc162cb167 Fix: Off by one error
When printing the error chain, we print the error and then iterate over
the causes. Hence, we have to increase the printed number by one here,
because 0 (zero) is already printed.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:56:13 +01:00
Matthias Beyer 45cb122f53 Add debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 19:05:09 +01:00
Matthias Beyer 0916c92a18 Bugfix: Rebuild iterator when changing collection
This patch fixes a bug where the following code (here pseudocode) did
the wrong thing:

    store.entries().in_collection("foo").for_each(||...)

because the `.in_collection()` call for the underlying PathIterator
object did not actually re-build the iterator. It only changed the
contained `PathIterBuilder`, but did not call `.build_iter()` on it to
rebuild the iterator object.

The test added with this patch checks whether the iterator does the
right thing.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15 18:29:15 +01:00
Matthias Beyer 2a07c8a0c2 Do not use deprecated way of checking whether path exists
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-12 19:04:15 +01:00
Matthias Beyer c98ec920a3 Adapt for new interface of gen_vars() function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 7680dcf3b8 Make generate_variants() more flexible
This patch changes generate_variants() so that it allows to be passed an
iterator for the modders, which makes it more powerful for passing
references.
2019-02-11 03:52:04 +01:00
Matthias Beyer b985c510aa Optimize: Do not iterate over entries outside of "timetrack" collection
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 171b42307d Add feature to trim content on the right
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 90eaeb642a Remove magic constants in trace_unwrap_exit/map_err_trace_exit_unwrap calls
This patch removes the magic constant we used when calling
`trace_unwrap_exit()` or `map_err_trace_exit_unwrap()`.
We used to call it with `1` as parameter, where the number was the exit
code to use. Now the implementation of the function does it
automatically (using 1 (one) as exit code).

All calls of these functions were fixed. Thanks to vim this was easy.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:52:04 +01:00
Matthias Beyer 01fa19aade Remove clone() calls
We should be able, from the signature of the `generate_variants()`
helper function, to pass a `Vec<&T>` here, so cloning should not be
necessary.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:23:17 +01:00
Matthias Beyer 6b34e99b75 Make doc comment test executable
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:23:17 +01:00
Matthias Beyer 751ce5af1a Simplify implementation
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11 03:22:56 +01:00