ESPHome 2026.3.0
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 RAMAllocator<uint8_t> allocator;
20 allocator.deallocate(this->buffer_, this->size_);
21 }
22
23 uint8_t *data(size_t offset = 0);
24 uint8_t *append() { return this->data(this->unread_); }
25
26 size_t unread() const { return this->unread_; }
27 size_t size() const { return this->size_; }
28 size_t free_capacity() const { return this->size_ - this->unread_; }
29
30 size_t read(size_t len);
31 size_t write(size_t len) {
32 this->unread_ += len;
33 return this->unread_;
34 }
35
36 void reset() { this->unread_ = 0; }
37 size_t resize(size_t size);
38
39 protected:
40 uint8_t *buffer_;
41 size_t size_;
43 size_t unread_;
44};
45
46} // namespace esphome::online_image
An STL allocator that uses SPI or internal RAM.
Definition helpers.h:1899
void deallocate(T *p, size_t n)
Definition helpers.h:1954
Buffer for managing downloaded data.
size_t unread_
Total number of downloaded bytes not yet read.
std::string size_t len
Definition helpers.h:892