ds-ext
Archived — no longer maintained. New projects should use standard collections or the alternatives below. The full library remains available for existing users; archival does not remove its source or change already published releases.
Why archive it?
Rust's standard collections now cover TinyChain's ordered transaction indexes.
TinyChain uses BTreeMap and BTreeSet for those indexes, and freqfs owns a small
private structure for its cache-specific priority policy. No active TinyChain
crate depends on ds-ext. Maintaining a separate general-purpose collection
library is no longer justified by this project's needs.
This is a maintenance decision, not a claim that another implementation is universally faster. The existing standalone collections and optional integrations are retained, including the correctness fixes described below.
Alternatives
Choose by the ordering and ownership behavior your application needs.
| Need | Alternative | Migration consideration |
|---|---|---|
| Unordered lookup | Standard HashMap and HashSet |
Iteration is not in key order. |
| Key ordering, ranges, and first/last entries | Standard BTreeMap and BTreeSet |
Exact lookup uses tree comparisons rather than hashing. |
| Comparison-based search over sorted data | Slice binary_search_by or partition_point |
Handle incomparable edges explicitly; use a lower-bound partition when the first equal item matters. |
| Insertion order and positional access | IndexMap and IndexSet |
Swap removal changes survivor order; order-preserving shift removal is linear. |
| Linked ordering or an LRU cache | hashlink |
Front/back movement and LRU are different policies from one-position promotion. |
| A complete concurrent cache | Moka |
Its default TinyLFU policy combines frequency-based admission and LRU eviction; it does not reproduce ds-ext's promotion policy. |
These are not universal drop-in replacements. Check insertion/replacement order, removal and drain behavior, and any persisted hashes or codec representations before migrating. A replacement's hashing or serialization support does not by itself guarantee the same bytes or digest.
Retained functionality
LinkedHashMap: front insertion/replacement, one-position promotion, arbitrary swapping, removal, cloning, and borrowed/owned double-ended iteration.OrdHashMapandOrdHashSet: key ordering, exact lookup, comparison-based bisection, mutation, partial drains, owned iteration, and size accounting.- Optional integrations:
hashenablesasync-hash;streamenablesdestream;serializeenables Serde;allenables all three. Hash support followsasync-hashtrait bounds; borrowed hashing requires borrowed element support.
Cache priority ordering
The linked map remains a reusable cache-ordering primitive. A hit is represented
by an explicit bump: ordinary get does not change priority. A bump exchanges
an entry with its immediate predecessor; removal preserves survivor order.
This is neither exact LFU nor LRU, and the map does not manage cache capacity.
A caller can consume candidates from the back to implement its eviction policy.
use LinkedHashMap;
let mut priority = new;
for key in 1..=3
assert_eq!;
assert!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Borrowed cursors do not retain keys. Shared key links remain owned so keys need
not implement Clone unless the map itself is cloned. The current implementation
requires Rust 1.86 or newer for disjoint mutable map access.
Ordered lookup
Bisection compares the target with each stored key. Defined results must run
from Greater through Equal to Less; incomparable keys may occur only at the
edges. Search visits those excluded edges, then performs a logarithmic lower-bound
search. An incomparable interior key encountered by the search is an invariant
violation, not a missing match.
use ;
let set = from_iter;
assert_eq!;
let map = from_iter;
assert_eq!;
assert_eq!;
Unit-test implementations live under tests/unit/, included through private
conditional module declarations. Existing published versions are unchanged by
these local API and correctness updates.