32 return packets.
size();
72 packets.
back().push();
90 return {packets.
front().readSize(), ssize(packets)};
112 parse_assert(byteNr <
nrBytes,
"New-line not found within {} bytes",
nrBytes);
114 if (i == ssize(packets[packetNr])) {
120 ttlet c = packets[packetNr][i]
121 if (c ==
'\n' || c ==
'\0') {
123 ttlet bspan =
peek(byteNr + 1);
124 return {
reinterpret_cast<char *
>(bspan.data(), byteNr + 1};
144 ttlet packet_size = ssize(packets.
front());
149 tt_assume(ssize(packets.
front()) > 0);
151 nrBytes -= ssize(packets_size);
Definition PacketBuffer.hpp:7
void read(ssize_t nrBytes) noexcept
Consume the data from the buffer.
Definition PacketBuffer.hpp:140
void close() noexcept
Close the connection on this side.
Definition PacketBuffer.hpp:37
ssize_t nrPackets() const noexcept
Total number of packets in the buffer.
Definition PacketBuffer.hpp:31
std::string_view peekLine(ssize_t nrBytes=1024)
Peek into the data a single text-line without consuming.
Definition PacketBuffer.hpp:107
ssize_t nrBytes() const noexcept
Total number of bytes in the buffer.
Definition PacketBuffer.hpp:22
nonstd::span< std::byte > getNewPacket(ssize_t nrBytes) noexcept
Get a new packet to write a message into.
Definition PacketBuffer.hpp:44
nonstd::span< std::byte > getPacket(ssize_t nrBytes) noexcept
Get a packet to write a stream of bytes into.
Definition PacketBuffer.hpp:53
void write(ssize_t nrBytes, bool push=true) noexcept
Write the data added to the packet.
Definition PacketBuffer.hpp:68
nonstd::span< std::byte const > peek(ssize_t nrBytes)
Peek into the data without consuming.
Definition PacketBuffer.hpp:83
bool closed() const noexcept
Connection is closed.
Definition PacketBuffer.hpp:16
T emplace_back(T... args)