treesummaryrefslogcommitdiff
path: root/src/db.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.zig')
-rw-r--r--src/db.zig15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/db.zig b/src/db.zig
index 6279a1b..8bf2f7f 100644
--- a/src/db.zig
+++ b/src/db.zig
@@ -76,6 +76,7 @@ pub fn Set(comptime K: type) type {
idx: ?Index = null,
const Self = @This();
+ pub const Key = K;
pub const Index = u64;
pub const View = SetView(K);
@@ -186,7 +187,7 @@ pub fn SetView(comptime K: type) type {
pub fn clear(self: *Self) !void {
var it = self.iterator();
while (it.next()) |i| {
- try self.del(i);
+ try self.del(i.key);
}
}
pub fn has(self: Self, k: K) !bool {
@@ -200,7 +201,7 @@ pub fn SetView(comptime K: type) type {
idx: ?K,
dir: enum { Forward, Backward },
- pub fn next(self: *Iterator) ?K {
+ pub fn next(self: *Iterator) ?struct { key: K } {
if (self.idx != null) {
const k = self.idx.?;
const item = self.sv.item_get(k) catch return null;
@@ -208,7 +209,7 @@ pub fn SetView(comptime K: type) type {
.Forward => item.next,
.Backward => item.prev,
};
- return k;
+ return .{ .key = k };
} else {
return null;
}
@@ -236,6 +237,8 @@ pub fn List(comptime V: type) type {
const Self = @This();
pub const Index = u64;
+ pub const Key = u64;
+ pub const Val = V;
pub const View = ListView(V);
fn open_dbi(txn: lmdb.Txn) !lmdb.Dbi {
@@ -410,12 +413,14 @@ pub fn ListView(comptime V: type) type {
pub fn SetList(comptime K: type, comptime V: type) type {
return struct {
- idx: ?Index = null,
-
const Self = @This();
pub const Index = u64;
+ pub const Key = K;
+ pub const Val = V;
pub const View = SetListView(K, V);
+ idx: ?Index = null,
+
fn open_dbi(txn: lmdb.Txn) !lmdb.Dbi {
return try txn.dbi("SetList");
}