authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 20:45:59 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-31 20:45:59 -07:00
log2a236f46f4a5831891d92469cc571b4215b3bff5
tree1c9378f2dac41f46bf9d2611440e66acfc914f94
parent72fb20a7c5f6f466ced5c3bc731864ee69bc7682
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

update to zig 0.15.2


4 files changed, 13 insertions(+), 14 deletions(-)

AnyReadable.zig+3-3
......@@ -37,15 +37,15 @@ pub fn anyReadable(r: AnyReadable) AnyReadable {
3737 return r;
3838}
3939
40pub fn fromStd(reader_ptr: anytype) AnyReadable {
40pub fn fromStd(reader_ptr: *std.Io.Reader) AnyReadable {
4141 const S = struct {
4242 fn _read(s: *allowzero anyopaque, buffer: []u8) !usize {
4343 const r: @TypeOf(reader_ptr) = @ptrCast(@alignCast(s));
44 return r.read(buffer);
44 return r.readSliceShort(buffer);
4545 }
4646 };
4747 return .{
4848 .vtable = &.{ .read = &S._read },
49 .state = @constCast(@ptrCast(reader_ptr)),
49 .state = @ptrCast(@constCast(reader_ptr)),
5050 };
5151}
README.md+1-1
......@@ -3,7 +3,7 @@
33![loc](https://sloc.xyz/github/nektro/zig-nio)
44[![license](https://img.shields.io/github/license/nektro/zig-nio.svg)](https://github.com/nektro/zig-nio/blob/master/LICENSE)
55[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)
6[![Zig](https://img.shields.io/badge/Zig-0.14-f7a41d)](https://ziglang.org/)
6[![Zig](https://img.shields.io/badge/Zig-0.15-f7a41d)](https://ziglang.org/)
77[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)
88
99Nektro's IO, an alternative to `std.io`.
nio.zig+9-9
......@@ -58,11 +58,11 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
5858
5959 /// Appends to the `std.ArrayList` contents by reading from the stream until end of stream is found.
6060 /// If the number of bytes appended would exceed `max_append_size`, `error.StreamTooLong` is returned and the `std.ArrayList` has exactly `max_append_size` bytes appended.
61 fn readAllArrayList(self: Self, array_list: *std.ArrayList(u8), max_append_size: usize) !void {
61 fn readAllArrayList(self: Self, array_list: *std.array_list.Managed(u8), max_append_size: usize) !void {
6262 return readAllArrayListAligned(self, null, array_list, max_append_size);
6363 }
6464
65 fn readAllArrayListAligned(self: Self, comptime alignment: ?u29, array_list: *std.ArrayListAligned(u8, alignment), max_append_size: usize) !void {
65 fn readAllArrayListAligned(self: Self, comptime alignment: ?std.mem.Alignment, array_list: *std.array_list.AlignedManaged(u8, alignment), max_append_size: usize) !void {
6666 try array_list.ensureTotalCapacity(@min(max_append_size, 4096));
6767 const original_len = array_list.items.len;
6868 var start_index: usize = original_len;
......@@ -92,7 +92,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
9292 /// Caller owns returned memory.
9393 /// If this function returns an error, the contents from the stream read so far are lost.
9494 pub fn readAllAlloc(self: Self, allocator: std.mem.Allocator, max_size: usize) ![]u8 {
95 var array_list = std.ArrayList(u8).init(allocator);
95 var array_list = std.array_list.Managed(u8).init(allocator);
9696 defer array_list.deinit();
9797 try readAllArrayList(self, &array_list, max_size);
9898 return try array_list.toOwnedSlice();
......@@ -109,7 +109,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
109109 }
110110
111111 /// Returned slice is not suffixed by needle but array_list will contain it.
112 pub fn readUntilDelimiterArrayList(self: Self, array_list: *std.ArrayList(u8), needle: u8, max_size: usize) ![]u8 {
112 pub fn readUntilDelimiterArrayList(self: Self, array_list: *std.array_list.Managed(u8), needle: u8, max_size: usize) ![]u8 {
113113 const initial_len = array_list.items.len;
114114 for (0..max_size) |i| {
115115 try array_list.append(try readByte(self));
......@@ -120,14 +120,14 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
120120
121121 /// Returned slice is suffixed by needle.
122122 pub fn readUntilDelimiterAlloc(self: Self, allocator: std.mem.Allocator, needle: u8, max_size: usize) ![]u8 {
123 var list: std.ArrayList(u8) = .init(allocator);
123 var list: std.array_list.Managed(u8) = .init(allocator);
124124 errdefer list.deinit();
125125 _ = try readUntilDelimiterArrayList(self, &list, needle, max_size);
126126 return list.toOwnedSlice();
127127 }
128128
129129 pub fn readUntilDelimiterOrEofAlloc(self: Self, allocator: std.mem.Allocator, needle: u8, max_size: usize) !?[]u8 {
130 var list: std.ArrayList(u8) = .init(allocator);
130 var list: std.array_list.Managed(u8) = .init(allocator);
131131 defer list.deinit();
132132 _ = readUntilDelimiterArrayList(self, &list, needle, max_size) catch |err| switch (err) {
133133 error.EndOfStream => return null,
......@@ -149,7 +149,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
149149 }
150150
151151 /// Returned slice is not suffixed by needle but array_list will contain it.
152 pub fn readUntilDelimitersArrayList(self: Self, array_list: *std.ArrayList(u8), needle: []const u8, max_size: usize) ![]u8 {
152 pub fn readUntilDelimitersArrayList(self: Self, array_list: *std.array_list.Managed(u8), needle: []const u8, max_size: usize) ![]u8 {
153153 const initial_len = array_list.items.len;
154154 for (0..max_size) |i| {
155155 try array_list.append(try readByte(self));
......@@ -159,7 +159,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
159159 }
160160
161161 pub fn readAlloc(self: Self, allocator: std.mem.Allocator, size: usize) ![]u8 {
162 var array_list = try std.ArrayList(u8).initCapacity(allocator, size);
162 var array_list = try std.array_list.Managed(u8).initCapacity(allocator, size);
163163 defer array_list.deinit();
164164 try array_list.ensureUnusedCapacity(size);
165165 const len = try readAll(self, array_list.allocatedSlice());
......@@ -176,7 +176,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
176176
177177 /// Returned slice is suffixed by needle.
178178 pub fn readUntilDelimitersAlloc(self: Self, allocator: std.mem.Allocator, needle: []const u8, max_size: usize) ![]u8 {
179 var list: std.ArrayList(u8) = .init(allocator);
179 var list: std.array_list.Managed(u8) = .init(allocator);
180180 errdefer list.deinit();
181181 _ = try readUntilDelimitersArrayList(self, &list, needle, max_size);
182182 return list.toOwnedSlice();
zigmod.yml-1
......@@ -3,7 +3,6 @@ name: nio
33main: nio.zig
44license: MPL-2.0
55description: Nektro's IO, an alternative to std.io
6min_zig_version: 0.14.0
76dependencies:
87 - src: git https://github.com/nektro/zig-sys-linux
98 - src: git https://github.com/nektro/zig-extras