Skip to main content

Tile

Struct Tile 

Source
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

Source

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.

Source

pub fn level(&self) -> u8

The tile level (0 = leaf-hash tiles).

Source

pub fn index(&self) -> u64

The tile index within its level.

Source

pub fn width(&self) -> u16

The tile width in hashes (256 for a full tile).

Source

pub fn is_partial(&self) -> bool

Whether this is a partial tile (width < 256).

Source

pub fn byte_len(&self) -> usize

The number of serialized bytes a tile of this width occupies (width * 32).

Source

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 1234067x001/x234/067). The .p/<W> suffix is present only for partial tiles.

Source

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).

Source

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.

Source

pub fn hashes(&self, bytes: &[u8]) -> Result<Vec<Hash>>

Interpret raw tile bytes as the tile’s sequence of 32-byte hashes, validating that the byte length matches the declared width.

§Errors

Returns Error::MalformedTile if bytes.len() != width * 32.

Trait Implementations§

Source§

impl Clone for Tile

Source§

fn clone(&self) -> Tile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Tile

Source§

impl Debug for Tile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Tile

Source§

impl Hash for Tile

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Tile

Source§

fn eq(&self, other: &Tile) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Tile

Auto Trait Implementations§

§

impl Freeze for Tile

§

impl RefUnwindSafe for Tile

§

impl Send for Tile

§

impl Sync for Tile

§

impl Unpin for Tile

§

impl UnsafeUnpin for Tile

§

impl UnwindSafe for Tile

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.