CID Trie implementation in Zig
Find a file
2024-05-21 12:55:45 +03:00
src Initial commit 2024-05-21 12:55:45 +03:00
.gitignore Initial commit 2024-05-21 12:55:45 +03:00
build.zig Initial commit 2024-05-21 12:55:45 +03:00
build.zig.zon Initial commit 2024-05-21 12:55:45 +03:00
LICENSE Initial commit 2024-05-21 12:55:45 +03:00
README.md Initial commit 2024-05-21 12:55:45 +03:00

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

  1. Get the Zig compiler appropriate to your distribution (Generally, if you are sane, nix-shell -p zig) will do the trick.)
  2. Clone the project
  3. zig build or zig 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