authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 03:25:55 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-05-22 03:25:55 -07:00
log3e18f16a27faad6344444685124d7a25c512b56b
tree6bd29fafe31d2c687d5ba25a7f0b7d3d433a3dd7
parent784588b650abfc429124538b910bd0975ce09fe3
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

eliminate usingnamespace


7 files changed, 95 insertions(+), 8 deletions(-)

AnyReadable.zig+15-1
......@@ -8,9 +8,23 @@ vtable: *const struct {
88},
99state: *allowzero anyopaque,
1010
11const R = nio.Readable(@This(), ._const);
12pub const readAll = R.readAll;
13pub const readAtLeast = R.readAtLeast;
14pub const readNoEof = R.readNoEof;
15pub const readAllAlloc = R.readAllAlloc;
16pub const readArray = R.readArray;
17pub const readByte = R.readByte;
18pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList;
19pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc;
20pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf;
21pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList;
22pub const readAlloc = R.readAlloc;
23pub const readInt = R.readInt;
24pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
25
1126pub const Error = ReadError; // std compat
1227pub const ReadError = anyerror;
13pub usingnamespace nio.Readable(@This(), ._const);
1428pub fn read(r: AnyReadable, buffer: []u8) !usize {
1529 return r.vtable.read(r.state, buffer);
1630}
AnyWritable.zig+10-1
......@@ -15,8 +15,17 @@ vtable: *const struct {
1515},
1616state: *allowzero anyopaque,
1717
18const W = nio.Writable(@This(), ._const);
19pub const writeAll = W.writeAll;
20pub const writevAll = W.writevAll;
21pub const writeByteNTimes = W.writeByteNTimes;
22pub const writeNTimes = W.writeNTimes;
23pub const writeInt = W.writeInt;
24pub const writeStruct = W.writeStruct;
25pub const writeIntPretty = W.writeIntPretty;
26pub const print = W.print;
27
1828pub const WriteError = anyerror;
19pub usingnamespace nio.Writable(@This(), ._const);
2029pub fn write(r: AnyWritable, buffer: []const u8) !usize {
2130 return r.vtable.write(r.state, buffer);
2231}
buffered_reader.zig+15-1
......@@ -19,8 +19,22 @@ pub fn BufferedReader(comptime buffer_size: usize, comptime ReaderType: type) ty
1919 };
2020 }
2121
22 const R = nio.Readable(@This(), ._var);
23 pub const readAll = R.readAll;
24 pub const readAtLeast = R.readAtLeast;
25 pub const readNoEof = R.readNoEof;
26 pub const readAllAlloc = R.readAllAlloc;
27 pub const readArray = R.readArray;
28 pub const readByte = R.readByte;
29 pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList;
30 pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc;
31 pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf;
32 pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList;
33 pub const readAlloc = R.readAlloc;
34 pub const readInt = R.readInt;
35 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
36
2237 pub const ReadError = ReaderType.ReadError;
23 pub usingnamespace nio.Readable(@This(), ._var);
2438 pub fn read(self: *Self, dest: []u8) ReadError!usize {
2539 // First try reading from the already buffered data onto the destination.
2640 const current = self.buf[self.start..self.end];
buffered_writer.zig+10-1
......@@ -25,8 +25,17 @@ pub fn BufferedWriter(comptime buffer_size: usize, comptime WriterType: type) ty
2525 };
2626 }
2727
28 const W = nio.Writable(@This(), ._var);
29 pub const writeAll = W.writeAll;
30 pub const writevAll = W.writevAll;
31 pub const writeByteNTimes = W.writeByteNTimes;
32 pub const writeNTimes = W.writeNTimes;
33 pub const writeInt = W.writeInt;
34 pub const writeStruct = W.writeStruct;
35 pub const writeIntPretty = W.writeIntPretty;
36 pub const print = W.print;
37
2838 pub const WriteError = extras.Pointee(WriterType).WriteError;
29 pub usingnamespace nio.Writable(@This(), ._var);
3039 pub fn write(self: *Self, bytes: []const u8) WriteError!usize {
3140 if (self.end + bytes.len > self.buf.len) {
3241 try self.flush();
counting_writer.zig+10-1
......@@ -16,8 +16,17 @@ pub fn CountingWriter(WriterType: type) type {
1616 };
1717 }
1818
19 const W = nio.Writable(@This(), ._var);
20 pub const writeAll = W.writeAll;
21 pub const writevAll = W.writevAll;
22 pub const writeByteNTimes = W.writeByteNTimes;
23 pub const writeNTimes = W.writeNTimes;
24 pub const writeInt = W.writeInt;
25 pub const writeStruct = W.writeStruct;
26 pub const writeIntPretty = W.writeIntPretty;
27 pub const print = W.print;
28
1929 pub const WriteError = extras.Pointee(WriterType).WriteError;
20 pub usingnamespace nio.Writable(@This(), ._var);
2130 pub fn write(self: *Self, bytes: []const u8) WriteError!usize {
2231 const len = try self.backing_writer.write(bytes);
2332 self.bytes_written += len;
fixed_buffer_stream.zig+25-2
......@@ -27,8 +27,22 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
2727 };
2828 }
2929
30 const R = nio.Readable(@This(), ._var);
31 pub const readAll = R.readAll;
32 pub const readAtLeast = R.readAtLeast;
33 pub const readNoEof = R.readNoEof;
34 pub const readAllAlloc = R.readAllAlloc;
35 pub const readArray = R.readArray;
36 pub const readByte = R.readByte;
37 pub const readUntilDelimiterArrayList = R.readUntilDelimiterArrayList;
38 pub const readUntilDelimiterAlloc = R.readUntilDelimiterAlloc;
39 pub const readUntilDelimitersBuf = R.readUntilDelimitersBuf;
40 pub const readUntilDelimitersArrayList = R.readUntilDelimitersArrayList;
41 pub const readAlloc = R.readAlloc;
42 pub const readInt = R.readInt;
43 pub const readUntilDelimitersAlloc = R.readUntilDelimitersAlloc;
44
3045 pub const ReadError = error{};
31 pub usingnamespace nio.Readable(@This(), ._var);
3246 pub fn read(self: *Self, dest: []u8) ReadError!usize {
3347 const size = @min(dest.len, self.buffer.len - self.pos);
3448 const end = self.pos + size;
......@@ -50,8 +64,17 @@ pub fn FixedBufferStream(comptime Buffer: type) type {
5064 };
5165 }
5266
67 const W = nio.Writable(@This(), ._var);
68 pub const writeAll = W.writeAll;
69 pub const writevAll = W.writevAll;
70 pub const writeByteNTimes = W.writeByteNTimes;
71 pub const writeNTimes = W.writeNTimes;
72 pub const writeInt = W.writeInt;
73 pub const writeStruct = W.writeStruct;
74 pub const writeIntPretty = W.writeIntPretty;
75 pub const print = W.print;
76
5377 pub const WriteError = error{NoSpaceLeft};
54 pub usingnamespace nio.Writable(@This(), ._var);
5578 /// If the returned number of bytes written is less than requested, the buffer is full.
5679 /// Returns `error.NoSpaceLeft` when no bytes would be written.
5780 pub fn write(self: *Self, bytes: []const u8) WriteError!usize {
null_writer.zig+10-1
......@@ -3,8 +3,17 @@ const extras = @import("extras");
33const nio = @import("./nio.zig");
44
55pub const NullWriter = struct {
6 const W = nio.Writable(@This(), ._var);
7 pub const writeAll = W.writeAll;
8 pub const writevAll = W.writevAll;
9 pub const writeByteNTimes = W.writeByteNTimes;
10 pub const writeNTimes = W.writeNTimes;
11 pub const writeInt = W.writeInt;
12 pub const writeStruct = W.writeStruct;
13 pub const writeIntPretty = W.writeIntPretty;
14 pub const print = W.print;
15
616 pub const WriteError = error{};
7 pub usingnamespace nio.Writable(@This(), ._var);
817 pub fn write(self: NullWriter, bytes: []const u8) WriteError!usize {
918 _ = self;
1019 return bytes.len;