https://github.com/notashelf/zid
CID Trie implementation in Zig
https://github.com/notashelf/zid
Last synced: about 1 year ago
JSON representation
CID Trie implementation in Zig
- Host: GitHub
- URL: https://github.com/notashelf/zid
- Owner: NotAShelf
- License: bsd-3-clause
- Created: 2024-05-21T09:54:41.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-21T09:55:53.000Z (about 2 years ago)
- Last Synced: 2025-05-11T15:46:18.599Z (about 1 year ago)
- Language: Zig
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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`):
```zig
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:
```zig
const result = try trie.lookup("identifier_to_search");
```
## FAQ
[IPFS docs]: https://docs.ipfs.tech/concepts/content-addressing/#what-is-a-cid
### 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