Kagome
Polkadot Runtime Engine in C++17
libp2p::connection::StreamReadBuffer Struct Reference

#include <stream_read_buffer.hpp>

Inheritance diagram for libp2p::connection::StreamReadBuffer:
Collaboration diagram for libp2p::connection::StreamReadBuffer:

Public Member Functions

 StreamReadBuffer (std::shared_ptr< Stream > stream, size_t capacity)
 
size_t size () const
 
void readFull (gsl::span< uint8_t > out, size_t total, ReadCallbackFunc cb)
 
void read (gsl::span< uint8_t > out, size_t n, ReadCallbackFunc cb) override
 
size_t readFromBuffer (gsl::span< uint8_t > out)
 
void readSome (gsl::span< uint8_t > out, size_t n, ReadCallbackFunc cb) override
 
- Public Member Functions inherited from libp2p::connection::StreamProxyBase
 StreamProxyBase (std::shared_ptr< Stream > stream)
 
void read (gsl::span< uint8_t > out, size_t bytes, ReadCallbackFunc cb) override
 
void readSome (gsl::span< uint8_t > out, size_t bytes, ReadCallbackFunc cb) override
 
void deferReadCallback (outcome::result< size_t > res, ReadCallbackFunc cb) override
 
void write (gsl::span< const uint8_t > in, size_t bytes, WriteCallbackFunc cb) override
 
void writeSome (gsl::span< const uint8_t > in, size_t bytes, WriteCallbackFunc cb) override
 
void deferWriteCallback (std::error_code ec, WriteCallbackFunc cb) override
 
bool isClosedForRead () const override
 
bool isClosedForWrite () const override
 
bool isClosed () const override
 
void close (VoidResultHandlerFunc cb) override
 
void reset () override
 
void adjustWindowSize (uint32_t new_size, VoidResultHandlerFunc cb) override
 
outcome::result< bool > isInitiator () const override
 
outcome::result< peer::PeerId > remotePeerId () const override
 
outcome::result< multi::Multiaddress > localMultiaddr () const override
 
outcome::result< multi::Multiaddress > remoteMultiaddr () const override
 

Public Attributes

std::shared_ptr< std::vector< uint8_t > > buffer
 
size_t begin {}
 
size_t end {}
 
- Public Attributes inherited from libp2p::connection::StreamProxyBase
std::shared_ptr< Stream > stream
 

Detailed Description

Stream with buffered reader.

Works around problem when reading varint prefix of big message (bigger than yamux window) causes yamux to send/receive each byte of message in separate packet.

Definition at line 19 of file stream_read_buffer.hpp.

Constructor & Destructor Documentation

libp2p::connection::StreamReadBuffer::StreamReadBuffer ( std::shared_ptr< Stream >  stream,
size_t  capacity 
)
inline

Definition at line 25 of file stream_read_buffer.hpp.

Member Function Documentation

void libp2p::connection::StreamReadBuffer::read ( gsl::span< uint8_t >  out,
size_t  n,
ReadCallbackFunc  cb 
)
inlineoverride

Definition at line 63 of file stream_read_buffer.hpp.

size_t libp2p::connection::StreamReadBuffer::readFromBuffer ( gsl::span< uint8_t >  out)
inline

Read from buffer.

Definition at line 72 of file stream_read_buffer.hpp.

void libp2p::connection::StreamReadBuffer::readFull ( gsl::span< uint8_t >  out,
size_t  total,
ReadCallbackFunc  cb 
)
inline

Async loop iteration. Reads out.size() remaining bytes of total bytes.

Definition at line 40 of file stream_read_buffer.hpp.

void libp2p::connection::StreamReadBuffer::readSome ( gsl::span< uint8_t >  out,
size_t  n,
ReadCallbackFunc  cb 
)
inlineoverride

Definition at line 83 of file stream_read_buffer.hpp.

size_t libp2p::connection::StreamReadBuffer::size ( ) const
inline

Returns count of available bytes in buffer.

Definition at line 32 of file stream_read_buffer.hpp.

Member Data Documentation

size_t libp2p::connection::StreamReadBuffer::begin {}

Definition at line 22 of file stream_read_buffer.hpp.

std::shared_ptr<std::vector<uint8_t> > libp2p::connection::StreamReadBuffer::buffer

Definition at line 21 of file stream_read_buffer.hpp.

size_t libp2p::connection::StreamReadBuffer::end {}

Definition at line 23 of file stream_read_buffer.hpp.


The documentation for this struct was generated from the following file: