CountingReader
Deprecated with no replacement; inefficient pattern
Fields of this type
Fields
- child_reader:ReaderType
- bytes_read:u64
- = 0
Functions in this namespace
Functions
= ReaderType.Error
Values
- Error
- = ReaderType.Error
Source
Implementation
pub fn CountingReader(comptime ReaderType: anytype) type {
return struct {
child_reader: ReaderType,
bytes_read: u64 = 0,
pub const Error = ReaderType.Error;
pub const Reader = io.GenericReader(*@This(), Error, read);
pub fn read(self: *@This(), buf: []u8) Error!usize {
const amt = try self.child_reader.read(buf);
self.bytes_read += amt;
return amt;
}
pub fn reader(self: *@This()) Reader {
return .{ .context = self };
}
};
}