2 #include "../Stream.hpp" 6 constexpr Stream::Stream(virStreamPtr ptr) noexcept : underlying(ptr) {}
7 inline Stream::Stream(
const Connection& conn,
Flag flags) noexcept : underlying(virStreamNew(conn.underlying,
to_integral(flags))) {}
8 inline Stream::Stream(
const Stream& oth) noexcept : underlying(oth.underlying) {
10 virStreamRef(underlying);
12 constexpr Stream::Stream(
Stream&& from) noexcept : underlying(from.underlying) { from.underlying =
nullptr; }
15 virStreamFree(underlying);
19 if ((underlying = oth.underlying))
20 virStreamRef(underlying);
24 underlying = from.underlying;
25 from.underlying =
nullptr;
29 inline bool Stream::abort() noexcept {
return virStreamAbort(underlying) >= 0; }
31 inline bool Stream::finish() noexcept {
return virStreamFinish(underlying) >= 0; }
32 inline int Stream::recv(gsl::span<char> span) noexcept {
return recv(span.data(), span.size()); }
33 inline int Stream::recv(
char* buf,
size_t buflen) noexcept {
return virStreamRecv(underlying, buf, buflen); }
37 std::optional<long long> ret;
38 long long& v = ret.emplace();
39 return virStreamRecvHole(underlying, &v, 0) >= 0 ? ret : std::nullopt;
41 inline int Stream::send(gsl::span<const char> span) noexcept {
return send(span.data(), span.size()); }
42 inline int Stream::send(
const char* buf,
size_t buflen) noexcept {
return virStreamSend(underlying, buf, buflen); }
43 inline bool Stream::sendHole(
long long len) noexcept {
return virStreamSendHole(underlying, len, 0) >= 0; }
Definition: Stream.hpp:10
~Stream() noexcept
Definition: Stream.hpp:13
int send(gsl::span< const char >) noexcept
Definition: Stream.hpp:41
constexpr auto to_integral(E e) noexcept
Definition: Base.hpp:32
int recv(gsl::span< char >) noexcept
Definition: Stream.hpp:32
Definition: Connection.hpp:47
bool abort() noexcept
Definition: Stream.hpp:29
Definition: AdminConnection.hpp:11
bool sendHole(long long) noexcept
Definition: Stream.hpp:43
Stream & operator=(const Stream &) noexcept
Definition: Stream.hpp:17
std::optional< long long > recvHole()
Definition: Stream.hpp:36
bool finish() noexcept
Definition: Stream.hpp:31
Definition: RecvFlag.hpp:8