1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! Chunk type trait
//!
//! This module provides the [`ChunkType`] trait which adds compile-time type
//! information to chunk implementations.
use Chunk;
use ChunkTypeId;
/// 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`](ChunkType::TYPE_ID)
/// - Type-safe serialization/deserialization
/// - Generic programming over chunk types
///
/// # Implementing ChunkType
///
/// All implementations must also implement:
/// - [`Chunk`] trait
/// - [`TryFrom<Bytes>`] for deserialization
/// - [`Into<Bytes>`] for serialization
///
/// # Example
///
/// ```ignore
/// 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";
/// }
/// ```