Skip to main content

ChunkType

Trait ChunkType 

Source
pub trait ChunkType: Chunk + Sized {
    const TYPE_ID: ChunkTypeId;
    const TYPE_NAME: &'static str;
}
Expand description

Trait for chunk types with compile-time type information.

This trait extends Chunk with static type metadata, enabling:

  • Compile-time type identification via TYPE_ID
  • Type-safe serialization/deserialization
  • Generic programming over chunk types

§Implementing ChunkType

All implementations must also implement:

§Example

use nectar_primitives::{Chunk, ChunkType, ChunkTypeId};

struct MyCustomChunk { /* ... */ }

impl ChunkType for MyCustomChunk {
    const TYPE_ID: ChunkTypeId = ChunkTypeId::custom(200);
    const TYPE_NAME: &'static str = "my_custom";
}

Required Associated Constants§

Source

const TYPE_ID: ChunkTypeId

The wire-level type identifier for this chunk type.

This ID is used in chunk headers for serialization and must be unique across all chunk types in a system.

Source

const TYPE_NAME: &'static str

Human-readable name for this chunk type.

Used for logging, debugging, and error messages.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§

Source§

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

Source§

const TYPE_ID: ChunkTypeId = super::type_id::ChunkTypeId::CONTENT

Source§

const TYPE_NAME: &'static str = "content"

Source§

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

Source§

const TYPE_ID: ChunkTypeId = super::type_id::ChunkTypeId::SINGLE_OWNER

Source§

const TYPE_NAME: &'static str = "single_owner"