pub struct ExtensionDataTypeId(pub u32);Expand description
Stable u32 id for an extension variant.
Extension ids are generated deterministically from a stable name via
ExtensionDataTypeId::from_name. A crate that never changes its
extension name keeps the same id across versions, which is the
wire-format contract: a Program encoded by v1.0 of an extension
decodes identically in v1.1 so long as the name is stable.
Tuple Fields§
§0: u32Implementations§
Source§impl ExtensionDataTypeId
impl ExtensionDataTypeId
Sourcepub const EXTENSION_RANGE_MASK: u32 = 0x8000_0000
pub const EXTENSION_RANGE_MASK: u32 = 0x8000_0000
Reserved range: every extension id has its high bit set.
Core IR discriminants occupy 0x00..=0x7F; extensions occupy
0x80..=0xFFFF_FFFF. Wire decoders test the high byte to route
decoding between the two.
Sourcepub const fn from_name(name: &str) -> Self
pub const fn from_name(name: &str) -> Self
Construct an id from a stable extension name.
The id is derived deterministically: callers that pass the same
name always get the same id. Wire encoders serialize this id
directly; decoders on a machine with the same extension crate
linked resolve it back to the original trait vtable.
The implementation hashes name with FNV-1a and folds the
32-bit result into the extension range by setting the high
bit. Two collision-free names produce two distinct ids with
overwhelming probability.
Sourcepub const fn is_extension(self) -> bool
pub const fn is_extension(self) -> bool
Is this a reserved extension id (high bit set)?
Trait Implementations§
Source§impl Clone for ExtensionDataTypeId
impl Clone for ExtensionDataTypeId
Source§fn clone(&self) -> ExtensionDataTypeId
fn clone(&self) -> ExtensionDataTypeId
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more