From 22926d4037ab1b331bb7d1b219e0b8ba03e4c05a Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Wed, 6 May 2026 02:59:08 -0700 Subject: [PATCH] add NullWriter --- nio.zig | 2 ++ null_writer.zig | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 null_writer.zig diff --git a/nio.zig b/nio.zig index cbf9501ad148ddea3942e863fddcae16e3a837fb..3290f025e8d0f30b585b996047483908592489d3 100644 --- a/nio.zig +++ b/nio.zig @@ -301,3 +301,5 @@ pub const BufferedReader = @import("./buffered_reader.zig").BufferedReader; pub const BufferedWriter = @import("./buffered_writer.zig").BufferedWriter; pub const CountingWriter = @import("./counting_writer.zig").CountingWriter; + +pub const NullWriter = @import("./null_writer.zig").NullWriter; diff --git a/null_writer.zig b/null_writer.zig new file mode 100644 index 0000000000000000000000000000000000000000..23db0828bf021d5f151bfc1fbe86184242bba7a3 --- /dev/null +++ b/null_writer.zig @@ -0,0 +1,12 @@ +const std = @import("std"); +const extras = @import("extras"); +const nio = @import("./nio.zig"); + +pub const NullWriter = struct { + pub const WriteError = error{}; + pub usingnamespace nio.Writable(@This(), ._var); + pub fn write(self: NullWriter, bytes: []const u8) WriteError!usize { + _ = self; + return bytes.len; + } +}; -- 2.54.0