Skip to main content

JoinMode

Trait JoinMode 

Source
pub trait JoinMode: Sized + 'static {
    type RootRef: Clone + Debug + Send + Sync;
    type JoinerContext: Clone + Debug + Send + Sync;

    const REF_SIZE: usize;

    // Required methods
    fn root_address(input: &Self::RootRef) -> ChunkAddress;
    fn init_from_chunk<const BS: usize>(
        input: Self::RootRef,
        chunk: ContentChunk<BS>,
    ) -> Result<(ChunkAddress, u64, Self::JoinerContext)>;
    fn decode_body<const BS: usize>(
        chunk: ContentChunk<BS>,
        context: &Self::JoinerContext,
        span: u64,
    ) -> Result<Bytes>;
    fn parse_child_ref(
        body: &[u8],
        ref_start: usize,
    ) -> Result<(ChunkAddress, Self::JoinerContext)>;

    // Provided methods
    fn refs_per_chunk(body_size: usize) -> usize { ... }
    fn levels(length: u64, chunk_size: usize) -> usize { ... }
    fn subspan_size<const BS: usize>(span: u64) -> u64 { ... }
    fn child_span<const BS: usize>(
        parent_span: u64,
        subspan: u64,
        child_index: usize,
    ) -> u64 { ... }
}
Expand description

Joiner-side chunk mode operations.

Required Associated Constants§

Source

const REF_SIZE: usize

Size of a single reference in bytes (32 plain, 64 encrypted).

Required Associated Types§

Source

type RootRef: Clone + Debug + Send + Sync

Root reference type: ChunkAddress (plain) or EncryptedChunkRef (encrypted).

Source

type JoinerContext: Clone + Debug + Send + Sync

Per-chunk context carried through tree traversal: () (plain) or EncryptionKey.

Required Methods§

Source

fn root_address(input: &Self::RootRef) -> ChunkAddress

Extract the chunk address from a root reference (for fetching).

Source

fn init_from_chunk<const BS: usize>( input: Self::RootRef, chunk: ContentChunk<BS>, ) -> Result<(ChunkAddress, u64, Self::JoinerContext)>

Initialize joiner from a root ref and pre-fetched root chunk.

Source

fn decode_body<const BS: usize>( chunk: ContentChunk<BS>, context: &Self::JoinerContext, span: u64, ) -> Result<Bytes>

Decode a fetched chunk into body bytes (decrypting if needed).

Source

fn parse_child_ref( body: &[u8], ref_start: usize, ) -> Result<(ChunkAddress, Self::JoinerContext)>

Parse a child reference from body bytes at offset. Returns (address, child_context).

Provided Methods§

Source

fn refs_per_chunk(body_size: usize) -> usize

Number of child references per intermediate chunk.

Source

fn levels(length: u64, chunk_size: usize) -> usize

Tree depth for the given file length.

Source

fn subspan_size<const BS: usize>(span: u64) -> u64

Subspan size for a given parent span.

Source

fn child_span<const BS: usize>( parent_span: u64, subspan: u64, child_index: usize, ) -> u64

Compute the span covered by a child at child_index within a parent of parent_span.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§