lib/accy/src/kernel/library/catalog/artifact/model.zig

daab053ee43316e1809a84551d573ddd1e5bf3d2

 1 const std = @import("std");
 2 
 3 const artifact_product = @import("../../../../artifact/model/root.zig");
 4 const kernel = @import("../../../root.zig");
 5 
 6 pub const OwnedKernelCallArtifactRegistry = struct {
 7     allocator: std.mem.Allocator,
 8     artifacts: []kernel.OwnedKernelCallArtifact = &.{},
 9     entries: []artifact_product.KernelCallArtifact = &.{},
10     index: artifact_product.KernelCallRegistryIndex = .{},
11 
12     pub fn registry(self: *const OwnedKernelCallArtifactRegistry) artifact_product.KernelCallRegistry {
13         return .{
14             .entries = self.entries,
15             .index = self.index,
16         };
17     }
18 
19     pub fn deinit(self: *OwnedKernelCallArtifactRegistry) void {
20         artifact_product.deinitKernelCallRegistryIndex(self.allocator, self.index);
21         for (self.artifacts) |*artifact| artifact.deinit();
22         if (self.artifacts.len != 0) self.allocator.free(self.artifacts);
23         if (self.entries.len != 0) self.allocator.free(self.entries);
24         self.* = undefined;
25     }
26 };
27 
28 pub const OwnedKernelCallPipelinePackage = struct {
29     allocator: std.mem.Allocator,
30     artifacts: []kernel.OwnedKernelCallArtifact = &.{},
31     entries: []artifact_product.KernelCallArtifact = &.{},
32     index: artifact_product.KernelCallRegistryIndex = .{},
33     pipeline: artifact_product.OwnedKernelCallPipeline,
34 
35     pub fn registry(self: *const OwnedKernelCallPipelinePackage) artifact_product.KernelCallRegistry {
36         return .{
37             .entries = self.entries,
38             .index = self.index,
39         };
40     }
41 
42     pub fn deinit(self: *OwnedKernelCallPipelinePackage) void {
43         artifact_product.deinitKernelCallRegistryIndex(self.allocator, self.index);
44         for (self.artifacts) |*artifact| artifact.deinit();
45         if (self.artifacts.len != 0) self.allocator.free(self.artifacts);
46         if (self.entries.len != 0) self.allocator.free(self.entries);
47         self.pipeline.deinit();
48         self.* = undefined;
49     }
50 };