@@ -3,8 +3,7 @@ const native_endian = @import("builtin").target.cpu.arch.endian();
33const mem = std .mem ;
44const assert = std .debug .assert ;
55
6- const zimpl = @import ("zimpl" );
7- const Impl = zimpl .Impl ;
6+ const Impl = @import ("zimpl" ).Impl ;
87
98pub const FixedBufferReader = @import ("io/FixedBufferReader.zig" );
109pub const FixedBufferStream = @import ("io/FixedBufferStream.zig" );
@@ -32,23 +31,23 @@ pub fn Reader(comptime T: type) type {
3231
3332pub inline fn read (
3433 reader_ctx : anytype ,
35- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
34+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
3635 buffer : []u8 ,
3736) reader_impl .ReadError ! usize {
3837 return @errorCast (reader_impl .read (reader_ctx , buffer ));
3938}
4039
4140pub inline fn readAll (
4241 reader_ctx : anytype ,
43- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
42+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
4443 buffer : []u8 ,
4544) reader_impl .ReadError ! usize {
4645 return readAtLeast (reader_ctx , reader_impl , buffer , buffer .len );
4746}
4847
4948pub inline fn readAtLeast (
5049 reader_ctx : anytype ,
51- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
50+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
5251 buffer : []u8 ,
5352 len : usize ,
5453) reader_impl .ReadError ! usize {
@@ -64,7 +63,7 @@ pub inline fn readAtLeast(
6463
6564pub inline fn readNoEof (
6665 reader_ctx : anytype ,
67- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
66+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
6867 buf : []u8 ,
6968) (reader_impl .ReadError || error {EndOfStream })! void {
7069 const amt_read = try readAll (reader_ctx , reader_impl , buf );
@@ -73,9 +72,9 @@ pub inline fn readNoEof(
7372
7473pub inline fn streamUntilDelimiter (
7574 reader_ctx : anytype ,
76- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
75+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
7776 writer_ctx : anytype ,
78- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
77+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
7978 delimiter : u8 ,
8079 optional_max_size : ? usize ,
8180) (reader_impl .ReadError || writer_impl .WriteError || error {
@@ -102,7 +101,7 @@ pub inline fn streamUntilDelimiter(
102101
103102pub inline fn skipUntilDelimiterOrEof (
104103 reader_ctx : anytype ,
105- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
104+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
106105 delimiter : u8 ,
107106) reader_impl .ReadError ! void {
108107 while (true ) {
@@ -116,7 +115,7 @@ pub inline fn skipUntilDelimiterOrEof(
116115
117116pub inline fn readByte (
118117 reader_ctx : anytype ,
119- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
118+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
120119) (reader_impl .ReadError || error {EndOfStream })! u8 {
121120 var result : [1 ]u8 = undefined ;
122121 const amt_read = try read (reader_ctx , reader_impl , result [0.. ]);
@@ -126,14 +125,14 @@ pub inline fn readByte(
126125
127126pub inline fn readByteSigned (
128127 reader_ctx : anytype ,
129- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
128+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
130129) (reader_impl .ReadError || error {EndOfStream })! i8 {
131130 return @as (i8 , @bitCast (try readByte (reader_ctx , reader_impl )));
132131}
133132
134133pub inline fn readBytesNoEof (
135134 reader_ctx : anytype ,
136- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
135+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
137136 comptime num_bytes : usize ,
138137) (reader_impl .ReadError || error {EndOfStream })! [num_bytes ]u8 {
139138 var bytes : [num_bytes ]u8 = undefined ;
@@ -143,7 +142,7 @@ pub inline fn readBytesNoEof(
143142
144143pub inline fn readInt (
145144 reader_ctx : anytype ,
146- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
145+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
147146 comptime T : type ,
148147 endian : std.builtin.Endian ,
149148) (reader_impl .ReadError || error {EndOfStream })! T {
@@ -157,7 +156,7 @@ pub inline fn readInt(
157156
158157pub inline fn readVarInt (
159158 reader_ctx : anytype ,
160- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
159+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
161160 comptime ReturnType : type ,
162161 endian : std.builtin.Endian ,
163162 size : usize ,
@@ -171,7 +170,7 @@ pub inline fn readVarInt(
171170
172171pub inline fn skipBytes (
173172 reader_ctx : anytype ,
174- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
173+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
175174 num_bytes : u64 ,
176175 comptime options : struct {
177176 buf_size : usize = 512 ,
@@ -189,7 +188,7 @@ pub inline fn skipBytes(
189188
190189pub inline fn isBytes (
191190 reader_ctx : anytype ,
192- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
191+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
193192 slice : []const u8 ,
194193) (reader_impl .ReadError || error {EndOfStream })! bool {
195194 var i : usize = 0 ;
@@ -204,7 +203,7 @@ pub inline fn isBytes(
204203
205204pub inline fn readStruct (
206205 reader_ctx : anytype ,
207- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
206+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
208207 comptime T : type ,
209208) (reader_impl .ReadError || error {EndOfStream })! T {
210209 // Only extern and packed structs have defined in-memory layout.
@@ -216,7 +215,7 @@ pub inline fn readStruct(
216215
217216pub inline fn readStructBig (
218217 reader_ctx : anytype ,
219- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
218+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
220219 comptime T : type ,
221220) (reader_impl .ReadError || error {EndOfStream })! T {
222221 var res = try readStruct (reader_ctx , reader_impl , T );
@@ -228,7 +227,7 @@ pub inline fn readStructBig(
228227
229228pub inline fn readEnum (
230229 reader_ctx : anytype ,
231- reader_impl : Impl (@TypeOf (reader_ctx ), Reader ),
230+ reader_impl : Impl (Reader , @TypeOf (reader_ctx )),
232231 comptime Enum : type ,
233232 endian : std.builtin.Endian ,
234233) (reader_impl .ReadError || error { EndOfStream , InvalidValue })! Enum {
@@ -263,15 +262,15 @@ pub fn Writer(comptime T: type) type {
263262
264263pub fn write (
265264 writer_ctx : anytype ,
266- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
265+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
267266 bytes : []const u8 ,
268267) writer_impl .WriteError ! usize {
269268 return @errorCast (writer_impl .write (writer_ctx , bytes ));
270269}
271270
272271pub fn writeAll (
273272 writer_ctx : anytype ,
274- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
273+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
275274 bytes : []const u8 ,
276275) writer_impl .WriteError ! void {
277276 var index : usize = 0 ;
@@ -282,7 +281,7 @@ pub fn writeAll(
282281
283282pub fn writeByte (
284283 writer_ctx : anytype ,
285- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
284+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
286285 byte : u8 ,
287286) writer_impl .WriteError ! void {
288287 const array = [1 ]u8 {byte };
@@ -291,7 +290,7 @@ pub fn writeByte(
291290
292291pub fn writeByteNTimes (
293292 writer_ctx : anytype ,
294- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
293+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
295294 byte : u8 ,
296295 n : usize ,
297296) writer_impl .WriteError ! void {
@@ -308,7 +307,7 @@ pub fn writeByteNTimes(
308307
309308pub inline fn writeInt (
310309 writer_ctx : anytype ,
311- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
310+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
312311 comptime T : type ,
313312 value : T ,
314313 endian : std.builtin.Endian ,
@@ -325,7 +324,7 @@ pub inline fn writeInt(
325324
326325pub fn writeStruct (
327326 writer_ctx : anytype ,
328- writer_impl : Impl (@TypeOf (writer_ctx ), Writer ),
327+ writer_impl : Impl (Writer , @TypeOf (writer_ctx )),
329328 value : anytype ,
330329) writer_impl .WriteError ! void {
331330 // Only extern and packed structs have defined in-memory layout.
@@ -349,30 +348,30 @@ pub fn Seekable(comptime T: type) type {
349348
350349pub fn seekTo (
351350 seek_ctx : anytype ,
352- seek_impl : Impl (@TypeOf (seek_ctx ), Seekable ),
351+ seek_impl : Impl (Seekable , @TypeOf (seek_ctx )),
353352 pos : u64 ,
354353) seek_impl .SeekError ! void {
355354 return @errorCast (seek_impl .seekTo (seek_ctx , pos ));
356355}
357356
358357pub fn seekBy (
359358 seek_ctx : anytype ,
360- seek_impl : Impl (@TypeOf (seek_ctx ), Seekable ),
359+ seek_impl : Impl (Seekable , @TypeOf (seek_ctx )),
361360 amt : i64 ,
362361) seek_impl .SeekError ! void {
363362 return @errorCast (seek_impl .seekBy (seek_ctx , amt ));
364363}
365364
366365pub fn getPos (
367366 seek_ctx : anytype ,
368- seek_impl : Impl (@TypeOf (seek_ctx ), Seekable ),
367+ seek_impl : Impl (Seekable , @TypeOf (seek_ctx )),
369368) seek_impl .GetSeekPosError ! u64 {
370369 return @errorCast (seek_impl .getPos (seek_ctx ));
371370}
372371
373372pub fn getEndPos (
374373 seek_ctx : anytype ,
375- seek_impl : Impl (@TypeOf (seek_ctx ), Seekable ),
374+ seek_impl : Impl (Seekable , @TypeOf (seek_ctx )),
376375) seek_impl .GetSeekPosError ! u64 {
377376 return @errorCast (seek_impl .getEndPos (seek_ctx ));
378377}
0 commit comments