From ccb96875b1b23d274ca585f39260dbfb1200568b Mon Sep 17 00:00:00 2001 From: kayomn Date: Sat, 22 Oct 2022 23:34:30 +0100 Subject: [PATCH] Add "Reader" IO closure type for reading resources --- src/ona/io.zig | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ona/io.zig b/src/ona/io.zig index 7714365..c939f49 100644 --- a/src/ona/io.zig +++ b/src/ona/io.zig @@ -98,6 +98,12 @@ pub const FileAccess = struct { } }; +/// +/// Closure that captures a reference to readable resources like block devices, memory buffers, +/// network sockets, and more. +/// +pub const Reader = meta.Function(@sizeOf(usize), []u8, usize); + /// /// Returns a state machine for lazily computing all `Element` components of a given source input /// that match a delimiting pattern. @@ -238,9 +244,9 @@ test "Null writing" { } /// -/// Writes the singular `byte` to `writer`, returning `true` if it was successfully written, +/// Applies the singular `byte` to `writer`, returning `true` if it was successfully written, /// otherwise `false`. /// -pub fn writeByte(writer: Writer, byte: u8) bool { +pub fn writeByte(writer: *Writer, byte: u8) bool { return (writer.apply(std.mem.asBytes(&byte)) != 0); }