aboutsummaryrefslogtreecommitdiff
path: root/src/proto/command_complete.zig
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-28 20:46:10 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-28 20:46:10 +0100
commitc00a7cd57be154b5a770a397319c8c8ad35c98b6 (patch)
tree89ef0f7bef322574883260c8952e0f3f71fa40ff /src/proto/command_complete.zig
parentd1435847fa68a548f8a2b8c61857691c6f5ac924 (diff)
downloadpgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.gz
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.bz2
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.tar.xz
pgz-c00a7cd57be154b5a770a397319c8c8ad35c98b6.zip
WIP
Diffstat (limited to 'src/proto/command_complete.zig')
-rw-r--r--src/proto/command_complete.zig7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/proto/command_complete.zig b/src/proto/command_complete.zig
index ed8e052..f9a9e26 100644
--- a/src/proto/command_complete.zig
+++ b/src/proto/command_complete.zig
@@ -30,6 +30,13 @@ pub fn deinit(self: *CommandComplete, a: std.mem.Allocator) void {
if (self.buf != null) a.free(self.buf.?);
}
+pub fn clone(self: CommandComplete, a: std.mem.Allocator) !CommandComplete {
+ var ba = ByteArrayList.init(a);
+ errdefer ba.deinit();
+ try self.write(a, ba.writer());
+ return try CommandComplete.read(a, ba.items);
+}
+
test "round trip" {
const allocator = std.testing.allocator;
var sm = CommandComplete{