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

#include <protobuf_message_read_writer.hpp>

Inheritance diagram for kagome::network::ProtobufMessageReadWriter:
Collaboration diagram for kagome::network::ProtobufMessageReadWriter:

Public Member Functions

 ProtobufMessageReadWriter (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 protobuf with a prepended varint

Definition at line 25 of file protobuf_message_read_writer.hpp.

Member Typedef Documentation

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

Definition at line 28 of file protobuf_message_read_writer.hpp.

Constructor & Destructor Documentation

kagome::network::ProtobufMessageReadWriter::ProtobufMessageReadWriter ( const std::shared_ptr< libp2p::basic::ReadWriter > &  read_writer)
inlineexplicit

Definition at line 33 of file protobuf_message_read_writer.hpp.

Member Function Documentation

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

Read a Protobuf 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 45 of file protobuf_message_read_writer.hpp.

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

Serialize to protobuf 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 74 of file protobuf_message_read_writer.hpp.

Member Data Documentation

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

Definition at line 30 of file protobuf_message_read_writer.hpp.


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