This commit is contained in:
2025-12-29 00:35:06 +00:00
parent 18f4475aaf
commit 335c4aa092
3 changed files with 43 additions and 20 deletions

View File

@@ -13,7 +13,6 @@ pub const MessageType = enum {
pong,
@"+ok",
@"-err",
eos,
fn parseMemEql(input: []const u8) ?MessageType {
// if (std.mem.eql(u8, "INFO", input)) return .info;
@@ -45,9 +44,6 @@ pub const Message = union(MessageType) {
pong,
@"+ok": void,
@"-err": void,
// Not an actual NATS message, but used to signal end of stream was reached in the input,
// and we should close the reader.
eos: void,
pub const ServerInfo = struct {
/// The unique identifier of the NATS server.
server_id: []const u8,
@@ -176,14 +172,7 @@ pub const Message = union(MessageType) {
try operation_string.appendBounded(byte);
try in.discardAll(1);
} else break;
} else |err| switch (err) {
error.EndOfStream => {
return .{ .eos = {} };
},
else => {
return err;
},
}
} else |err| return err;
const operation = parse(operation_string.items) orelse {
return error.InvalidOperation;