fixup! tests: add top level function tests

This commit is contained in:
torque 2023-08-27 18:04:21 -07:00
parent 64c1a1604d
commit dc97e44c9e
Signed by: torque
SSH Key Fingerprint: SHA256:nCrXefBNo6EbjNSQhv0nXmEg/VuNq3sMF5b8zETw3Tk

View File

@ -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));