Seastar
High performance C++ framework for concurrent servers
Public Types | Public Member Functions | Protected Member Functions | List of all members
seastar::input_stream< CharType > Class Template Referencefinal

Detailed Description

template<typename CharType>
class seastar::input_stream< CharType >

Buffers data from a data_source and provides a stream interface to the user.

Note
All methods must be called sequentially. That is, no method may be invoked before the previous method's returned future is resolved.

#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_streamoperator= (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_bufread ()
 
future< tmp_bufread_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_sourcefd ()
 

Member Function Documentation

◆ close()

template<typename CharType >
future seastar::input_stream< CharType >::close ( )
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().

Returns
a future that becomes ready when this stream no longer needs the data source.

◆ detach()

template<typename CharType >
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.

Exceptions
std::logic_errorif called on a used stream
Returns
the data_source

◆ read()

template<typename CharType >
future< temporary_buffer< CharType > > seastar::input_stream< CharType >::read

Returns some data from the stream, or an empty buffer on end of stream.

◆ read_exactly()

template<typename CharType >
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.

Returns
a future that waits until n bytes are available in the stream and returns them. If the end of stream is reached before n bytes were read, fewer than n bytes will be returned - so despite the method's name, the caller must not assume the returned buffer will always contain exactly n bytes.
Exceptions
ifan I/O error occurs during the read. As explained above, prematurely reaching the end of stream is not an I/O error.

◆ read_up_to()

template<typename CharType >
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.


The documentation for this class was generated from the following files: