* Send as many of the bytes as possible in the packet. This can mean * that it is possible that not all bytes are sent. To cope with this * the function returns the span of bytes that were not sent. * @param span The span describing the range of bytes to send. * @return The span of bytes that were not written. */
| 195 | * @return The span of bytes that were not written. |
| 196 | */ |
| 197 | std::span<const uint8_t> Packet::Send_bytes(const std::span<const uint8_t> span) |
| 198 | { |
| 199 | size_t amount = std::min<size_t>(span.size(), this->limit - this->Size()); |
| 200 | this->buffer.insert(this->buffer.end(), span.data(), span.data() + amount); |
| 201 | return span.subspan(amount); |
| 202 | } |
| 203 | |
| 204 | /* |
| 205 | * Receiving commands |
no test coverage detected