expression

Decode a small versioned diagnostic record

A compact diagnostic record can carry reset information without heap allocation. This educational format has exactly three bytes: format version 1 and a little-endian event code. It rejects unsupported versions and malformed lengths. It is not a crash-safe persistent log or a target reset-register format. Expected host stdout (not executed): diagnostic format checked Common mistake: Assuming a Rust struct layout is a stable serialized format.

Formal Syntax & Structure

rust syntaxrust
u16::from_le_bytes; match version

Working Example

Example Snippetrust
#![no_std]pub fn event_code(bytes: &[u8]) -> Option<u16> {    match bytes { [1, lo, hi] => Some(u16::from_le_bytes([*lo, *hi])), _ => None }}
Rust Reference