Skip to main content

Chunk

Trait Chunk 

Source
pub trait Chunk:
    Send
    + Sync
    + 'static {
    type Header: ChunkHeader;

    // Required methods
    fn address(&self) -> &ChunkAddress;
    fn header(&self) -> &Self::Header;
    fn data(&self) -> &Bytes;

    // Provided methods
    fn size(&self) -> usize { ... }
    fn verify(&self, expected: &ChunkAddress) -> Result<()> { ... }
}
Expand description

Core trait for all chunk types in the system.

This trait defines the common interface that all chunk implementations must provide. Each implementation must specify its type ID and version as associated constants.

Required Associated Types§

Source

type Header: ChunkHeader

The header type for this chunk

Required Methods§

Source

fn address(&self) -> &ChunkAddress

Get the address of this chunk

Source

fn header(&self) -> &Self::Header

Get the header for this chunk

Source

fn data(&self) -> &Bytes

Get the raw data contained in this chunk

Provided Methods§

Source

fn size(&self) -> usize

Get the total size of this chunk in bytes

Source

fn verify(&self, expected: &ChunkAddress) -> Result<()>

Verify that this chunk matches an expected address

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<const BODY_SIZE: usize> Chunk for ContentChunk<BODY_SIZE>

Source§

type Header = ContentChunkHeader

Source§

impl<const BODY_SIZE: usize> Chunk for SingleOwnerChunk<BODY_SIZE>

Source§

type Header = SingleOwnerChunkHeader