| Crates.io | sqlite-collections |
| lib.rs | sqlite-collections |
| version | 0.1.0 |
| created_at | 2023-11-25 22:37:32.127519+00 |
| updated_at | 2023-12-09 15:22:26.348531+00 |
| description | Rust collection types backed by sqlite database files. |
| homepage | |
| repository | https://codeberg.org/Taywee/sqlite-collections |
| max_upload_size | |
| id | 1048617 |
| size | 151,851 |
Rust collection types backed by sqlite database files.
This provides some standard-library-like collections, which may be serialized
and deserialized with arbitrary serializers. This allows you to use an
interface very similar to the std::collections ones, with these
characteristics:
serde to load and dump the whole
thing.ds::set::DSSet and ds::map::DSMap types depend on deterministic
serialization. You aren't prevented from storing whatever is serializable in a
Set, for instance, but keep in mind:
cbor feature) does not support half-precision floating point
yet, so it being added would break determinism in the future.
To be safe, make sure you do not update your serializers without some thorough
testing. Direct is always safe. postmark is probably the most reliable
serde format you can use, keeping in mind to not depend on types that use
the Hash trait to determine ordering unless you can ensure a consistent order
separately. cbor and json are useful for inter-language use, but keep in
mind the caveats, and make sure that other languages serialize the exact same
way.
In the future, a BTreeSet and BTreeMap will be added to support non-
deterministic encodings. These will be slower, but will be guaranteed to match
just based on Ord and Eq alone. This will not solve platform portability
problems, but will solve deterministic serialization concerns.
Your collections might be open in a different thread or process through another connection. SAVEPOINT is used internally to prevent inconsistent states.
This library uses internal SAVEPOINTs to prevent inconsistent states of the database. To get the most performance without sacrificing reliability:
journal_mode = WAL with synchronized = NORMAL
can give some performance gains when there is a lot of writing.Ord is
implemented. Should be quite a lot slower than a normal Set, as every
comparison requires a full deserialization.Vec because it's not really an array and is not
accessible as a contiguous slice.Yes. This is mostly to make it easy to efficiently interact with a SQLite-
backed collection without having to think too hard about the SQL details, as
well as making it not-too-painful to swap out an existing std::collections
struct and keep the same functionality, when you need persistence and/or huge
data without filling your RAM.
If you really just want a large, persistent, and/or transaction-safe set of collections and don't need any other RDBMS functionality, this library is a good choice.