#pragma once #include #include class Buffer { public: Buffer(); ~Buffer(); Buffer(Buffer&& other); Buffer(const Buffer& other) = delete; // For now. Buffer& operator=(Buffer&&); Buffer& operator=(const Buffer&) = delete; static Result create_sized(usize size); Result try_resize(usize new_size); Result slice_at_end(usize size); Result slice(usize offset, usize size); Result append_data(const u8* data, usize size); usize dequeue_data(u8* data, usize size); u8* data() { return m_data; } const u8* data() const { return m_data; } u8* release_data(); u8* end() { return m_data + m_size; } const u8* end() const { return m_data + m_size; } usize size() const { return m_size; } bool is_empty() const { return m_size == 0; } private: Buffer(u8* data, usize size); u8* m_data { nullptr }; usize m_size { 0 }; };