File tree Expand file tree Collapse file tree 1 file changed +36
-1
lines changed
Expand file tree Collapse file tree 1 file changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -16,8 +16,43 @@ time. It supports:
1616
1717## Install
1818
19+ Add or update this library as a dependency in your zig project run the following command:
20+
21+ ``` sh
22+ zig fetch --save git+https://github.com/nilslice/zig-interface
23+ ```
24+
25+ Afterwards add the library as a dependency to any module in your _ build.zig_ :
26+
27+ ``` zig
28+ // ...
29+ const interface_dependency = b.dependency("interface", .{
30+ .target = target,
31+ .optimize = optimize,
32+ });
33+
34+ const exe = b.addExecutable(.{
35+ .name = "main",
36+ .root_source_file = b.path("src/main.zig"),
37+ .target = target,
38+ .optimize = optimize,
39+ });
40+ // import the exposed `interface` module from the dependency
41+ exe.root_module.addImport("interface", interface_dependency.module("interface"));
42+ // ...
1943```
20- TODO
44+
45+ In the end you can import the ` interface ` module. For example:
46+
47+ ``` zig
48+ const Interface = @import("interface").Interface;
49+
50+ const Repository = Interface(.{
51+ .create = fn(anytype, User) anyerror!u32,
52+ .findById = fn(anytype, u32) anyerror!?User,
53+ .update = fn(anytype, User) anyerror!void,
54+ .delete = fn(anytype, u32) anyerror!void,
55+ }, null);
2156```
2257
2358## Usage
You can’t perform that action at this time.
0 commit comments