@@ -28,7 +28,6 @@ namespace Core::Stream {
28
28
// / operations one can perform on every stream in LibCore.
29
29
class Stream {
30
30
public:
31
- virtual bool is_readable () const { return false ; }
32
31
// / Reads into a buffer, with the maximum size being the size of the buffer.
33
32
// / The amount of bytes read can be smaller than the size of the buffer.
34
33
// / Returns either the bytes that were read, or an errno in the case of
@@ -46,7 +45,6 @@ class Stream {
46
45
// / internal stack-based buffer.
47
46
virtual ErrorOr<void > discard (size_t discarded_bytes);
48
47
49
- virtual bool is_writable () const { return false ; }
50
48
// / Tries to write the entire contents of the buffer. It is possible for
51
49
// / less than the full buffer to be written. Returns either the amount of
52
50
// / bytes written into the stream, or an errno in the case of failure.
@@ -239,10 +237,8 @@ class File final : public SeekableStream {
239
237
return *this ;
240
238
}
241
239
242
- virtual bool is_readable () const override ;
243
240
virtual ErrorOr<Bytes> read (Bytes) override ;
244
241
virtual ErrorOr<ByteBuffer> read_all (size_t block_size = 4096 ) override ;
245
- virtual bool is_writable () const override ;
246
242
virtual ErrorOr<size_t > write (ReadonlyBytes) override ;
247
243
virtual bool is_eof () const override ;
248
244
virtual bool is_open () const override ;
@@ -346,8 +342,6 @@ class TCPSocket final : public Socket {
346
342
return *this ;
347
343
}
348
344
349
- virtual bool is_readable () const override { return is_open (); }
350
- virtual bool is_writable () const override { return is_open (); }
351
345
virtual ErrorOr<Bytes> read (Bytes buffer) override { return m_helper.read (buffer, default_flags ()); }
352
346
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_helper.write (buffer, default_flags ()); }
353
347
virtual bool is_eof () const override { return m_helper.is_eof (); }
@@ -423,8 +417,6 @@ class UDPSocket final : public Socket {
423
417
return m_helper.read (buffer, default_flags ());
424
418
}
425
419
426
- virtual bool is_readable () const override { return is_open (); }
427
- virtual bool is_writable () const override { return is_open (); }
428
420
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_helper.write (buffer, default_flags ()); }
429
421
virtual bool is_eof () const override { return m_helper.is_eof (); }
430
422
virtual bool is_open () const override { return m_helper.is_open (); }
@@ -484,8 +476,6 @@ class LocalSocket final : public Socket {
484
476
return *this ;
485
477
}
486
478
487
- virtual bool is_readable () const override { return is_open (); }
488
- virtual bool is_writable () const override { return is_open (); }
489
479
virtual ErrorOr<Bytes> read (Bytes buffer) override { return m_helper.read (buffer, default_flags ()); }
490
480
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_helper.write (buffer, default_flags ()); }
491
481
virtual bool is_eof () const override { return m_helper.is_eof (); }
@@ -717,7 +707,7 @@ class BufferedHelper {
717
707
if (m_buffer.span ().slice (0 , m_buffered_size).contains_slow (' \n ' ))
718
708
return true ;
719
709
720
- if (! stream ().is_readable ())
710
+ if (stream ().is_eof ())
721
711
return false ;
722
712
723
713
while (m_buffered_size < m_buffer.size ()) {
@@ -818,9 +808,7 @@ class BufferedSeekable final : public SeekableStream {
818
808
BufferedSeekable (BufferedSeekable&& other) = default ;
819
809
BufferedSeekable& operator =(BufferedSeekable&& other) = default ;
820
810
821
- virtual bool is_readable () const override { return m_helper.stream ().is_readable (); }
822
811
virtual ErrorOr<Bytes> read (Bytes buffer) override { return m_helper.read (move (buffer)); }
823
- virtual bool is_writable () const override { return m_helper.stream ().is_writable (); }
824
812
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_helper.stream ().write (buffer); }
825
813
virtual bool is_eof () const override { return m_helper.is_eof (); }
826
814
virtual bool is_open () const override { return m_helper.stream ().is_open (); }
@@ -889,9 +877,7 @@ class BufferedSocket final : public BufferedSocketBase {
889
877
return *this ;
890
878
}
891
879
892
- virtual bool is_readable () const override { return m_helper.stream ().is_readable (); }
893
880
virtual ErrorOr<Bytes> read (Bytes buffer) override { return m_helper.read (move (buffer)); }
894
- virtual bool is_writable () const override { return m_helper.stream ().is_writable (); }
895
881
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_helper.stream ().write (buffer); }
896
882
virtual bool is_eof () const override { return m_helper.is_eof (); }
897
883
virtual bool is_open () const override { return m_helper.stream ().is_open (); }
@@ -977,9 +963,7 @@ class BasicReusableSocket final : public ReusableSocket {
977
963
return {};
978
964
}
979
965
980
- virtual bool is_readable () const override { return m_socket.is_readable (); }
981
966
virtual ErrorOr<Bytes> read (Bytes buffer) override { return m_socket.read (move (buffer)); }
982
- virtual bool is_writable () const override { return m_socket.is_writable (); }
983
967
virtual ErrorOr<size_t > write (ReadonlyBytes buffer) override { return m_socket.write (buffer); }
984
968
virtual bool is_eof () const override { return m_socket.is_eof (); }
985
969
virtual bool is_open () const override { return m_socket.is_open (); }
0 commit comments