ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
download_buffer.h
Go to the documentation of this file.
1#pragma once
2
4#include <cstddef>
5#include <cstdint>
6
7namespace esphome::online_image {
8
16 public:
17 DownloadBuffer(size_t size);
19
20 uint8_t *data(size_t offset = 0);
21 uint8_t *append() { return this->data(this->unread_); }
22
23 size_t unread() const { return this->unread_; }
24 size_t size() const { return this->size_; }
25 size_t free_capacity() const { return this->size_ - this->unread_; }
26
27 size_t read(size_t len);
28 size_t write(size_t len) {
29 this->unread_ += len;
30 return this->unread_;
31 }
32
33 void reset() { this->unread_ = 0; }
34 size_t resize(size_t size);
35
36 protected:
38 uint8_t *buffer_;
39 size_t size_;
41 size_t unread_;
42};
43
44} // namespace esphome::online_image
An STL allocator that uses SPI or internal RAM.
Definition helpers.h:1665
void deallocate(T *p, size_t n)
Definition helpers.h:1723
Buffer for managing downloaded data.
size_t unread_
Total number of downloaded bytes not yet read.
std::string size_t len
Definition helpers.h:692