aboutsummaryrefslogtreecommitdiff
path: root/src/proto/authentication_request.zig
diff options
context:
space:
mode:
authorMartin Ashby <martin@ashbysoft.com>2023-09-27 23:34:46 +0100
committerMartin Ashby <martin@ashbysoft.com>2023-09-27 23:34:46 +0100
commit747c6e55cbe2283fd85ef8cd930e88d2bb0b7db2 (patch)
tree7115e12e19f684640bd2aad4e5d998e13bbb5484 /src/proto/authentication_request.zig
parent08472c27c77d27ea084e3458842540351c5a5c28 (diff)
downloadpgz-747c6e55cbe2283fd85ef8cd930e88d2bb0b7db2.tar.gz
pgz-747c6e55cbe2283fd85ef8cd930e88d2bb0b7db2.tar.bz2
pgz-747c6e55cbe2283fd85ef8cd930e88d2bb0b7db2.tar.xz
pgz-747c6e55cbe2283fd85ef8cd930e88d2bb0b7db2.zip
Add a tagged union for all backend messages.
Move read_message to proto.zig and make it return the tagged union rather than expecting a message type.
Diffstat (limited to 'src/proto/authentication_request.zig')
-rw-r--r--src/proto/authentication_request.zig6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/proto/authentication_request.zig b/src/proto/authentication_request.zig
index 9203482..3ea5cd1 100644
--- a/src/proto/authentication_request.zig
+++ b/src/proto/authentication_request.zig
@@ -30,7 +30,11 @@ pub fn read(_: std.mem.Allocator, b: []const u8) !AuthenticationRequest {
log.err("invalid message length, expected 4 got {}", .{b.len});
return ProtocolError.InvalidMessageLength;
}
- const inner_type = enum_from_int(InnerAuthRequestType, std.mem.readIntBig(u32, b[0..4])) orelse return ClientError.UnsupportedAuthType;
+ const auth_type_int = std.mem.readIntBig(u32, b[0..4]);
+ const inner_type = enum_from_int(InnerAuthRequestType, auth_type_int) orelse {
+ log.err("Unsupported auth type {}", .{auth_type_int});
+ return ClientError.UnsupportedAuthType;
+ };
var inner: InnerAuthRequest = switch (inner_type) {
.AuthRequestTypeOk => .{ .ok = AuthRequestOk{} },
.AuthRequestTypeCleartextPassword => .{ .cleartext_password = AuthRequestCleartextPassword{} },