diff --git a/src/nats.zig b/src/nats.zig index aefd67d..edbacdf 100644 --- a/src/nats.zig +++ b/src/nats.zig @@ -114,7 +114,8 @@ pub fn sign(encoded_seed: [:0]const u8, input: [:0]const u8) Error![]const u8 { // Note: an "Inbox" is actually just a string. This API creates a random (unique) // string suitable for passing as the `reply` field to Message.create or -// Connection.publishRequest. +// Connection.publishRequest. The string is owned by the caller and should be freed +// using `destroyInbox`. pub fn createInbox() Error![:0]u8 { var self: [*c]u8 = undefined; const status = Status.fromInt(nats_c.natsInbox_Create(@ptrCast(&self))); @@ -122,12 +123,19 @@ pub fn createInbox() Error![:0]u8 { return status.toError() orelse std.mem.sliceTo(self, 0); } -pub fn destroyInbox(inbox: [:0]const u8) void { - nats_c.natsInbox_Destroy(@constCast(@ptrCast(inbox.ptr))); +pub fn destroyInbox(inbox: [:0]u8) void { + nats_c.natsInbox_Destroy(@ptrCast(inbox.ptr)); } // I think this is also a jetstream API. This function sure does not seem at all useful -// by itself. +// by itself. Note: for some reason, most of the jetstream data structures are all +// public, instead of following the opaque handle style that the rest of the library +// does. + +// typedef struct natsMsgList { +// natsMsg **Msgs; +// int Count; +// } natsMsgList; pub const MessageList = opaque { pub fn destroy(self: *MessageList) void { nats_c.natsMsgList_Destroy(@ptrCast(self));