summaryrefslogtreecommitdiffstats
path: root/lib/core
AgeCommit message (Collapse)Author
2019-06-30Update all dependenciesMatthias Beyer
This patch updates all dependencies but not "nom". Done with `cargo upgrade --all` and manual editing. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-06-22Allow unused variable hereMatthias Beyer
2019-05-31Import toml-query with typed featureMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Rewrite to use derive macroMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Add comment why we do thisMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Remove boilerplate by enabling serde in "log" dependencyMatthias Beyer
This patch adds the "serde" feature to the "log" dependency, so we can deserialize logging levels directly into "log" types. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-30Rewrite logging config deserializationMatthias Beyer
This patch rewrites the logging config deserialization. It removes the manual traversing of the config toml structure and replaces it with types which implement `Deserialize`, which is way more convenient and easy to read (and extend). Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29Update toml-query to 0.9.0Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-29Update dependency: toml: 0.4 -> 0.5Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-24Introduce proper error handling in IdPathProviderLeon Schuermann
Prior to this change, the IdPathProvider implementation would be responsible for exiting the process on insufficient / wrong arguments. However, such error handling should be performed together with the business logic and not in CLI-parsing related code. This change introduces a clear separation: both parsing errors and insufficient id path arguments can now be return from inside the `get_ids`-method, and get passed up to the application logic to be handled. This change is reflected in all instances of IdPathProvider and their surrounding code. Signed-off-by: Leon Schuermann <leon.git@is.currently.online> Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Fix: Entries::in_collection() should be able to return errorMatthias Beyer
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-18Add more context in error messagesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Add more context in error messagesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-05-18Run 'cargo fix' for rust-2018Matthias Beyer
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-04-13Merge branch 'fix-path-iterator' into master-ffMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13Fix: PathIterBuilder should not yield directoriesMatthias Beyer
PathIterBuilder should yield iterator that does only yield file pathes, not directories. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-04-13Rewrite all usages of ModuleEntryPathMatthias Beyer
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-13Fix for rust beta compilerMatthias Beyer
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-03-09Remove old TODOMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-03-07Remove Iterator::size_hint() implementationMatthias Beyer
I'm not sure why the author added this in the first place, but I bet we don't need this. So remove code we do not need. Feel free to prove me wrong and revert this patch. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20Add debug outputMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-20Fix: Use StoreIdWithBase::from_full_pathMatthias Beyer
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-19Add output about logger settings in logging setupMatthias Beyer
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-15Merge branch 'redefine-storeid'Matthias Beyer
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-15Remove unused variableMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Remove irrelevant testsMatthias Beyer
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-15Use StoreId::local_display_string() for less errorhandling hereMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Adapt to new libimagstore::iter::Entries APIMatthias Beyer
Use Entries::into_storeid_iter() for transforming iterator into right type. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Add Entries::into_storeid_iter()Matthias Beyer
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-15Rewrite: StoreId::new_baseless() -> StoreId::new()Matthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Rewrite Store::new* API: libimagstore does not export backend typesMatthias Beyer
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-15Delete unused codeMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Move to simpler implementation of StoreidMatthias Beyer
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-15Fix: Off by one errorMatthias Beyer
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-15Add debug outputMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-15Bugfix: Rebuild iterator when changing collectionMatthias Beyer
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-11Adapt for new interface of gen_vars() functionMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11Remove magic constants in trace_unwrap_exit/map_err_trace_exit_unwrap callsMatthias Beyer
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-11Remove clone() callsMatthias Beyer
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-11Simplify implementationMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11Add trace!() call to show config when runtime initializesMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-11Change id reporting API to return ExitCodeMatthias Beyer
Because this API only errors when write!() errors occur, we can return the exit code as an error here. This way the user of the API can immediately exit if there was an IO error, but the API automatically takes care of the right return value, returning (exiting) with zero (0) if there was an "Broken pipe" error and with one (1) otherwise, which is the expected behaviour here. All calls to that API were changed accordingly. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-10Fix config override mechanismMatthias Beyer
The bug was that we did not actually _set_ the new value. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-05Remove log-destination-override featuresMatthias Beyer
This removes the feature to be able to override log destinations from the commandline. This feature is removed because the --override-config feature from the runtime already contains this functionality. It is a little more complex to use, though this is a feature hardly used at all, so I rather go for less code (less complexity) here than feature bloat. Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-02-05Add runtime feature: Ignore id reportingMatthias Beyer
This feature gives the users of the Runtime API the possibility to check whether the user wants the ID reporting to be ignored as well (and more important) to override the default behaviour where the runtime assumes that if STDOUT is a pipe, it is a pipe to an imag command. Before, this would not have been possible: imag contact find Jonas --json | jq 'map(.fullname)' because the runtime automatically prints the output of the command to stderr and the touched IDs to stdout. But now with this change, a user can override this default behaviour and do: imag contact --ignore-ids find Jonas --json | jq 'map(.fullname)' Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-01-03Update copyright yearsMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-12-13Add Store::exists() for checking whether a StoreId exists as EntryMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-26Simplify Display impl for StoreidMatthias Beyer
2018-11-26Reimplement StoreId::to_str() without erroringMatthias Beyer
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-11-11Forbid unsafe code in all cratesMatthias Beyer