summaryrefslogtreecommitdiff
path: root/src/lua_bridge.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/lua_bridge.zig')
-rw-r--r--src/lua_bridge.zig10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/lua_bridge.zig b/src/lua_bridge.zig
index 245b0ec..444cedc 100644
--- a/src/lua_bridge.zig
+++ b/src/lua_bridge.zig
@@ -270,7 +270,7 @@ pub fn pushJsonAsLua(
/// one `.media` part per attachment (`data` is base64-encoded bytes).
///
/// Every returned slice/part owns its bytes (allocated with `allocator`);
-/// the caller frees via `panto.freeResultParts`.
+/// the caller frees via `panto.ResultParts.deinit`.
pub fn readHandlerResult(
L: *c.lua_State,
idx: c_int,
@@ -281,8 +281,8 @@ pub fn readHandlerResult(
var len: usize = 0;
const ptr = c.lua_tolstring(L, idx, &len);
if (ptr == null) return BridgeError.BadHandlerReturn;
- return (panto.textResult(allocator, ptr[0..len]) catch
- BridgeError.OutOfMemory);
+ return ((panto.ResultParts.fromText(allocator, ptr[0..len]) catch
+ return BridgeError.OutOfMemory).items);
}
if (ty != T_TABLE) return BridgeError.BadHandlerReturn;
return readHandlerResultTable(L, idx, allocator);
@@ -796,7 +796,7 @@ test "handler invocation: input parsed, result captured" {
}
const result = try readHandlerResult(L, -1, std.testing.allocator);
- defer panto.freeResultParts(std.testing.allocator, result);
+ defer (panto.ResultParts{ .items = result }).deinit(std.testing.allocator);
try std.testing.expectEqual(@as(usize, 1), result.len);
try std.testing.expectEqualStrings("got: hello", result[0].text);
}
@@ -821,7 +821,7 @@ test "readHandlerResult: table with text and attachments" {
}
const result = try readHandlerResult(L, -1, std.testing.allocator);
- defer panto.freeResultParts(std.testing.allocator, result);
+ defer (panto.ResultParts{ .items = result }).deinit(std.testing.allocator);
try std.testing.expectEqual(@as(usize, 3), result.len);
try std.testing.expectEqualStrings("see image", result[0].text);
try std.testing.expectEqualStrings("image/png", result[1].media.media_type.?);