Add "Reader" IO closure type for reading resources
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kayomn 2022-10-22 23:34:30 +01:00
parent b698f18c4d
commit ccb96875b1
1 changed files with 8 additions and 2 deletions

View File

@ -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 /// Returns a state machine for lazily computing all `Element` components of a given source input
/// that match a delimiting pattern. /// 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`. /// 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); return (writer.apply(std.mem.asBytes(&byte)) != 0);
} }