rhema_transcript/tree.rs
1//! The slot algebra: how ranges of the log are named and split.
2//!
3//! A range `(id, n)` is the `n` messages of the log from index `id` on.
4//! Larger ranges split into halves that always cover them — the tree a
5//! later compactor will grow is binary, but the algebra does not need
6//! it. This module is the contract every fill policy keeps: the lines
7//! change, the addresses never.
8
9/// A range of the log: the `n` messages from `id` on.
10#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
11pub struct Range {
12 /// Index of the first message.
13 pub id: usize,
14 /// How many messages the range covers; at least 1.
15 pub n: usize,
16}
17
18impl Range {
19 /// The range's single message: `(id, 1)`.
20 pub fn message(id: usize) -> Self {
21 Self { id, n: 1 }
22 }
23}