Skip to content

Commit

Permalink
schema: add to_u16 const methods to type ids
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 18, 2024
1 parent 352442e commit d6bba7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/schema/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use crate::LIB_NAME_RGB_COMMIT;
pub struct AssignmentType(u16);
impl AssignmentType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
#[inline]
pub fn to_le_bytes(&self) -> [u8; 2] { self.0.to_le_bytes() }
}
Expand All @@ -58,6 +59,7 @@ impl AssignmentType {
pub struct ValencyType(u16);
impl ValencyType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
}

pub type MetaSchema = TinyOrdSet<MetaType>;
Expand Down
4 changes: 4 additions & 0 deletions src/schema/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use crate::{
pub struct MetaType(u16);
impl MetaType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
}

#[derive(Wrapper, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, From, Display)]
Expand All @@ -72,6 +73,7 @@ impl MetaType {
pub struct GlobalStateType(u16);
impl GlobalStateType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
}

#[derive(Wrapper, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, From, Display)]
Expand All @@ -87,6 +89,7 @@ impl GlobalStateType {
pub struct ExtensionType(u16);
impl ExtensionType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
}

#[derive(Wrapper, Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug, From, Display)]
Expand All @@ -102,6 +105,7 @@ impl ExtensionType {
pub struct TransitionType(u16);
impl TransitionType {
pub const fn with(ty: u16) -> Self { Self(ty) }
pub const fn to_u16(&self) -> u16 { self.0 }
}

impl TransitionType {
Expand Down

0 comments on commit d6bba7a

Please sign in to comment.