pub struct Tile { /* private fields */ }Expand description
A C2SP tlog-tiles tile coordinate.
Identifies a tile by its level, its index within that level, and its
width in hashes. A width of TILE_WIDTH (256) is a full tile; a width
in 1..=255 is a partial tile (the rightmost tile of a tree whose size is
not a multiple of the tile span).
Implementations§
Source§impl Tile
impl Tile
Sourcepub fn new(level: u8, index: u64, width: u16) -> Result<Self>
pub fn new(level: u8, index: u64, width: u16) -> Result<Self>
Construct a tile coordinate, validating the level and width.
§Errors
Returns Error::MalformedTile if level > 63 or width is not in
1..=256.
Sourcepub fn is_partial(&self) -> bool
pub fn is_partial(&self) -> bool
Whether this is a partial tile (width < 256).
Sourcepub fn byte_len(&self) -> usize
pub fn byte_len(&self) -> usize
The number of serialized bytes a tile of this width occupies
(width * 32).
Sourcepub fn path(&self) -> String
pub fn path(&self) -> String
The Merkle tile path tile/<L>/<N>[.p/<W>].
<N> is encoded as zero-padded 3-digit path elements, all but the last
prefixed with x (e.g. index 1234067 → x001/x234/067). The
.p/<W> suffix is present only for partial tiles.
Sourcepub fn entries_path(&self) -> String
pub fn entries_path(&self) -> String
The entry-bundle path tile/entries/<N>[.p/<W>] for this tile’s index
and width. Only meaningful for level-0 coordinates, but defined purely
in terms of (index, width).
Sourcepub fn parse_path(path: &str) -> Result<Self>
pub fn parse_path(path: &str) -> Result<Self>
Parse a Merkle tile path tile/<L>/<N>[.p/<W>].
§Errors
Returns Error::MalformedTile if the path does not match the grammar,
including leading-zero levels/widths, malformed index path elements, or
an out-of-range level/width.