tiny.sql.LazyHistory
Defined in lifecycle.
API (11)
Actions
Public operations.
Fields and members
Public fields and members.
Source
Source: lib/sql/src/lifecycle.zig:162
zig
pub const LazyHistory = struct { allocator: Allocator, io: std.Io, dir: std.Io.Dir, path: []u8, state: State, retired: ?history_mod.refs.Snapshot = null, read_only: bool = false, const State = union(enum) { deferred: history_mod.refs.Snapshot, open: history_mod.History, }; pub fn full(self: *LazyHistory) Error!*history_mod.History { switch (self.state) { .open => {}, .deferred => |snapshot| { std.debug.assert(self.retired == null); const opened = try history_mod.History.open(self.allocator, self.dir, .{ .io = self.io, .path = self.path, .recovery = .reject, .create = !self.read_only, .read_only = self.read_only, }); self.retired = snapshot; self.state = .{ .open = opened }; }, } return &self.state.open; } pub fn replayed(self: *const LazyHistory) bool { return self.state == .open; } pub fn checkoutBranch(self: *const LazyHistory, name: []const u8) Error!branch.Checkout { return switch (self.state) { .open => |*history| try history.checkoutBranch(name), .deferred => |*snapshot| checkout: { const entry = snapshot.find(name) orelse return error.RefNotFound; break :checkout branch.Checkout.init( .{ .name = entry.name, .target = entry.head }, entry.root, ); }, }; } pub fn deinit(self: *LazyHistory) void { switch (self.state) { .open => |*history| history.deinit(), .deferred => |*snapshot| snapshot.deinit(), } if (self.retired) |*snapshot| snapshot.deinit(); self.dir.close(self.io); self.allocator.free(self.path); self.* = undefined; }};Source: lib/sql/src/root.zig:101
zig
pub const LazyHistory = lifecycle.LazyHistory;Audit
| Definitions | 5 |
|---|---|
| Public names | 10 |
| Members | 7 |
| Version | 26.7.0 |
| Revision | daab053ee433 |