From dff4234bf2d957a0328ff4f3dc4f9bba1fbeffd4 Mon Sep 17 00:00:00 2001 From: Martin Ashby Date: Sat, 11 Nov 2023 11:36:26 +0000 Subject: Extend meta info file parsing --- src/bencode.zig | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/bencode.zig') diff --git a/src/bencode.zig b/src/bencode.zig index d09f394..60a3746 100644 --- a/src/bencode.zig +++ b/src/bencode.zig @@ -93,6 +93,13 @@ pub const BValue = union(enum) { else => return error.WrongType, } } + + pub fn asList(self: BValue) !std.ArrayList(BValue) { + switch (self) { + .list => |l| return l, + else => return error.WrongType, + } + } }; pub fn bdecodeBuf(a: std.mem.Allocator, buf: []const u8) !BValue { -- cgit v1.2.3-ZIG