20typedef enum : uint32_t {
46 const double b = (double)bytes;
55 (void)snprintf(buf, cap,
"%llu B", (
unsigned long long)bytes);
76 if (elapsed_ms == 0U) {
77 (void)snprintf(buf, cap,
"-- KB/s");
80 const double bps = ((double)bytes * (double)
k_ms_per_sec) / (
double)elapsed_ms;
179 if (filled > bar_width) {
216 if (log->total == 0U) {
221 for (
size_t i = 0U; i < log->count; ++i) {
230 if (log->total > log->count) {
@ k_ms_per_sec
Milliseconds per second.
void priv_mdl_fetch_reason(ra8_err_t err, long status, char *buf, size_t cap)
Render a human-readable reason for a transfer result and HTTP status.
State-aware chapter/page download orchestrator for the media downloader.
Module-private fetch-loop decisions promoted for host unit tests and the CLI's end-of-run reporting.
@ k_mdl_reason_max
Failure-reason string buffer bytes.
static uint32_t internal_percent_pad_width(uint32_t pct)
Width of the space padding before a whole-percent value.
ra8_err_t mdl_report_progress(void *ctx, const mdl_fetch_progress_t *ev)
Per-page progress sink: print one redirect-safe line per page.
ra8_err_t mdl_report_progress_bar(void *ctx, const mdl_fetch_progress_t *ev)
Per-page progress bar sink: render an in-place terminal progress bar.
static ra8_err_t internal_report_position(ra8_err_t error, ra8_io_stream_t *output, const mdl_fetch_progress_t *ev)
Append the common chapter and page coordinates for one event.
static void internal_fmt_rate(uint64_t bytes, uint32_t elapsed_ms, char *buf, size_t cap)
Format a byte transfer rate as a compact string.
static void internal_fmt_size(uint64_t bytes, char *buf, size_t cap)
Format a byte count as a compact human-readable string.
mdl_report_scale_t
Human-readable size/rate scaling and buffer sizes.
@ k_progress_bar_width
Rendered progress-bar cells.
@ k_bytes_per_mib
Bytes in a mebibyte.
@ k_percent_scale
Whole-percent conversion scale.
@ k_percent_two_digits
First two-digit percentage.
@ k_bytes_per_kib
Bytes in a kibibyte.
@ k_human_bytes
Size/rate string buffer bytes.
ra8_err_t mdl_report_failures(ra8_io_stream_t *diagnostic, const mdl_fetch_faillog_t *log)
End-of-run summary: list every failure with its URL and reason.
Human-facing progress and failure reporting for the mdl CLI.
ra8_err_t priv_mdl_stream_text(ra8_err_t prior, ra8_io_stream_t *stream, const char *text)
Append text unless an earlier operation already failed.
ra8_err_t priv_mdl_stream_flush(ra8_err_t prior, ra8_io_stream_t *stream)
Flush a stream only when every earlier append succeeded.
ra8_err_t priv_mdl_stream_repeat(ra8_err_t prior, ra8_io_stream_t *stream, char byte, size_t count)
Append a bounded repeated byte after prior success.
ra8_err_t priv_mdl_stream_u64(ra8_err_t prior, ra8_io_stream_t *stream, uint64_t value)
Append one unsigned integer unless an earlier append failed.
Private bounded text helpers over the portable byte-stream contract.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Bounded record of every failure in a run (declare at file scope).
One per-page progress event the run emits through mdl_progress_fn.
bool reused
Page served from an already-held file.
size_t chapter_index
1-based chapter position in the run.
uint64_t page_bytes
Bytes transferred (0 when reused).
const char * chapter_id
Chapter identifier (URL leaf).
uint32_t elapsed_ms
Wall time for the transfer (0 when reused).
size_t chapter_total
Total chapters in the run.
size_t page_index
1-based page position within the chapter.
size_t page_total
Pages in the chapter.
Caller-allocated byte-stream handle binding a sink to its context.