trying to have some base code setup:
const std = @import("std");
// Define the explicit error set
pub const ObjectStorageError = error{
FileNotFound,
AccessDenied,
OutOfMemory,
InvalidInput,
};
pub const ObjectStorage = struct {
// Explicitly specify the error set for each function pointer
putIfAbsentFn: fn (self: *ObjectStorage, name: []const u8, bytes: []const u8) ObjectStorageError!void,
listPrefixFn: fn (self: *ObjectStorage, prefix: []const u8, allocator: *std.mem.Allocator) ObjectStorageError!std.ArrayList([]const u8),
readFn: fn (self: *ObjectStorage, name: []const u8, allocator: *std.mem.Allocator) ObjectStorageError![]const u8,
pub fn putIfAbsent(self: *ObjectStorage, name: []const u8, bytes: []const u8) ObjectStorageError!void {
return self.putIfAbsentFn(self, name, bytes);
}
pub fn listPrefix(self: *ObjectStorage, prefix: []const u8, allocator: *std.mem.Allocator) ObjectStorageError!std.ArrayList([]const u8) {
return self.listPrefixFn(self, prefix, allocator);
}
pub fn read(self: *ObjectStorage, name: []const u8, allocator: *std.mem.Allocator) ObjectStorageError![]const u8 {
return self.readFn(self, name, allocator);
}
};
but keep getting the error function type cannot have an inferred error set
tried doing anyerror too, but can’t seem to get this work.