This repository has been archived on 2020-05-25. You can view files and clone it, but cannot push or open issues or pull requests.
tdlib-fork/tdnet/td/net/SslStream.h
levlam 23c03a97f4 Various style fixes.
GitOrigin-RevId: 056c091cfd71322a0cc8db0e3bafec7d272da7ad
2018-08-16 01:06:53 +03:00

47 lines
1.0 KiB
C++

//
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2018
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
#pragma once
#include "td/utils/ByteFlow.h"
#include "td/utils/Slice.h"
#include "td/utils/Status.h"
namespace td {
namespace detail {
class SslStreamImpl;
}
class SslStream {
public:
SslStream();
SslStream(SslStream &&);
SslStream &operator=(SslStream &&);
~SslStream();
enum class VerifyPeer { On, Off };
static Result<SslStream> create(CSlice host, CSlice cert_file = CSlice(), VerifyPeer verify_peer = VerifyPeer::On);
ByteFlowInterface &read_byte_flow();
ByteFlowInterface &write_byte_flow();
size_t flow_read(MutableSlice slice);
size_t flow_write(Slice slice);
explicit operator bool() const {
return bool(impl_);
}
private:
std::unique_ptr<detail::SslStreamImpl> impl_;
explicit SslStream(std::unique_ptr<detail::SslStreamImpl> impl);
};
} // namespace td