mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:07:34 +00:00
LibCore: Rename Stream::*_or_error
to *_entire_buffer
All of our functions are `_or_error` (or are about to be), and maybe making it less reminiscient of AK::Stream will make people use it more.
This commit is contained in:
parent
ed4c2f2f8e
commit
6c7c5a6786
17 changed files with 44 additions and 36 deletions
|
@ -40,7 +40,7 @@ public:
|
|||
return m_stream.read(bytes);
|
||||
}
|
||||
virtual ErrorOr<size_t> write(ReadonlyBytes bytes) override { return m_stream.write(bytes); }
|
||||
virtual bool write_or_error(ReadonlyBytes bytes) override { return m_stream.write_or_error(bytes); }
|
||||
virtual bool write_entire_buffer(ReadonlyBytes bytes) override { return m_stream.write_entire_buffer(bytes); }
|
||||
virtual bool is_eof() const override { return m_stream.is_eof() && !m_current_byte.has_value(); }
|
||||
virtual bool is_open() const override { return m_stream.is_open(); }
|
||||
virtual void close() override
|
||||
|
@ -155,7 +155,7 @@ public:
|
|||
return m_stream.read(bytes);
|
||||
}
|
||||
virtual ErrorOr<size_t> write(ReadonlyBytes bytes) override { return m_stream.write(bytes); }
|
||||
virtual bool write_or_error(ReadonlyBytes bytes) override { return m_stream.write_or_error(bytes); }
|
||||
virtual bool write_entire_buffer(ReadonlyBytes bytes) override { return m_stream.write_entire_buffer(bytes); }
|
||||
virtual bool is_eof() const override { return m_stream.is_eof() && !m_current_byte.has_value(); }
|
||||
virtual bool is_open() const override { return m_stream.is_open(); }
|
||||
virtual void close() override
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
m_offset += nwritten;
|
||||
return nwritten;
|
||||
}
|
||||
virtual bool write_or_error(ReadonlyBytes bytes) override
|
||||
virtual bool write_entire_buffer(ReadonlyBytes bytes) override
|
||||
{
|
||||
if (remaining() < bytes.size())
|
||||
return false;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
namespace Core::Stream {
|
||||
|
||||
bool Stream::read_or_error(Bytes buffer)
|
||||
bool Stream::read_entire_buffer(Bytes buffer)
|
||||
{
|
||||
VERIFY(buffer.size());
|
||||
|
||||
|
@ -89,7 +89,7 @@ ErrorOr<void> Stream::discard(size_t discarded_bytes)
|
|||
return {};
|
||||
}
|
||||
|
||||
bool Stream::write_or_error(ReadonlyBytes buffer)
|
||||
bool Stream::write_entire_buffer(ReadonlyBytes buffer)
|
||||
{
|
||||
VERIFY(buffer.size());
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
virtual ErrorOr<Bytes> read(Bytes) = 0;
|
||||
/// Tries to fill the entire buffer through reading. Returns whether the
|
||||
/// buffer was filled without an error.
|
||||
virtual bool read_or_error(Bytes);
|
||||
virtual bool read_entire_buffer(Bytes);
|
||||
/// Reads the stream until EOF, storing the contents into a ByteBuffer which
|
||||
/// is returned once EOF is encountered. The block size determines the size
|
||||
/// of newly allocated chunks while reading.
|
||||
|
@ -50,9 +50,17 @@ public:
|
|||
/// bytes written into the stream, or an errno in the case of failure.
|
||||
virtual ErrorOr<size_t> write(ReadonlyBytes) = 0;
|
||||
/// Same as write, but does not return until either the entire buffer
|
||||
/// contents are written or an error occurs. Returns whether the entire
|
||||
/// contents were written without an error.
|
||||
virtual bool write_or_error(ReadonlyBytes);
|
||||
/// contents are written or an error occurs.
|
||||
virtual bool write_entire_buffer(ReadonlyBytes);
|
||||
|
||||
// This is a wrapper around `write_entire_buffer` that is compatible with
|
||||
// `write_or_error`. This is required by some templated code in LibProtocol
|
||||
// that needs to work with either type of stream.
|
||||
// TODO: Fully port or wrap `Request::stream_into_impl` into `Core::Stream` and remove this.
|
||||
bool write_or_error(ReadonlyBytes buffer)
|
||||
{
|
||||
return write_entire_buffer(buffer);
|
||||
}
|
||||
|
||||
/// Returns whether the stream has reached the end of file. For sockets,
|
||||
/// this most likely means that the protocol has disconnected (in the case
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue