feat: base project
This commit is contained in:
32
src/core/provider/provider.zig
Normal file
32
src/core/provider/provider.zig
Normal file
@@ -0,0 +1,32 @@
|
||||
pub const VTable = struct {
|
||||
getItemByFullName: *const fn (
|
||||
self: *anyopaque,
|
||||
fullName: FullName,
|
||||
allocator: std.mem.Allocator,
|
||||
globalAllocator: std.mem.Allocator,
|
||||
) GetItemsError!Item,
|
||||
};
|
||||
|
||||
pub const GetItemsError = error{
|
||||
OutOfMemory,
|
||||
NotExists,
|
||||
};
|
||||
|
||||
pub const Provider = struct {
|
||||
object: *anyopaque,
|
||||
vtable: *const VTable,
|
||||
|
||||
pub inline fn getItemByFullName(
|
||||
self: *const Provider,
|
||||
fullName: FullName,
|
||||
allocator: std.mem.Allocator,
|
||||
globalAllocator: std.mem.Allocator,
|
||||
) GetItemsError!Item {
|
||||
return &self.vtable.getItemByFullName(self.object, fullName, allocator, globalAllocator);
|
||||
}
|
||||
};
|
||||
|
||||
const std = @import("std");
|
||||
const models = @import("../models.zig");
|
||||
const Item = models.Item;
|
||||
const FullName = models.FullName;
|
||||
Reference in New Issue
Block a user