diff options
Diffstat (limited to 'src/password_message.zig')
-rw-r--r-- | src/password_message.zig | 3 |
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); } |