9#include <libnuraft/buffer.hxx>
17 nuraft_serializer::operator bool()
const {
22 m_buf.pos(m_buf.pos() + len);
31 return m_buf.pos() >= m_buf.size();
35 if(m_buf.pos() + len > m_buf.size()) {
39 auto data_vec = std::vector<nuraft::byte>(len);
40 std::memcpy(data_vec.data(), data, len);
41 m_buf.put_raw(data_vec.data(), len);
46 if(m_buf.pos() + len > m_buf.size()) {
50 std::memcpy(data, m_buf.get_raw(len), len);
auto end_of_buffer() const -> bool final
Returns whether the cursor is currently at the end of the buffer.
void reset() final
Resets the cursor to the start of the buffer.
auto read(void *data, size_t len) -> bool final
Reads the given number of bytes from the current cursor in the buffer into the given destination.
auto write(const void *data, size_t len) -> bool final
Writes the given raw bytes to the buffer from the current position of the cursor.
void advance_cursor(size_t len) final
Moves the cursor inside the buffer forward by the given number of bytes.
nuraft_serializer(nuraft::buffer &buf)
Constructor.