enshwick 1.0.0-alpha.8

The Enshwick Loader's modding API for Enshrouded: the one crate mods are written against
Documentation
//! The id the game gives each item.

/// An item of the game by the number its item data gives it, as a prop's
/// `UsedItem` names the item the prop was placed from.
///
/// # Examples
///
/// ```
/// use enshwick::ItemId;
///
/// let torch = ItemId::from(1_042);
/// assert_eq!(torch.get(), 1_042);
/// assert_eq!(torch, ItemId::new(1_042));
/// ```
#[derive(
    Clone,
    Copy,
    Debug,
    Default,
    PartialEq,
    Eq,
    Hash,
    PartialOrd,
    Ord,
    serde::Serialize,
    serde::Deserialize,
)]
#[serde(transparent)]
pub struct ItemId(u32);

impl ItemId {
    /// The item the game numbers `id`, in a `const` too.
    ///
    /// # Examples
    ///
    /// See [`ItemId`].
    #[must_use]
    pub const fn new(id: u32) -> Self {
        Self(id)
    }

    /// The game's number for the item.
    ///
    /// # Examples
    ///
    /// See [`ItemId`].
    #[must_use]
    pub const fn get(self) -> u32 {
        self.0
    }
}

impl From<u32> for ItemId {
    fn from(id: u32) -> Self {
        Self(id)
    }
}

impl From<ItemId> for u32 {
    fn from(item: ItemId) -> Self {
        item.0
    }
}