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) |
template<typename Consumer > | |
future | consume (Consumer &&c) |
template<typename Consumer > | |
future | consume (Consumer &c) |
bool | eof () const |
future< tmp_buf > | read () |
future< tmp_buf > | read_up_to (size_t n) |
future | close () |
future | skip (uint64_t n) |
Ignores n next bytes from the stream. | |
data_source | detach () && |
Protected Member Functions | |
void | reset () |
data_source * | fd () |
|
inline |
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 |
future< temporary_buffer< CharType > > seastar::input_stream< CharType >::read |
Returns some data from the stream, or an empty buffer on end of stream.
future< temporary_buffer< CharType > > seastar::input_stream< CharType >::read_exactly | ( | size_t | n | ) |
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. |
future< temporary_buffer< CharType > > seastar::input_stream< CharType >::read_up_to | ( | size_t | n | ) |
Returns up to n bytes from the stream, or an empty buffer on end of stream.