pub struct ChunkTypeId(/* private fields */);Expand description
Wire-level chunk type identifier.
This type represents the type ID byte used in chunk headers for serialization and deserialization dispatch. It provides type-safe constants for known chunk types and supports custom types.
§Type ID Ranges
0-127: Reserved for standard Swarm chunk types128-255: Available for custom/experimental chunk types
§Examples
use nectar_primitives::ChunkTypeId;
// Use predefined constants
let content_type = ChunkTypeId::CONTENT;
let soc_type = ChunkTypeId::SINGLE_OWNER;
// Create custom type ID
let custom_type = ChunkTypeId::custom(200);
// Compare type IDs
assert_ne!(content_type, soc_type);
assert_eq!(content_type.as_u8(), 0);Implementations§
Source§impl ChunkTypeId
impl ChunkTypeId
Sourcepub const CONTENT: Self
pub const CONTENT: Self
Content-addressed chunk type (CAC).
These chunks have their address derived from the BMT hash of their content.
Sourcepub const SINGLE_OWNER: Self
pub const SINGLE_OWNER: Self
Single-owner chunk type (SOC).
These chunks include owner identification and a digital signature.
Sourcepub const fn new(id: u8) -> Self
pub const fn new(id: u8) -> Self
Create a new chunk type ID from a raw byte value.
This is a const fn allowing use in const contexts.
Sourcepub const fn custom(id: u8) -> Self
pub const fn custom(id: u8) -> Self
Create a custom chunk type ID.
Custom types should use IDs in the range 128-255 to avoid conflicts with standard types.
§Examples
use nectar_primitives::ChunkTypeId;
let custom = ChunkTypeId::custom(200);
assert!(custom.is_custom());Sourcepub const fn is_standard(self) -> bool
pub const fn is_standard(self) -> bool
Check if this is a standard (reserved) type ID.
Standard types have IDs in the range 0-127.
Sourcepub const fn is_custom(self) -> bool
pub const fn is_custom(self) -> bool
Check if this is a custom type ID.
Custom types have IDs in the range 128-255.
Sourcepub const fn name(self) -> Option<&'static str>
pub const fn name(self) -> Option<&'static str>
Get the human-readable name for known type IDs.
Returns None for unknown or custom types.
Sourcepub const fn abbreviation(self) -> Option<&'static str>
pub const fn abbreviation(self) -> Option<&'static str>
Get the abbreviated name for known type IDs.
Returns common abbreviations like “CAC” for content-addressed chunks
and “SOC” for single-owner chunks. Returns None for unknown or custom types.
§Examples
use nectar_primitives::ChunkTypeId;
assert_eq!(ChunkTypeId::CONTENT.abbreviation(), Some("CAC"));
assert_eq!(ChunkTypeId::SINGLE_OWNER.abbreviation(), Some("SOC"));
assert_eq!(ChunkTypeId::custom(200).abbreviation(), None);Trait Implementations§
Source§impl Clone for ChunkTypeId
impl Clone for ChunkTypeId
Source§fn clone(&self) -> ChunkTypeId
fn clone(&self) -> ChunkTypeId
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ChunkTypeId
Source§impl Debug for ChunkTypeId
impl Debug for ChunkTypeId
Source§impl Display for ChunkTypeId
impl Display for ChunkTypeId
impl Eq for ChunkTypeId
Source§impl From<ChunkTypeId> for u8
impl From<ChunkTypeId> for u8
Source§fn from(id: ChunkTypeId) -> Self
fn from(id: ChunkTypeId) -> Self
Source§impl From<u8> for ChunkTypeId
impl From<u8> for ChunkTypeId
Source§impl Hash for ChunkTypeId
impl Hash for ChunkTypeId
Source§impl PartialEq for ChunkTypeId
impl PartialEq for ChunkTypeId
Source§fn eq(&self, other: &ChunkTypeId) -> bool
fn eq(&self, other: &ChunkTypeId) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ChunkTypeId
Auto Trait Implementations§
impl Freeze for ChunkTypeId
impl RefUnwindSafe for ChunkTypeId
impl Send for ChunkTypeId
impl Sync for ChunkTypeId
impl Unpin for ChunkTypeId
impl UnsafeUnpin for ChunkTypeId
impl UnwindSafe for ChunkTypeId
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more