https://github.com/braheezy/ada-zig
Zig bindings for Ada URL library.
https://github.com/braheezy/ada-zig
zig
Last synced: 5 months ago
JSON representation
Zig bindings for Ada URL library.
- Host: GitHub
- URL: https://github.com/braheezy/ada-zig
- Owner: braheezy
- Created: 2024-12-30T05:30:29.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-12T05:26:50.000Z (over 1 year ago)
- Last Synced: 2025-02-12T06:40:07.447Z (over 1 year ago)
- Topics: zig
- Language: Zig
- Homepage: https://braheezy.github.io/ada-zig/
- Size: 2.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Ada-Zig
[](https://braheezy.github.io/ada-zig)
[Ada](https://github.com/ada-url/ada) is a fast and spec-compliant URL parser written in C++. Specification for URL parser can be found from the WHATWG website.
This project contains Zig language bindings. That means instead of linking the C library directly in your project and interacting with the C API, `zig-ada` does it for you, providing a thin wrapper for familiar Zig use.
## Usage
First, add to your `build.zig.zon`:
```bash
zig fetch --save git+https://github.com/braheezy/ada-zig#2.9.2
```
Then update your `build.zig`:
```zig
const ada_dep = b.dependency("ada-zig", .{});
exe.root_module.addImport("ada", ada_dep.module("ada"));
```
Finally, in your source code:
```zig
const ada = @import("ada");
pub fn main() void {
const ada_url = try ada.Url.init("https://ziglang.org/");
std.debug.print(ada_url.getProtocol());
// prints 'https'
}
```
## Examples
The [Usage docs](https://github.com/ada-url/ada/tree/main?tab=readme-ov-file#usage) from the Ada library are applicable.
```zig
const std = @import("std");
const ada = @import("ada");
pub fn main() !void {
const input_url = "https://user:pass@127.0.0.1:8080/path?query=1#frag";
const url = try ada.Url.init(input_url);
defer url.free();
std.debug.print("url.host type: {any}\n", .{url.getHostType()});
}
```
## Development
See `zig build --list`.