From ce271f82f16ee89a18e7bfc9ed8eab7cbd6f37bc Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Mon, 22 Sep 2025 23:38:21 +0200 Subject: Change io::Reader and company to return ReadError::Eof instead of 0. It's debatable if Eof should be considered an error or not. But it is pretty clear it generally is a special response that needs special handling, so easier to keep with the unexpected lot. Also keeps better at higher abstraction levels, such as the line reader. --- src/line.hh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/line.hh') diff --git a/src/line.hh b/src/line.hh index 5ce42dd..a8eeea8 100644 --- a/src/line.hh +++ b/src/line.hh @@ -11,20 +11,13 @@ namespace line { -struct ReadError { - bool eof; - std::optional io_error; - - ReadError(); - explicit ReadError(io::ReadError error); -}; - class Reader { public: virtual ~Reader() = default; // Returned view is only valid until next call to read. - [[nodiscard]] virtual std::expected read() = 0; + [[nodiscard]] + virtual std::expected read() = 0; // Starts at zero. Returns next line. // So, before first read it is zero, after first read it is one. [[nodiscard]] virtual uint64_t number() const = 0; -- cgit v1.3