29static const char*
const s_tag =
"ra8_io_stream";
37typedef enum : uint32_t {
74 if (s->
iface ==
nullptr) {
83 if ((stream ==
nullptr) || (iface ==
nullptr) || (context ==
nullptr)) {
86 if (iface->
write ==
nullptr) {
102 uint32_t accepted = 0U;
104 if (accepted > len) {
107 if (out_written !=
nullptr) {
108 *out_written = accepted;
110 if ((error ==
k_ra8_ok) && (accepted != len)) {
134 const uint8_t b = (uint8_t)c;
147 if (str[len] ==
'\0') {
170 for (uint32_t j = 0; j < i; ++j) {
171 out[j] = tmp[i - 1U - j];
183 uint32_t digits = 0U;
184 uint64_t remaining = value;
189 }
while (remaining != 0U);
191 for (uint32_t index = 0U; index < digits; ++index) {
192 output[index] = reversed[digits - 1U - index];
203 if (min_digits == 0U) {
209 static const char k_hex[] =
"0123456789abcdef";
218 while (i < (uint32_t)min_digits) {
219 tmp[i] = (uint8_t)
'0';
223 for (uint32_t j = 0; j < i; ++j) {
224 out[j] = tmp[i - 1U - j];
static const char * s_tag
Logging / check tag.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_not_initialized
Module not initialized – _init() not yet called successfully.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
ra8_err_t ra8_io_stream_write(ra8_io_stream_t *s, const uint8_t *buf, uint32_t len, uint32_t *out_written)
Write len bytes to the bound sink.
ra8_err_t ra8_io_stream_puts(ra8_io_stream_t *s, const char *str)
Write a NUL-terminated string (without the NUL) to the bound sink.
ra8_err_t ra8_io_stream_put_u32(ra8_io_stream_t *s, uint32_t value)
Write value as unsigned decimal ASCII (no leading zeros).
ra8_err_t ra8_io_stream_bind(ra8_io_stream_t *stream, const ra8_io_stream_iface_t *iface, void *context)
Bind a backend vtable and caller-owned state into a stream handle.
ra8_err_t ra8_io_stream_flush(ra8_io_stream_t *s)
Flush any sink-side buffering to its destination.
ra8_err_t ra8_io_stream_put_u64(ra8_io_stream_t *s, uint64_t value)
Write value as unsigned 64-bit decimal ASCII without leading zeros.
ra8_err_t ra8_io_stream_putc(ra8_io_stream_t *s, char c)
Write a single byte to the bound sink.
ra8_io_stream_const_t
Rendering constants for the formatted-output helpers.
@ k_ra8_io_dec_base
Base for ra8_io_stream_put_u32.
@ k_ra8_io_hex_max_digits
Hex digits in a 32-bit value.
@ k_ra8_io_u64_max_digits
Decimal digits in UINT64_MAX.
@ k_ra8_io_puts_max
Bounded scan limit for ra8_io_stream_puts.
@ k_ra8_io_u32_max_digits
Decimal digits in UINT32_MAX.
@ k_ra8_io_hex_base
Base for ra8_io_stream_put_hex.
static ra8_err_t internal_validate(const ra8_io_stream_t *s)
Reject a handle that is NULL or has no sink bound.
ra8_err_t ra8_io_stream_put_hex(ra8_io_stream_t *s, uint32_t value, uint8_t min_digits)
Write value as lowercase hex ASCII, zero-padded to min_digits.
ra8_io targetable byte-stream facade – one writer, many destinations.
struct ra8_io_stream_iface ra8_io_stream_iface_t
Public implementer contract for ra8_io byte-stream backends.
ra8_err_t(* flush)(void *ctx)
Commit any buffering.
ra8_err_t(* write)(void *ctx, const uint8_t *buf, uint32_t len, uint32_t *out_written)
Write len bytes from buf, reporting the accepted count.
Caller-allocated byte-stream handle binding a sink to its context.
const ra8_io_stream_iface_t * iface
Bound sink vtable (private).
void * ctx
Sink-private context (private).