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:
- Minimum: 1 byte (
MIN_BLOCK_SIZE) - Maximum: 2 MiB (
MAX_BLOCK_SIZE)
Structs§
- Block
- A content-addressed data block.
- Block
Builder - Builder for creating blocks with custom CID settings.
- Block
Metadata - 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