6 #ifndef KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP 7 #define KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP 9 #include <libp2p/connection/stream.hpp> 20 : stream{std::move(stream)} {}
22 void read(gsl::span<uint8_t> out,
24 ReadCallbackFunc cb)
override {
25 stream->read(out, bytes, std::move(cb));
29 ReadCallbackFunc cb)
override {
30 stream->readSome(out, bytes, std::move(cb));
33 ReadCallbackFunc cb)
override {
34 stream->deferReadCallback(res, std::move(cb));
37 void write(gsl::span<const uint8_t> in,
39 WriteCallbackFunc cb)
override {
40 stream->write(in, bytes, std::move(cb));
44 WriteCallbackFunc cb)
override {
45 stream->writeSome(in, bytes, std::move(cb));
48 stream->deferWriteCallback(ec, std::move(cb));
52 return stream->isClosedForRead();
55 return stream->isClosedForWrite();
58 return stream->isClosed();
60 void close(VoidResultHandlerFunc cb)
override {
61 stream->close(std::move(cb));
67 VoidResultHandlerFunc cb)
override {
68 stream->adjustWindowSize(new_size, std::move(cb));
71 return stream->isInitiator();
74 return stream->remotePeerId();
77 return stream->localMultiaddr();
80 return stream->remoteMultiaddr();
85 #endif // KAGOME_NETWORK_HELPERS_STREAM_PROXY_BASE_HPP bool isClosedForWrite() const override
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
bool isClosed() 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
std::shared_ptr< Stream > stream
bool isClosedForRead() const 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