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 {...@@ -37,15 +37,15 @@ pub fn anyReadable(r: AnyReadable) AnyReadable {
37 return r;37 return r;
38}38}
3939
40pub fn fromStd(reader_ptr: anytype) AnyReadable {40pub fn fromStd(reader_ptr: *std.Io.Reader) AnyReadable {
41 const S = struct {41 const S = struct {
42 fn _read(s: *allowzero anyopaque, buffer: []u8) !usize {42 fn _read(s: *allowzero anyopaque, buffer: []u8) !usize {
43 const r: @TypeOf(reader_ptr) = @ptrCast(@alignCast(s));43 const r: @TypeOf(reader_ptr) = @ptrCast(@alignCast(s));
44 return r.read(buffer);44 return r.readSliceShort(buffer);
45 }45 }
46 };46 };
47 return .{47 return .{
48 .vtable = &.{ .read = &S._read },48 .vtable = &.{ .read = &S._read },
49 .state = @constCast(@ptrCast(reader_ptr)),49 .state = @ptrCast(@constCast(reader_ptr)),
50 };50 };
51}51}
README.md+1-1
...@@ -3,7 +3,7 @@...@@ -3,7 +3,7 @@
3![loc](https://sloc.xyz/github/nektro/zig-nio)3![loc](https://sloc.xyz/github/nektro/zig-nio)
4[![license](https://img.shields.io/github/license/nektro/zig-nio.svg)](https://github.com/nektro/zig-nio/blob/master/LICENSE)4[![license](https://img.shields.io/github/license/nektro/zig-nio.svg)](https://github.com/nektro/zig-nio/blob/master/LICENSE)
5[![nektro @ github sponsors](https://img.shields.io/badge/sponsors-nektro-purple?logo=github)](https://github.com/sponsors/nektro)5[![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/)
7[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)7[![Zigmod](https://img.shields.io/badge/Zigmod-latest-f7a41d)](https://github.com/nektro/zigmod)
88
9Nektro's IO, an alternative to `std.io`.9Nektro'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 {...@@ -58,11 +58,11 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
5858
59 /// Appends to the `std.ArrayList` contents by reading from the stream until end of stream is found.59 /// Appends to the `std.ArrayList` contents by reading from the stream until end of stream is found.
60 /// 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.60 /// 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 {
62 return readAllArrayListAligned(self, null, array_list, max_append_size);62 return readAllArrayListAligned(self, null, array_list, max_append_size);
63 }63 }
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 {
66 try array_list.ensureTotalCapacity(@min(max_append_size, 4096));66 try array_list.ensureTotalCapacity(@min(max_append_size, 4096));
67 const original_len = array_list.items.len;67 const original_len = array_list.items.len;
68 var start_index: usize = original_len;68 var start_index: usize = original_len;
...@@ -92,7 +92,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -92,7 +92,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
92 /// Caller owns returned memory.92 /// Caller owns returned memory.
93 /// If this function returns an error, the contents from the stream read so far are lost.93 /// If this function returns an error, the contents from the stream read so far are lost.
94 pub fn readAllAlloc(self: Self, allocator: std.mem.Allocator, max_size: usize) ![]u8 {94 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);
96 defer array_list.deinit();96 defer array_list.deinit();
97 try readAllArrayList(self, &array_list, max_size);97 try readAllArrayList(self, &array_list, max_size);
98 return try array_list.toOwnedSlice();98 return try array_list.toOwnedSlice();
...@@ -109,7 +109,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -109,7 +109,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
109 }109 }
110110
111 /// Returned slice is not suffixed by needle but array_list will contain it.111 /// 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 {
113 const initial_len = array_list.items.len;113 const initial_len = array_list.items.len;
114 for (0..max_size) |i| {114 for (0..max_size) |i| {
115 try array_list.append(try readByte(self));115 try array_list.append(try readByte(self));
...@@ -120,14 +120,14 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -120,14 +120,14 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
120120
121 /// Returned slice is suffixed by needle.121 /// Returned slice is suffixed by needle.
122 pub fn readUntilDelimiterAlloc(self: Self, allocator: std.mem.Allocator, needle: u8, max_size: usize) ![]u8 {122 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);
124 errdefer list.deinit();124 errdefer list.deinit();
125 _ = try readUntilDelimiterArrayList(self, &list, needle, max_size);125 _ = try readUntilDelimiterArrayList(self, &list, needle, max_size);
126 return list.toOwnedSlice();126 return list.toOwnedSlice();
127 }127 }
128128
129 pub fn readUntilDelimiterOrEofAlloc(self: Self, allocator: std.mem.Allocator, needle: u8, max_size: usize) !?[]u8 {129 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);
131 defer list.deinit();131 defer list.deinit();
132 _ = readUntilDelimiterArrayList(self, &list, needle, max_size) catch |err| switch (err) {132 _ = readUntilDelimiterArrayList(self, &list, needle, max_size) catch |err| switch (err) {
133 error.EndOfStream => return null,133 error.EndOfStream => return null,
...@@ -149,7 +149,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -149,7 +149,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
149 }149 }
150150
151 /// Returned slice is not suffixed by needle but array_list will contain it.151 /// 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 {
153 const initial_len = array_list.items.len;153 const initial_len = array_list.items.len;
154 for (0..max_size) |i| {154 for (0..max_size) |i| {
155 try array_list.append(try readByte(self));155 try array_list.append(try readByte(self));
...@@ -159,7 +159,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -159,7 +159,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
159 }159 }
160160
161 pub fn readAlloc(self: Self, allocator: std.mem.Allocator, size: usize) ![]u8 {161 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);
163 defer array_list.deinit();163 defer array_list.deinit();
164 try array_list.ensureUnusedCapacity(size);164 try array_list.ensureUnusedCapacity(size);
165 const len = try readAll(self, array_list.allocatedSlice());165 const len = try readAll(self, array_list.allocatedSlice());
...@@ -176,7 +176,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {...@@ -176,7 +176,7 @@ pub fn Readable(T: type, this_kind: enum { _var, _const, _bare }) type {
176176
177 /// Returned slice is suffixed by needle.177 /// Returned slice is suffixed by needle.
178 pub fn readUntilDelimitersAlloc(self: Self, allocator: std.mem.Allocator, needle: []const u8, max_size: usize) ![]u8 {178 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);
180 errdefer list.deinit();180 errdefer list.deinit();
181 _ = try readUntilDelimitersArrayList(self, &list, needle, max_size);181 _ = try readUntilDelimitersArrayList(self, &list, needle, max_size);
182 return list.toOwnedSlice();182 return list.toOwnedSlice();
zigmod.yml-1
...@@ -3,7 +3,6 @@ name: nio...@@ -3,7 +3,6 @@ name: nio
3main: nio.zig3main: nio.zig
4license: MPL-2.04license: MPL-2.0
5description: Nektro's IO, an alternative to std.io5description: Nektro's IO, an alternative to std.io
6min_zig_version: 0.14.0
7dependencies:6dependencies:
8 - src: git https://github.com/nektro/zig-sys-linux7 - src: git https://github.com/nektro/zig-sys-linux
9 - src: git https://github.com/nektro/zig-extras8 - src: git https://github.com/nektro/zig-extras