Rust strings contain UTF-8 data and slice indices therefore refer to byte positions and both ends of the range must fall on valid UTF-8 character boundaries in source

To explain it a little bit, for ASCII text, each character occupies one byte

I N F O
0 1 2 3

So this is valid:

let level = "INFO";
let slice = &level[0..4];

Some Unicode characters occupy multiple bytes:

let text = String::from("नमस्ते");

A range such as &text[0..1] may stop in the middle of an encoded character. Rust will panic rather than produce an invalid string slice.

Our parser will avoid guessing field positions using arbitrary numeric indices. It will locate ASCII separators such as spaces and prefixes such as token=.

The timestamp, level, field names, and token in our format are expected to be ASCII. The message itself may contain any valid UTF-8 text.