mirror of
https://git.robbyzambito.me/zits
synced 2026-02-04 19:54:48 +00:00
Simplified a ton of things and cleaned up ownership
This commit is contained in:
@@ -104,6 +104,12 @@ pub const Message = union(MessageType) {
|
||||
reply_to: ?[]const u8 = null,
|
||||
/// The message payload data.
|
||||
payload: []const u8,
|
||||
|
||||
pub fn deinit(self: Pub, alloc: std.mem.Allocator) void {
|
||||
alloc.free(self.subject);
|
||||
alloc.free(self.payload);
|
||||
if (self.reply_to) |r| alloc.free(r);
|
||||
}
|
||||
};
|
||||
pub const Sub = struct {
|
||||
/// The subject name to subscribe to.
|
||||
@@ -112,6 +118,12 @@ pub const Message = union(MessageType) {
|
||||
queue_group: ?[]const u8,
|
||||
/// A unique alphanumeric subscription ID, generated by the client.
|
||||
sid: []const u8,
|
||||
|
||||
pub fn deinit(self: Sub, alloc: std.mem.Allocator) void {
|
||||
alloc.free(self.subject);
|
||||
alloc.free(self.sid);
|
||||
if (self.queue_group) |q| alloc.free(q);
|
||||
}
|
||||
};
|
||||
pub const Unsub = struct {
|
||||
/// The unique alphanumeric subscription ID of the subject to unsubscribe from.
|
||||
@@ -124,6 +136,22 @@ pub const Message = union(MessageType) {
|
||||
sid: []const u8,
|
||||
reply_to: ?[]const u8,
|
||||
payload: []const u8,
|
||||
|
||||
pub fn deinit(self: Msg, alloc: std.mem.Allocator) void {
|
||||
alloc.free(self.subject);
|
||||
alloc.free(self.sid);
|
||||
alloc.free(self.payload);
|
||||
if (self.reply_to) |r| alloc.free(r);
|
||||
}
|
||||
|
||||
pub fn dupe(self: Msg, alloc: std.mem.Allocator) !Msg {
|
||||
return .{
|
||||
.subject = try alloc.dupe(u8, self.subject),
|
||||
.sid = try alloc.dupe(u8, self.sid),
|
||||
.reply_to = if (self.reply_to) |r| try alloc.dupe(u8, r) else null,
|
||||
.payload = try alloc.dupe(u8, self.payload),
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const client_types = std.StaticStringMap(MessageType).initComptime(
|
||||
|
||||
Reference in New Issue
Block a user