Kagome
Polkadot Runtime Engine in C++17
stream_proxy_base.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP
7 #define KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP
8 
9 #include <libp2p/connection/stream.hpp>
10 
11 namespace libp2p::connection {
17  std::shared_ptr<Stream> stream;
18 
19  explicit StreamProxyBase(std::shared_ptr<Stream> stream)
20  : stream{std::move(stream)} {}
21 
22  void read(gsl::span<uint8_t> out,
23  size_t bytes,
24  ReadCallbackFunc cb) override {
25  stream->read(out, bytes, std::move(cb));
26  }
27  void readSome(gsl::span<uint8_t> out,
28  size_t bytes,
29  ReadCallbackFunc cb) override {
30  stream->readSome(out, bytes, std::move(cb));
31  }
32  void deferReadCallback(outcome::result<size_t> res,
33  ReadCallbackFunc cb) override {
34  stream->deferReadCallback(res, std::move(cb));
35  }
36 
37  void write(gsl::span<const uint8_t> in,
38  size_t bytes,
39  WriteCallbackFunc cb) override {
40  stream->write(in, bytes, std::move(cb));
41  }
42  void writeSome(gsl::span<const uint8_t> in,
43  size_t bytes,
44  WriteCallbackFunc cb) override {
45  stream->writeSome(in, bytes, std::move(cb));
46  }
47  void deferWriteCallback(std::error_code ec, WriteCallbackFunc cb) override {
48  stream->deferWriteCallback(ec, std::move(cb));
49  }
50 
51  bool isClosedForRead() const override {
52  return stream->isClosedForRead();
53  }
54  bool isClosedForWrite() const override {
55  return stream->isClosedForWrite();
56  }
57  bool isClosed() const override {
58  return stream->isClosed();
59  }
60  void close(VoidResultHandlerFunc cb) override {
61  stream->close(std::move(cb));
62  }
63  void reset() override {
64  stream->reset();
65  }
66  void adjustWindowSize(uint32_t new_size,
67  VoidResultHandlerFunc cb) override {
68  stream->adjustWindowSize(new_size, std::move(cb));
69  }
70  outcome::result<bool> isInitiator() const override {
71  return stream->isInitiator();
72  }
73  outcome::result<peer::PeerId> remotePeerId() const override {
74  return stream->remotePeerId();
75  }
76  outcome::result<multi::Multiaddress> localMultiaddr() const override {
77  return stream->localMultiaddr();
78  }
79  outcome::result<multi::Multiaddress> remoteMultiaddr() const override {
80  return stream->remoteMultiaddr();
81  }
82  };
83 } // namespace libp2p::connection
84 
85 #endif // KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP
void adjustWindowSize(uint32_t new_size, VoidResultHandlerFunc cb) override
outcome::result< multi::Multiaddress > remoteMultiaddr() const override
void readSome(gsl::span< uint8_t > out, size_t bytes, ReadCallbackFunc cb) override
void read(gsl::span< uint8_t > out, size_t bytes, ReadCallbackFunc cb) override
outcome::result< peer::PeerId > remotePeerId() const override
void deferReadCallback(outcome::result< size_t > res, ReadCallbackFunc cb) override
void deferWriteCallback(std::error_code ec, WriteCallbackFunc cb) override
void write(gsl::span< const uint8_t > in, size_t bytes, WriteCallbackFunc cb) override
outcome::result< bool > isInitiator() const override
void writeSome(gsl::span< const uint8_t > in, size_t bytes, WriteCallbackFunc cb) override
libp2p::connection::Stream Stream
outcome::result< multi::Multiaddress > localMultiaddr() const override
StreamProxyBase(std::shared_ptr< Stream > stream)
void close(VoidResultHandlerFunc cb) override