Commit Graph

608 Commits

Author SHA1 Message Date
Matthias Beyer d08c27e623 Rewrite StoreIdIterator extensions
This patch reimplements the iterator extensions.

As we iterate (in StoreIdIterator) over Result<StoreId> now anyways, we
don't need the extensions for Result iterators anymore.

This patch rewrites the extensions to be more simple in every way and
generic over the error type in the iterator.
All the errors have to do is implement From<StoreError>, which is what
they do when linking the generated error types with error_chain to the
libimagstore error types.
2018-05-01 17:44:01 +02:00
Matthias Beyer 6ee3f4a3f6 Refactor libimagentrycategory to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 6f81d02445 Refactor libimagentryannotation to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 40688a3c2d Refactor libimagwiki to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 715753ed25 Refactor libimagtodo to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 72c83ae3f7 Refactor libimagtimetrack to fit new store iterator interface 2018-05-01 17:44:01 +02:00
Matthias Beyer 08114bbf36 Refactor libimagnotes to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer e643f36fa3 Refactor libimaghabit to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer bf0bef058d Refactor libimagdiary to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer 8f03b4a71a Refactor libimagcontact to fit new store iterator interface 2018-05-01 17:44:00 +02:00
Matthias Beyer a2ff298e67 Rewrite Store::entries()
This patch rewrites the Store::entries() function to not be collecting
the iterator.

It therefore introduces a new, internal, iterator type which creates the
StoreId objects from the pathes the PathIterator yields internally.

With this patch, the Store iterator interface changes, as the iterators
now yield `Result<StoreId, StoreError>` instead of `StoreId`.
This is necessary, as the internal conversion errors shouldn't be
hidden.

Of course, the iterator types (like the StoreGetIterator and so on)
should hold a Result<StoreId> internally as well, and also yield
appropritely. This was changed in this commit, too.
2018-05-01 17:44:00 +02:00
Matthias Beyer f4556f3983 Rewrite backend to not collect on pathes_recursively() 2018-05-01 17:44:00 +02:00
Matthias Beyer 900d9f0984
Merge pull request #1474 from matthiasbeyer/libimagstore/cache-flush
Add functionality to flush the internal cache
2018-04-30 21:07:37 +02:00
Matthias Beyer 41615bcc97
Merge pull request #1473 from matthiasbeyer/libimagstore/more-error-information
Add information about which storeid is the cause of the error in errors
2018-04-30 21:07:02 +02:00
Matthias Beyer 6a5bcb2709 Remove unused error kinds 2018-04-30 18:54:11 +02:00
Matthias Beyer 6a40ac6b98 Add information about which storeid is the cause of the error in errors 2018-04-30 18:53:54 +02:00
Matthias Beyer 860e47a256 Add functionality to flush the internal cache
Before we had the problem that when iterating over _a lot_ (like 5k)
entries and also fetching them, at some point the OS would return with
"Too many files open".

That is because the store internally caches a lot.

With this change, the Store gets an API to query how big the cache is,
how much the cache can currently hold and (and that's the main thing in
this patch) to flush the cache to disk.

A function to simply ask the store whether its cache should be flushed
(which would us require to ask the OS how many files we can open...
which would be possible with `libc::getrlimit`) does not yet exist,
though, but could be added easily if desired.
2018-04-30 18:39:59 +02:00
Matthias Beyer b3cf96d88b Refactor error handling, use more error chaining 2018-04-30 17:29:27 +02:00
Matthias Beyer fc92cfc36f Move header filters to FailableFilter 2018-04-29 11:43:32 +02:00
Matthias Beyer 30ac77d626 Add error module 2018-04-29 11:43:32 +02:00
Matthias Beyer e08ec34893 Remove empty module 2018-04-29 11:43:32 +02:00
Matthias Beyer 6d21d8eb49 Update dependency: filters: 0.2 -> 0.3 2018-04-29 10:46:36 +02:00
Matthias Beyer 0976cab014
Merge pull request #1464 from matthiasbeyer/libimagentrygps/32-bit-gps-values
libimagentrygps: 32 bit gps values
2018-04-29 00:35:21 +02:00
Matthias Beyer 93c3bb5862 Upgrade variables to 64 bit 2018-04-28 23:27:12 +02:00
Matthias Beyer 5870fa0785 Fix: Use 16 bit variables for GPS degree/minute/second 2018-04-28 23:18:02 +02:00
Matthias Beyer 5f3b7b31e7 Add support for storing email properties
We have to move the `Email` type at the bottom of the DeserVcard type
because it contains a table and we must emit tables as last values when
de/serializing.

Maybe this will shoot us in the foot later, but only with TOML I guess.
We'll see. For now, this is good.

For that we need to update a dependency: vobject -> 0.5
2018-04-27 16:57:37 +02:00
Matthias Beyer 82867f3ff6 Fix tests for new interface 2018-04-27 13:24:59 +02:00
Matthias Beyer f0969db47c Rewrite
This patch rewrites the whole libimagcategory and brings it to a nice
standard (the code before was rather messy).

Now, categories are represented by an entry in the store and all entries
which have this category are linked to that entry.
2018-04-26 12:05:28 +02:00
Matthias Beyer 9fc9e7fe17 Outsource iterator in iter module 2018-04-26 12:05:28 +02:00
Matthias Beyer ab15d89e64 Rewrite CategoryRegister as CategoryStore 2018-04-26 12:05:28 +02:00
Matthias Beyer 5f305ef7a7 Add module for category handling 2018-04-26 12:05:28 +02:00
Matthias Beyer c26f1aae2a This module should be named "entry" 2018-04-26 11:20:40 +02:00
Matthias Beyer f321aa82a1 Make sure category is linked when setting it 2018-04-26 11:20:09 +02:00
Matthias Beyer 0bacfb0a88
Merge pull request #1446 from matthiasbeyer/travis-clippy
Travis: clippy
2018-04-26 10:25:45 +02:00
Matthias Beyer ea80a5a09b Derive Default for InMemoryFileAbstraction, remove constructor 2018-04-25 19:15:07 +02:00
Matthias Beyer 6a34e7a8fd Derive Default for FSFileAbstraction, reduces boilerplate 2018-04-25 19:15:07 +02:00
Matthias Beyer bf363c4748 Use "if let" if matching on a single pattern 2018-04-25 19:15:07 +02:00
Matthias Beyer f1142c414d Use ok_or_else() instead of ok_or() 2018-04-25 19:15:07 +02:00
Matthias Beyer 22170a0d55 Do not String::from(String) 2018-04-25 19:13:51 +02:00
Matthias Beyer 6f5590713a Use single quotes here 2018-04-25 19:13:51 +02:00
Matthias Beyer 44521a7c8c Dont use "return" keyword at end of function 2018-04-25 19:13:51 +02:00
Matthias Beyer dc18e650bb Collapse nested if-else-if 2018-04-25 19:13:51 +02:00
Matthias Beyer 67675b2ab2 Remove unecessary clone 2018-04-25 19:13:51 +02:00
Matthias Beyer a25f650ca0 Be more ergonomic here 2018-04-25 19:13:51 +02:00
Matthias Beyer 84249e3fb5 Be less verbose when constructing an object
The rust compiler does some fancy things for us: It automatically finds
the right fields if the name of the variable and the file is the same.

Lets use that to reduce boilerplate with this patch.
2018-04-25 19:13:50 +02:00
Matthias Beyer 154c2e482b Change generate_variants() helper to use base by ref 2018-04-25 19:13:50 +02:00
Matthias Beyer 42c4186dec Use or_else() instead of or() 2018-04-25 19:13:50 +02:00
Matthias Beyer 80c07171aa Make sure we can deserialize
Use default values when field is not there when we deserialize. This
does automatically the right thing.
2018-04-25 13:45:00 +02:00
Matthias Beyer 56c1b78d93 Add getters for DeserVcard helper type 2018-04-25 13:45:00 +02:00
Matthias Beyer abc142f4b5 Rewrite library
libimagcontact stores all contact information in the entry header now.
2018-04-25 12:54:01 +02:00