35 return packets.
size();
75 packets.
back().push();
93 return {packets.
front().readSize(), std::ssize(packets)};
115 tt_parse_check(byteNr <
nrBytes,
"New-line not found within {} bytes",
nrBytes);
117 if (i == std::ssize(packets[packetNr])) {
123 ttlet c = packets[packetNr][i]
124 if (c ==
'\n' || c ==
'\0') {
126 ttlet bspan =
peek(byteNr + 1);
127 return {
reinterpret_cast<char *
>(bspan.data(), byteNr + 1};
147 ttlet packet_size = std::ssize(packets.
front());
152 tt_axiom(std::ssize(packets.
front()) > 0);
154 nrBytes -= std::ssize(packets_size);
Definition packet_buffer.hpp:10
void read(ssize_t nrBytes) noexcept
Consume the data from the buffer.
Definition packet_buffer.hpp:143
bool closed() const noexcept
Connection is closed.
Definition packet_buffer.hpp:19
ssize_t nrBytes() const noexcept
Total number of bytes in the buffer.
Definition packet_buffer.hpp:25
void close() noexcept
Close the connection on this side.
Definition packet_buffer.hpp:40
std::span< std::byte const > peek(ssize_t nrBytes)
Peek into the data without consuming.
Definition packet_buffer.hpp:86
void write(ssize_t nrBytes, bool push=true) noexcept
Write the data added to the packet.
Definition packet_buffer.hpp:71
ssize_t nrpackets() const noexcept
Total number of packets in the buffer.
Definition packet_buffer.hpp:34
std::span< std::byte > getpacket(ssize_t nrBytes) noexcept
Get a packet to write a stream of bytes into.
Definition packet_buffer.hpp:56
std::span< std::byte > getNewpacket(ssize_t nrBytes) noexcept
Get a new packet to write a message into.
Definition packet_buffer.hpp:47
std::string_view peekLine(ssize_t nrBytes=1024)
Peek into the data a single text-line without consuming.
Definition packet_buffer.hpp:110
T emplace_back(T... args)