Module block

Module block 

Source
Expand description

Content-addressed data blocks.

This module provides the Block type, which represents a piece of data along with its content identifier (Cid). Blocks are the fundamental storage unit in IPFS-style systems.

§Example

use ipfrs_core::Block;
use bytes::Bytes;

// Create a block from data
let block = Block::new(Bytes::from_static(b"Hello!")).unwrap();

// Access the CID and data
println!("CID: {}", block.cid());
assert_eq!(block.data().as_ref(), b"Hello!");

// Verify the block's integrity
assert!(block.verify().unwrap());

§Size Limits

Blocks have size constraints for network efficiency:

Structs§

Block
A content-addressed data block.
BlockBuilder
Builder for creating blocks with custom CID settings.
BlockMetadata
Metadata about a block for indexing and queries.

Constants§

MAX_BLOCK_SIZE
Maximum block size in bytes (2 MiB, same as IPFS default)
MIN_BLOCK_SIZE
Minimum block size in bytes