usbhidusage 0.1.3

A general purpose library for working with usb Human Interface Device Descriptors from the HID Usage Tables for Universal Serial Bus (USB) v1.5
Documentation
#[derive(Clone, Copy, PartialEq, PartialOrd, Ord, Eq, Hash, Debug, Default)]
#[non_exhaustive]
#[repr(u16)]
pub enum ScalesUsage {
    #[default]
    Undefined,
    Scales,
    Reserved02_1F(u16),
    ScaleDevice = 0x20,
    ScaleClass,
    ScaleClassIMetric,
    ScaleClassIIMetric,
    ScaleClassIIIMetric,
    ScaleClassIIILMetric,
    ScaleClassIVMetric,
    ScaleClassIIIEnglish,
    ScaleClassIIILEnglish,
    ScaleClassIVEnglish,
    ScaleClassGeneric,
    Reserved2B_2F(u16),
    ScaleAttributeReport = 0x30,
    ScaleControlReport,
    ScaleDataReport,
    ScaleStatusReport,
    ScaleWeightLimitReport,
    ScaleStatisticsReport,
    Reserved36_3F(u16),
    DataWeight = 0x40,
    DataScaling,
    Reserved42_4F(u16),
    WeightUnit = 0x50,
    WeightUnitMilligram,
    WeightUnitGram,
    WeightUnitKilogram,
    WeightUnitCarats,
    WeightUnitTaels,
    WeightUnitGrains,
    WeightUnitPennyweights,
    WeightUnitMetricTon,
    WeightUnitAvoirTon,
    WeightUnitTroyOunce,
    WeightUnitOunce,
    WeightUnitPound,
    Reserved5D_5F(u16),
    CalibrationCount = 0x60,
    Re_ZeroCount,
    Reserved62_6F(u16),
    ScaleStatus = 0x70,
    ScaleStatusFault,
    ScaleStatusStableatCenterofZero,
    ScaleStatusInMotion,
    ScaleStatusWeightStable,
    ScaleStatusUnderZero,
    ScaleStatusOverWeightLimit,
    ScaleStatusRequiresCalibration,
    ScaleStatusRequiresRezeroing,
    Reserved79_7F(u16),
    ZeroScale = 0x80,
    EnforcedZeroReturn,
    Reserved82_FFFF(u16),
}
impl<T> From<T> for ScalesUsage
where
    T: TryInto<u16>,
{
    fn from(value: T) -> Self {
        let value: u16 = value.try_into().unwrap_or(0);

        match value {
            0 => Self::Undefined,
            1 => Self::Scales,
            2..32 => Self::Reserved02_1F(value),
            32 => Self::ScaleDevice,
            33 => Self::ScaleClass,
            34 => Self::ScaleClassIMetric,
            35 => Self::ScaleClassIIMetric,
            36 => Self::ScaleClassIIIMetric,
            37 => Self::ScaleClassIIILMetric,
            38 => Self::ScaleClassIVMetric,
            39 => Self::ScaleClassIIIEnglish,
            40 => Self::ScaleClassIIILEnglish,
            41 => Self::ScaleClassIVEnglish,
            42 => Self::ScaleClassGeneric,
            43..48 => Self::Reserved2B_2F(value),
            48 => Self::ScaleAttributeReport,
            49 => Self::ScaleControlReport,
            50 => Self::ScaleDataReport,
            51 => Self::ScaleStatusReport,
            52 => Self::ScaleWeightLimitReport,
            53 => Self::ScaleStatisticsReport,
            54..64 => Self::Reserved36_3F(value),
            64 => Self::DataWeight,
            65 => Self::DataScaling,
            66..80 => Self::Reserved42_4F(value),
            80 => Self::WeightUnit,
            81 => Self::WeightUnitMilligram,
            82 => Self::WeightUnitGram,
            83 => Self::WeightUnitKilogram,
            84 => Self::WeightUnitCarats,
            85 => Self::WeightUnitTaels,
            86 => Self::WeightUnitGrains,
            87 => Self::WeightUnitPennyweights,
            88 => Self::WeightUnitMetricTon,
            89 => Self::WeightUnitAvoirTon,
            90 => Self::WeightUnitTroyOunce,
            91 => Self::WeightUnitOunce,
            92 => Self::WeightUnitPound,
            93..96 => Self::Reserved5D_5F(value),
            96 => Self::CalibrationCount,
            97 => Self::Re_ZeroCount,
            98..112 => Self::Reserved62_6F(value),
            112 => Self::ScaleStatus,
            113 => Self::ScaleStatusFault,
            114 => Self::ScaleStatusStableatCenterofZero,
            115 => Self::ScaleStatusInMotion,
            116 => Self::ScaleStatusWeightStable,
            117 => Self::ScaleStatusUnderZero,
            118 => Self::ScaleStatusOverWeightLimit,
            119 => Self::ScaleStatusRequiresCalibration,
            120 => Self::ScaleStatusRequiresRezeroing,
            121..128 => Self::Reserved79_7F(value),
            128 => Self::ZeroScale,
            129 => Self::EnforcedZeroReturn,
            130..=65535 => Self::Reserved82_FFFF(value),
        }
    }
}