pub struct BlockSize(/* private fields */);
Expand description
A block size.
Block sizes are powers of 2, with the smallest being 1024 bytes. They are encoded as the power of 2, minus 10, so 1 is 1024 bytes, 2 is 2048 bytes, etc.
Since only powers of 2 are valid, the log2 of the size in bytes / 1024 is given in the constructor. So a block size of 0 is 1024 bytes, 1 is 2048 bytes, etc.
The actual size in bytes can be computed with BlockSize::bytes.
Implementations§
Source§impl BlockSize
impl BlockSize
Sourcepub const ZERO: BlockSize
pub const ZERO: BlockSize
The default block size, 1024 bytes
This means that blocks and blake3 chunks are the same size.
Sourcepub const fn from_chunk_log(chunk_log: u8) -> Self
pub const fn from_chunk_log(chunk_log: u8) -> Self
Create a block size from the log2 of the size in bytes / 1024
0 is 1024 bytes, 1 is 2048 bytes, etc.
Sourcepub const fn from_bytes(bytes: u64) -> Option<Self>
pub const fn from_bytes(bytes: u64) -> Option<Self>
Compute a block size from bytes
Trait Implementations§
Source§impl Ord for BlockSize
impl Ord for BlockSize
Source§impl PartialOrd for BlockSize
impl PartialOrd for BlockSize
impl Copy for BlockSize
impl Eq for BlockSize
impl StructuralPartialEq for BlockSize
Auto Trait Implementations§
impl Freeze for BlockSize
impl RefUnwindSafe for BlockSize
impl Send for BlockSize
impl Sync for BlockSize
impl Unpin for BlockSize
impl UnwindSafe for BlockSize
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more