Skip to main content

leopard_aligned_shard_len

Function leopard_aligned_shard_len 

Source
pub fn leopard_aligned_shard_len(data_len: usize, data_shards: usize) -> usize
Expand description

Computes a per-shard length, in bytes, that Leopard will accept for a payload of data_len bytes spread across data_shards data shards.

The result is always a non-zero multiple of LEOPARD_SHARD_MULTIPLE, so it is guaranteed to pass [validate_leopard_shard_len], for every input:

  • data_len == 0 (or any payload smaller than one block) clamps up to LEOPARD_SHARD_MULTIPLE.
  • data_shards == 0 is treated as a single shard (no divide-by-zero).
  • Payloads near usize::MAX saturate to the largest multiple of LEOPARD_SHARD_MULTIPLE that fits in a usize, rather than overflowing.