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) noexcept
 
template<typename Consumer >
future consume (Consumer &&c) noexcept(std::is_nothrow_move_constructible_v< Consumer >)
 
template<typename Consumer >
future consume (Consumer &c) noexcept(std::is_nothrow_move_constructible_v< Consumer >)
 
bool eof () const noexcept
 
future< tmp_bufread () noexcept
 
future< tmp_bufread_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_sourcefd () noexcept
 

Member Function Documentation

◆ close()

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

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

◆ eof()

template<typename CharType >
bool seastar::input_stream< CharType >::eof ( ) const
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.

◆ read()

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

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)
noexcept

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)
noexcept

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: