https://github.com/allyourcodebase/nats.c
The NATS C client library ported to the zig build system
https://github.com/allyourcodebase/nats.c
Last synced: 5 months ago
JSON representation
The NATS C client library ported to the zig build system
- Host: GitHub
- URL: https://github.com/allyourcodebase/nats.c
- Owner: allyourcodebase
- License: mit
- Created: 2024-09-16T02:51:08.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-10-15T01:29:00.000Z (over 1 year ago)
- Last Synced: 2024-11-12T15:14:05.771Z (over 1 year ago)
- Language: Zig
- Size: 15.6 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# NATS.c
This is the [NATS C client library][nats.c], packaged for [Zig](https://ziglang.org/).
## Status
This library only explicitly supports Linux, macOS, and Windows operating systems. Building for other platforms is currently untested, so your mileage may vary.
## Zig Bindings
The following projects provide Zig language bindings to the NATS.c library:
- [`epicyclic-dev/nats-client`][epicyclic-dev-bindings]
## Usage
First, update your `build.zig.zon`:
```sh
# Initialize a `zig build` project if you haven't already
zig init
# replace with the version you want to use, e.g. 3.9.3
zig fetch --save git+https://github.com/allyourcodebase/nats.c.git#
```
You can then import `nats_c` in your `build.zig` with:
```zig
const nats_c_dep = b.dependency("nats_c", .{
.target = target,
.optimize = optimize,
.@"enable-libsodium" = true, // Use libsodium for optimized implementations of some signing routines
.@"enable-tls" = true, // enable SSL/TLS support
.@"force-host-verify" = true, // force hostname verification for TLS connections
.@"enable-streaming" = true, // build with support for NATS streaming extensions
});
your_exe.linkLibrary(nats_c_dep.artifact("nats_c"));
```
## Dependencies
The NATS.c library has optional dependencies:
- [`libressl 4.0.0`][libressl] when building with `enable-tls`
- [`protobuf-c 1.5.0`][protobuf-c] when building with `enable-streaming`
- [`libsodium stable branch`][libsodium] when building with `enable-libsodium`
These dependencies are currently automatically retrieved and compiled as static libraries by the Zig build system.
## Zig Version Support Matrix
| Refname | NATS.c Version | Zig `0.14.0` | Zig `0.13.x` | Zig `0.12.x` |
|-----------|----------------|------------- |--------------|--------------|
| `3.9.3` | `3.9.3` | ✅ | ❌ | ❌ |
| `3.9.1+1` | `3.9.1` | ✅ | ❌ | ❌ |
| `3.9.1` | `3.9.1` | ❌ | ✅ | ✅ |
| `3.8.2+1` | `3.8.2` | ❌ | ✅ | ✅ |
[nats.c]: https://github.com/nats-io/nats.c
[libressl]: https://github.com/allyourcodebase/libressl
[protobuf-c]: https://github.com/allyourcodebase/protobuf-c
[libsodium]: https://github.com/jedisct1/libsodium
[epicyclic-dev-bindings]: https://github.com/epicyclic-dev/nats-client