unitscale 0.1.6

Facade crate for statically-scaled unit macros and traits.
Documentation
// Copyright 2025 GooseGrid Technologies
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![doc = include_str!("../README.md")]

/// Core traits and types (e.g., `UnitScale`, `Scaled`)
pub mod core {
    pub use unitscale_core::*;
}

/// Procedural macros (`unit_data`, `unit_scale`)
pub mod macros {
    pub use unitscale_macros::*;
}

/// SI `UnitScale` prefixes for convenience
pub mod si;

/// Common imports for users
pub mod prelude {
    pub use crate::core::{Scaled, ScaledPrimitiveByteSize, UnitScale, UnitScaleError};
    pub use crate::macros::{unit_data, unit_scale};
}

#[cfg(test)]
mod tests {
    use crate::prelude::*;

    #[unit_scale(to = 0.5)]
    struct Scale0_5;

    #[unit_data]
    struct HalfData;

    #[test]
    fn macro_test() {
        let data: HalfData<Scale0_5, u16> = HalfData::try_from(100.0).expect("Unable to convert");
        let result: u16 = 200;

        assert_eq!(data.scaled_value(), result);
    }
}