aboutsummaryrefslogtreecommitdiff
path: root/src/password_message.zig
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-23 15:18:38 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-23 15:18:38 +0100
commit5a91b37ee7dd36db52dfde1727b780ec3fa4c67d (patch)
treed17a1a8449ecd48fcf67f93edf7ba16c99974e6a /src/password_message.zig
parentc3c45287396569a96107c9b1413ac181f7197a6e (diff)
downloadpgz-5a91b37ee7dd36db52dfde1727b780ec3fa4c67d.tar.gz
pgz-5a91b37ee7dd36db52dfde1727b780ec3fa4c67d.tar.bz2
pgz-5a91b37ee7dd36db52dfde1727b780ec3fa4c67d.tar.xz
pgz-5a91b37ee7dd36db52dfde1727b780ec3fa4c67d.zip
Add error_response
Start adding connection abstraction
Diffstat (limited to 'src/password_message.zig')
-rw-r--r--src/password_message.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/password_message.zig b/src/password_message.zig
index 33214bf..1a8c17a 100644
--- a/src/password_message.zig
+++ b/src/password_message.zig
@@ -6,16 +6,17 @@ pub const Tag: u8 = 'p';
password: []const u8,
password_owned: bool = false,
-
pub fn read(allocator: std.mem.Allocator, b: []const u8) !PasswordMessage {
return .{ .password = try allocator.dupe(u8, b), .password_owned = true };
}
+
pub fn write(self: PasswordMessage, _: std.mem.Allocator, stream_writer: anytype) !void {
try stream_writer.writeByte(Tag);
try stream_writer.writeIntBig(u32, 5 + @as(u32, @intCast(self.password.len)));
try stream_writer.writeAll(self.password);
try stream_writer.writeByte(0);
}
+
pub fn deinit(self: *PasswordMessage, allocator: std.mem.Allocator) void {
if (self.password_owned) allocator.free(self.password);
}