pub struct StructuredId(pub u32);Expand description
The prefab/item id scheme, re-exported so consumers of the manifest don’t need
a direct thread-id dependency.
A structured decimal ID encoding category, subcategory, and item number.
Tuple Fields§
§0: u32Implementations§
Source§impl StructuredId
impl StructuredId
Sourcepub fn new(category: u8, subcategory: u8, number: u16) -> StructuredId
pub fn new(category: u8, subcategory: u8, number: u16) -> StructuredId
Create a new structured ID from components.
§Panics
Panics if category is 0 or >99, subcategory >99, or number is 0 or >9999.
Sourcepub fn try_new(
category: u8,
subcategory: u8,
number: u16,
) -> Option<StructuredId>
pub fn try_new( category: u8, subcategory: u8, number: u16, ) -> Option<StructuredId>
Try to create a structured ID, returning None if components are out of range.
Sourcepub fn subcategory(&self) -> u8
pub fn subcategory(&self) -> u8
Extract the subcategory (SS) component.
Sourcepub fn to_id_string(&self) -> String
pub fn to_id_string(&self) -> String
Format as zero-padded 8-digit string “CCSSNNNN”.
Sourcepub fn parse(s: &str) -> Option<StructuredId>
pub fn parse(s: &str) -> Option<StructuredId>
Parse from an 8-digit string “CCSSNNNN”.
Sourcepub fn from_raw(val: u32) -> Option<StructuredId>
pub fn from_raw(val: u32) -> Option<StructuredId>
Create from a raw u32, validating the encoded components.
Trait Implementations§
Source§impl Clone for StructuredId
impl Clone for StructuredId
Source§fn clone(&self) -> StructuredId
fn clone(&self) -> StructuredId
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for StructuredId
Source§impl Debug for StructuredId
impl Debug for StructuredId
Source§impl<'de> Deserialize<'de> for StructuredId
impl<'de> Deserialize<'de> for StructuredId
Source§fn deserialize<D>(
deserializer: D,
) -> Result<StructuredId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<StructuredId, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for StructuredId
impl Display for StructuredId
impl Eq for StructuredId
Source§impl Hash for StructuredId
impl Hash for StructuredId
Source§impl PartialEq for StructuredId
impl PartialEq for StructuredId
Source§impl Serialize for StructuredId
impl Serialize for StructuredId
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for StructuredId
Auto Trait Implementations§
impl Freeze for StructuredId
impl RefUnwindSafe for StructuredId
impl Send for StructuredId
impl Sync for StructuredId
impl Unpin for StructuredId
impl UnsafeUnpin for StructuredId
impl UnwindSafe for StructuredId
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
Mutably borrows from an owned value. Read more