pub struct EchoFrame {
pub start: u32,
pub end: u32,
pub keyed: bool,
pub count: u32,
pub back_lag: Option<NonZeroU32>,
pub fwd_lag: Option<NonZeroU32>,
pub period: f32,
pub nth: u32,
}Expand description
One token’s echo reading.
Fields§
§start: u32Byte offset where the token begins, at the width Token stores it.
end: u32Byte offset just past the token, at the same width.
keyed: boolWhether the token participates in the recurrence field (word / number / quoted / typed-literal kinds at or above the length floor). Unkeyed tokens (whitespace, punctuation, brackets) carry a zero frame.
count: u32Occurrences of this token’s key in the document (1 = unique).
back_lag: Option<NonZeroU32>Byte distance back to the previous occurrence of the key, or None
when this is the first (a novel token).
Non-zero because two occurrences of one key begin at different bytes,
which is the niche that keeps the Option free: a plain Option<u32>
is eight bytes where this is four, over one frame a token.
fwd_lag: Option<NonZeroU32>Byte distance forward to the next occurrence, or None at the last,
non-zero for the same reason as EchoFrame::back_lag.
period: f32The key’s recurrence period in bytes when its lags are regular, and zero where it has none.
Zero rather than None, which saves the four bytes an Option<f32>
spends on a discriminant over one frame a token. A period is only ever
set from a mean lag the writer requires to be above zero, so zero was
never a reading this could carry and reads as the absence it is.
Zero rather than a NaN, which would be the other way to mark it and is
wrong twice here: Default gives an unkeyed token a zero frame and
f32::default() is zero, not NaN, so absence would have two spellings;
and NaN is unequal to itself, so the derived PartialEq would report two
frames with no period as different.
nth: u32This occurrence’s place among the key’s, counting from one; zero for an unkeyed token.