7namespace hi::inline
v1 {
11 ssize_t _totalNrBytes;
37 return packets.size();
54 return {packets.back().end(),
nrBytes};
63 if (packets.empty() || (packets.back().writeSize() <
nrBytes)) {
66 return {packets.back().end(),
nrBytes};
81 packets.back().push();
94 if (packets.empty() || size() <
nrBytes) {
99 if (packets.front().readSize() >=
nrBytes) {
100 return {packets.front().readSize(), ssize(packets)};
119 ssize_t packetNr = 0;
125 if (i == ssize(packets[packetNr])) {
131 hilet c = packets[packetNr][i]
if (c ==
'\n' || c ==
'\0')
134 hilet bspan =
peek(byteNr + 1);
135 return {
reinterpret_cast<char *
>(bspan.data()), byteNr + 1};
156 hilet packet_size = ssize(packets.front());
163 nrBytes -= ssize(packets_size);
#define hi_check(expression, message,...)
Check if the expression is valid, or throw a parse_error.
Definition assert.hpp:110
#define hi_assert(expression,...)
Assert if expression is true.
Definition assert.hpp:199
DOXYGEN BUG.
Definition algorithm.hpp:13
Definition packet_buffer.hpp:9
void read(ssize_t nrBytes) noexcept
Consume the data from the buffer.
Definition packet_buffer.hpp:151
std::span< std::byte > getNewpacket(ssize_t nrBytes) noexcept
Get a new packet to write a message into.
Definition packet_buffer.hpp:50
std::string_view peekLine(ssize_t nrBytes=1024)
Peek into the data a single text-line without consuming.
Definition packet_buffer.hpp:117
std::span< std::byte const > peek(ssize_t nrBytes)
Peek into the data without consuming.
Definition packet_buffer.hpp:92
bool closed() const noexcept
Connection is closed.
Definition packet_buffer.hpp:18
std::span< std::byte > getpacket(ssize_t nrBytes) noexcept
Get a packet to write a stream of bytes into.
Definition packet_buffer.hpp:60
void close() noexcept
Close the connection on this side.
Definition packet_buffer.hpp:42
void write(ssize_t nrBytes, bool push=true) noexcept
Write the data added to the packet.
Definition packet_buffer.hpp:76
ssize_t nrBytes() const noexcept
Total number of bytes in the buffer.
Definition packet_buffer.hpp:25
ssize_t nrpackets() const noexcept
Total number of packets in the buffer.
Definition packet_buffer.hpp:35