Kagome
Polkadot Runtime Engine in C++17
kagome::network::ScaleMessageReadWriter Class Reference

#include <scale_message_read_writer.hpp>

Inheritance diagram for kagome::network::ScaleMessageReadWriter:
Collaboration diagram for kagome::network::ScaleMessageReadWriter:

Public Member Functions

 ScaleMessageReadWriter (std::shared_ptr< libp2p::basic::MessageReadWriter > read_writer)
 
 ScaleMessageReadWriter (const std::shared_ptr< libp2p::basic::ReadWriter > &read_writer)
 
template<typename MsgType >
void read (ReadCallback< MsgType > cb) const
 
template<typename MsgType >
void write (const MsgType &msg, libp2p::basic::Writer::WriteCallbackFunc cb) const
 

Private Types

template<typename MsgType >
using ReadCallback = std::function< void(outcome::result< MsgType >)>
 

Private Attributes

std::shared_ptr< libp2p::basic::MessageReadWriter > read_writer_
 

Detailed Description

Read and write messages, encoded into SCALE with a prepended varint

Definition at line 21 of file scale_message_read_writer.hpp.

Member Typedef Documentation

template<typename MsgType >
using kagome::network::ScaleMessageReadWriter::ReadCallback = std::function<void(outcome::result<MsgType>)>
private

Definition at line 24 of file scale_message_read_writer.hpp.

Constructor & Destructor Documentation

kagome::network::ScaleMessageReadWriter::ScaleMessageReadWriter ( std::shared_ptr< libp2p::basic::MessageReadWriter >  read_writer)
explicit

Definition at line 9 of file scale_message_read_writer.cpp.

kagome::network::ScaleMessageReadWriter::ScaleMessageReadWriter ( const std::shared_ptr< libp2p::basic::ReadWriter > &  read_writer)
explicit

Definition at line 13 of file scale_message_read_writer.cpp.

Member Function Documentation

template<typename MsgType >
void kagome::network::ScaleMessageReadWriter::read ( ReadCallback< MsgType >  cb) const
inline

Read a SCALE-encoded message from the channel

Template Parameters
MsgType- type of the message
Parameters
cbto be called, when the message is read, or error happens

Definition at line 38 of file scale_message_read_writer.hpp.

template<typename MsgType >
void kagome::network::ScaleMessageReadWriter::write ( const MsgType &  msg,
libp2p::basic::Writer::WriteCallbackFunc  cb 
) const
inline

SCALE-encode a message and write it to the channel

Template Parameters
MsgType- type of the message
Parameters
msgto be written
cbto be called, when the message is written, or error happens

Definition at line 63 of file scale_message_read_writer.hpp.

Member Data Documentation

std::shared_ptr<libp2p::basic::MessageReadWriter> kagome::network::ScaleMessageReadWriter::read_writer_
private

Definition at line 84 of file scale_message_read_writer.hpp.


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