ESPHome 2026.11.0-dev
Loading...
Searching...
No Matches
esphome::online_image::DownloadSource Class Reference

Lets a decoder read a download as it arrives, from the download buffer. More...

#include <download_buffer.h>

Inheritance diagram for esphome::online_image::DownloadSource:
esphome::runtime_image::DecodeSource

Public Member Functions

 DownloadSource (DownloadBuffer &buffer)
 
void reset ()
 Start again at the beginning of a new download, keeping what is read.
 
void set_keep_read (bool keep)
 
void compact ()
 Drop the bytes the decoder has read, to make room for more of the download.
 
int32_t read (uint8_t *buf, uint32_t len) override
 
bool seek (uint32_t position) override
 
- Public Member Functions inherited from esphome::runtime_image::DecodeSource
virtual ~DecodeSource ()=default
 

Protected Attributes

DownloadBuffer & buffer_
 
size_t start_ {0}
 
size_t pos_ {0}
 
bool keep_read_ {true}
 

Detailed Description

Lets a decoder read a download as it arrives, from the download buffer.

The decoder reads at its own position in the buffer. Bytes it has read stay there until compact() drops them, and compact() keeps everything while set_keep_read(true) is in effect, so the decoder can seek back while it reads the headers.

Definition at line 56 of file download_buffer.h.

Constructor & Destructor Documentation

◆ DownloadSource()

esphome::online_image::DownloadSource::DownloadSource ( DownloadBuffer & buffer)
inlineexplicit

Definition at line 58 of file download_buffer.h.

Member Function Documentation

◆ compact()

void esphome::online_image::DownloadSource::compact ( )

Drop the bytes the decoder has read, to make room for more of the download.

Definition at line 38 of file download_buffer.cpp.

◆ read()

int32_t esphome::online_image::DownloadSource::read ( uint8_t * buf,
uint32_t len )
overridevirtual

Implements esphome::runtime_image::DecodeSource.

Definition at line 45 of file download_buffer.cpp.

◆ reset()

void esphome::online_image::DownloadSource::reset ( )
inline

Start again at the beginning of a new download, keeping what is read.

Definition at line 61 of file download_buffer.h.

◆ seek()

bool esphome::online_image::DownloadSource::seek ( uint32_t position)
overridevirtual

Implements esphome::runtime_image::DecodeSource.

Definition at line 53 of file download_buffer.cpp.

◆ set_keep_read()

void esphome::online_image::DownloadSource::set_keep_read ( bool keep)
inline

Definition at line 66 of file download_buffer.h.

Field Documentation

◆ buffer_

DownloadBuffer& esphome::online_image::DownloadSource::buffer_
protected

Definition at line 74 of file download_buffer.h.

◆ keep_read_

bool esphome::online_image::DownloadSource::keep_read_ {true}
protected

Definition at line 77 of file download_buffer.h.

◆ pos_

size_t esphome::online_image::DownloadSource::pos_ {0}
protected

Definition at line 76 of file download_buffer.h.

◆ start_

size_t esphome::online_image::DownloadSource::start_ {0}
protected

Definition at line 75 of file download_buffer.h.


The documentation for this class was generated from the following files: