Expand description
This crate offers an efficient and concurrent interning API over generic data.
Here are its main features.
- Generic: You can intern any data type that implements
HashandEq, not just strings. The interned type doesn’t even have to beSized(for examplestr), as long as you provide aSizedstorage type (such asBox<str>) that can be borrowed as the interned type. - Efficient: Each
Internedvalue contains only a 32-bit index. The correspondingArenastores each value directly in anAppendVec, plus the 32-bit index in a raw hash table (DashTable). To intern a value of typeTusing storage typeS, you can pass any type that implementsBorrow<T>andInto<S>, which allows avoiding unnecessary copies. For example, in anArena<str, Box<str>>you can intern many string types:&str,String,Box<str>,Cow<'_, str>, etc. - Concurrent: The
ArenaisSync, and allows simultaneous reads and writes. More specifically, retrieving values viaArena::lookup()andArena::lookup_ref()is always wait-free, even when a write happens concurrently! This is thanks to the underlyingAppendVecimplementation. However, only one write (usingArena::intern()) can happen at a time on a given arena, due to an exclusive write lock.
Structs§
- Arena
- Interning arena for values of type
T, storing them with the givenStoragetype (that needs to beSized). - Arena
Slice - Interning arena for slices of type
T. - Arena
Str - Interning arena for strings.
- Delta
Encoding delta - Wrapper around an
ArenaorArenaSlicethat uses the givenAccumulatorto serialize it with delta encoding. - Extend
Arena serde - Wrapper to extend an
Arenaincrementally, typically by deserializing a sequence of serializedSnapshotDiff. - Extend
Arena Slice serde - Wrapper to extend an
ArenaSliceincrementally, typically by deserializing a sequence of serializedSnapshotSliceDiff. - Extend
Arena Str serde - Wrapper to extend an
ArenaStrincrementally, typically by deserializing a sequence of serializedSnapshotStrDiff. - Forward
Mapping - A mapping to re-order items in an
Arena,ArenaSliceorArenaStr. - Interned
- A handle to an interned value in an
Arena. - Interned
Slice - A handle to an interned value in an
ArenaSlice. - Interned
Str - A handle to an interned value in an
ArenaStr. - Mapping
- A mapping to re-order items in an
Arena,ArenaSliceorArenaStr. - Retain
Builder retain - A builder to select items to retain in an
Arena. - Retain
Slice Builder retain - A builder to select items to retain in an
ArenaSlice. - Retain
StrBuilder retain - A builder to select items to retain in an
ArenaStr. - Reverse
Mapping - A mapping to re-order items in an
Arena,ArenaSliceorArenaStr. - Snapshot
- Snapshot of an
Arena. - Snapshot
Diff serde - Difference between two snapshots of an
Arena. - Snapshot
Mark - A mark indicates the position of a
Snapshotin anArena. - Snapshot
Slice - Snapshot of an
ArenaSlice. - Snapshot
Slice Diff serde - Difference between two snapshots of an
ArenaSlice. - Snapshot
Slice Mark - A mark indicates the position of a
SnapshotSlicein anArenaSlice. - Snapshot
Str - Snapshot of an
ArenaStr. - Snapshot
StrDiff serde - Difference between two snapshots of an
ArenaStr. - Snapshot
StrMark - A mark indicates the position of a
SnapshotStrin anArenaStr. - U16
- A 16-bit index (2 bytes). Contrary to
u16, this type has an alignment of 1. - U24
- A 24-bit index (3 bytes).
- U32
- A 32-bit index (4 bytes). Contrary to
u32, this type has an alignment of 1. - U40
- A 40-bit index (5 bytes).
- U48
- A 48-bit index (6 bytes).
- U56
- A 56-bit index (7 bytes).
- U64
- A 64-bit index (8 bytes). Contrary to
u64, this type has an alignment of 1.
Traits§
- Accumulator
delta - Helper trait for delta-encoding of interned values.
- Index
- Interface to index values in an arena.
Type Aliases§
- Default
Build Hasher std - The default
BuildHasherused in this crate. - Hashbrown
Build Hasher - The default
BuildHasherfrom thehashbrowncrate. - StdBuild
Hasher std - The default
BuildHasherfrom the standard library.