Chris Mikkelson [Tue, 23 Jul 2024 20:15:21 +0000 (15:15 -0500)]
Generic sources working after big refactor.
Root cause was Box<dyn Trait> defaults to Box<dyn Trait + 'static>,
leading to the 'static lifetime "infecting" the generated iterators,
causing the borrow to last beyond the end of the function which dropped
the box or its containing structure.
The quick fix was to inject and add an explicit lifetime to the Box.
While tuning that fix, opted to inject lifetimes by implementing
Source methods on references. This tracks more with the C mtbl API,
where:
m = mtbl_merger_init(mopt);
/* populate m */
mtbl_merger_source(m);
Chris Mikkelson [Sun, 21 Jul 2024 00:40:23 +0000 (19:40 -0500)]
Refactor Source trait hierarchy
Source implements get/prefix/range, and is a subtrait of
IterSource which implements only iter(). The Default
implementation is now another subtrait of IterSource.
This avoids several of the previouas `Source<'a> + Ranges<'a>`
and 'Source<'a> + DefaultRanges' type constraints, and
simplifies type paths.
Chris Mikkelson [Fri, 19 Jul 2024 17:10:19 +0000 (12:10 -0500)]
WIP commit: attempt to make Source object safe
Use associated iterator types instead of `impl Iter`. Move
get, get_prefix, get_range to separate "Ranges" trait, with
a generic default implementation based on iter() enabled by
"DefaultRanges" trait.
Chris Mikkelson [Mon, 29 Apr 2024 01:44:00 +0000 (20:44 -0500)]
Modify filter_map to only map values
Mapping keys requires a conversion on seek from the
mapped key to the inner key. Since the keys are passed
to seek by reference to avoid moves, this complicates
consuming the key for a full conversion to the inner
key.
For now, restrict mapping to values only. This required
changing the filter function signature to take a reference
to the key so its caller could retain the key for returning.