15 ~DrainGuard() { this->owner.
draining_ =
false; }
26 if (
static_cast<size_t>(sent) <
len) {
50 if (this->
count_ >= API_MAX_SEND_QUEUE)
53 const size_t new_len = total_len - skip;
60 if (this->
buf_.
size() + new_bytes > this->buf_.capacity()) {
64 if (this->
head_ > 0) {
77 dst[1] = new_len >> 8;
79 for (
const struct iovec *
end = iov + iovcnt; iov !=
end; iov++) {
84 std::memcpy(dst,
static_cast<const uint8_t *
>(iov->
iov_base) + skip,
len);
void drop_front(size_t drop)
Drop the first drop bytes, sliding the rest down. Precondition: drop <= size().
void release()
Release all memory (equivalent to std::vector swap trick).
uint8_t * append(size_t n)
Grow by n bytes; returns the new bytes, or nullptr on allocation failure.
bool reserve(size_t n) ESPHOME_ALWAYS_INLINE
Returns false if allocation fails; the buffer is left unchanged.
TCP send backlog, only used when the socket send buffer is full.
bool enqueue_iov(const struct iovec *iov, int iovcnt, size_t total_len, size_t skip)
Queue iov data from byte offset skip as one message.
static constexpr size_t LEN_PREFIX
static constexpr size_t MAX_BYTES
static constexpr size_t reserve_for(size_t want)
ssize_t try_drain(socket::Socket *socket)
Drain queued messages to the socket.
static constexpr size_t MAX_LONE_BYTES
bool release_when_drained_
constexpr T encode_value_le(const uint8_t *bytes)
Encode a value from its constituent bytes (from least to most significant) in an array with length si...