|
const std = @import("std.zig");
|
deflate
compress/deflate.zig
|
pub const deflate = @import("compress/deflate.zig");
|
gzip
compress/gzip.zig
|
pub const gzip = @import("compress/gzip.zig");
|
lzma
compress/lzma.zig
|
pub const lzma = @import("compress/lzma.zig");
|
lzma2
compress/lzma2.zig
|
pub const lzma2 = @import("compress/lzma2.zig");
|
xz
compress/xz.zig
|
pub const xz = @import("compress/xz.zig");
|
zlib
compress/zlib.zig
|
pub const zlib = @import("compress/zlib.zig");
|
zstd
compress/zstandard.zig
|
pub const zstd = @import("compress/zstandard.zig");
|
HashedReader()
|
pub fn HashedReader(
comptime ReaderType: anytype,
comptime HasherType: anytype,
) type {
return struct {
child_reader: ReaderType,
hasher: HasherType,
|
Error
|
pub const Error = ReaderType.Error;
|
Reader
|
pub const Reader = std.io.Reader(*@This(), Error, read);
|
read()
|
pub fn read(self: *@This(), buf: []u8) Error!usize {
const amt = try self.child_reader.read(buf);
self.hasher.update(buf);
return amt;
}
|
reader()
|
pub fn reader(self: *@This()) Reader {
return .{ .context = self };
}
};
}
|
hashedReader()
|
pub fn hashedReader(
reader: anytype,
hasher: anytype,
) HashedReader(@TypeOf(reader), @TypeOf(hasher)) {
return .{ .child_reader = reader, .hasher = hasher };
}
test {
_ = deflate;
_ = gzip;
_ = lzma;
_ = lzma2;
_ = xz;
_ = zlib;
_ = zstd;
}
|
|