mirror of
https://github.com/NotAShelf/zid.git
synced 2024-11-21 21:00:44 +00:00
CID Trie implementation in Zig
src | ||
.gitignore | ||
build.zig | ||
build.zig.zon | ||
LICENSE | ||
README.md |
Zid
Zid is a Content Identifier (CID) Trie implementation in Zig.
Features
- Trie structure for fast access to identifiers based on their byte values.
- Proper manages memory allocation and deallocation.
- Custom error types for better error reporting and handling.
Building
- Get the Zig compiler appropriate to your distribution (Generally, if you are
sane,
nix-shell -p zig
) will do the trick.) - Clone the project
zig build
orzig build-exe src/main.zig
(former is recommended, but doesn't matter)
Usage
Caution
Zid, for the time being, should be considered highly unstable and must be avoided in actual projects, unless you know what you are doing.
Adding Identifiers
To add an identifier to the trie, use the add
method. Pass the identifier as a
byte slice (i.e. []u8
):
try trie.add("your_identifier_here");
Searching for Identifiers
To search for an identifier in the trie, use the lookup method. Again, pass the identifier as a byte slice:
const result = try trie.lookup("identifier_to_search");
FAQ
What the hell is a CID?
See IPFS docs. My interpretation of a CID Trie is a tree-like data structure used for efficiently storing and retrieving identifiers, with efficiency being the primary goal.
Why doesn't this build?
It's my first time building a Zig project. Call it a minor friction.
TODO
- Support for Multiple Tries
- Batch Operations
- Dynamic MaxCIDLen (it's currently a runtime constant)
- Persistence Layer
- Concurrency