Seastar
High performance C++ framework for concurrent servers
|
Buffers data from a data_source and provides a stream interface to the user.
#include <seastar/core/iostream.hh>
Public Types | |
using | consumption_result_type = consumption_result< CharType > |
using | unconsumed_remainder = std::optional< tmp_buf > |
using | char_type = CharType |
Public Member Functions | |
input_stream (data_source fd) noexcept | |
input_stream (input_stream &&)=default | |
input_stream & | operator= (input_stream &&)=default |
future< temporary_buffer< CharType > > | read_exactly (size_t n) noexcept |
template<typename Consumer > requires InputStreamConsumer<Consumer, CharType> || ObsoleteInputStreamConsumer<Consumer, CharType> | |
future | consume (Consumer &&c) noexcept(std::is_nothrow_move_constructible_v< Consumer >) |
template<typename Consumer > requires InputStreamConsumer<Consumer, CharType> || ObsoleteInputStreamConsumer<Consumer, CharType> | |
future | consume (Consumer &c) noexcept(std::is_nothrow_move_constructible_v< Consumer >) |
bool | eof () const noexcept |
future< tmp_buf > | read () noexcept |
future< tmp_buf > | read_up_to (size_t n) noexcept |
future | close () noexcept |
future | skip (uint64_t n) noexcept |
Ignores n next bytes from the stream. | |
data_source | detach () && |
Protected Member Functions | |
void | reset () noexcept |
data_source * | fd () noexcept |
|
inlinenoexcept |
Detaches the input_stream
from the underlying data source.
Waits for any background operations (for example, read-ahead) to complete, so that the any resources the stream is using can be safely destroyed. An example is a file resource used by the stream returned by make_file_input_stream().
data_source seastar::input_stream< CharType >::detach | ( | ) | && |
Detaches the underlying data_source
from the input_stream
.
The intended usage is custom data_source_impl
implementations wrapping an existing input_stream
, therefore it shouldn't be called on an input_stream
that was already used. After calling detach()
the input_stream
is in an unusable, moved-from state.
std::logic_error | if called on a used stream |
|
inlinenoexcept |
Returns true if the end-of-file flag is set on the stream. Note that the eof flag is only set after a previous attempt to read from the stream noticed the end of the stream. In other words, it is possible that eof() returns false but read() will return an empty buffer. Checking eof() again after the read will return true.
|
noexcept |
Returns some data from the stream, or an empty buffer on end of stream.
|
noexcept |
Reads n bytes from the stream, or fewer if reached the end of stream.
if | an I/O error occurs during the read. As explained above, prematurely reaching the end of stream is not an I/O error. |
|
noexcept |
Returns up to n bytes from the stream, or an empty buffer on end of stream.