Skip to main content

unitscale/
si.rs

1// Copyright 2025 GooseGrid Technologies
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! # SI prefixes
16//!
17//! Common SI prefixes as `UnitScale` for convenience.
18
19pub mod f32 {
20    use crate::prelude::unit_scale;
21
22    /// Prefix for `1E15`
23    #[unit_scale(to = 1e15)]
24    pub struct Peta;
25
26    /// Prefix for `1E12`
27    #[unit_scale(to = 1e12)]
28    pub struct Tera;
29
30    /// Prefix for `1E9`
31    #[unit_scale(to = 1e9)]
32    pub struct Giga;
33
34    /// Prefix for `1E6`
35    #[unit_scale(to = 1e6)]
36    pub struct Mega;
37
38    /// Prefix for `1E3`
39    #[unit_scale(to = 1e3)]
40    pub struct Kilo;
41
42    /// Prefix for `1E2`
43    #[unit_scale(to = 1e2)]
44    pub struct Hecto;
45
46    /// Prefix for `1E1`
47    #[unit_scale(to = 1e1)]
48    pub struct Deka;
49
50    /// Prefix for `Base scale 1.0`
51    #[unit_scale(to = 1e0)]
52    pub struct Base;
53
54    /// Prefix for `1E-1`
55    #[unit_scale(to = 1e-1)]
56    pub struct Deci;
57
58    /// Prefix for `1E-2`
59    #[unit_scale(to = 1e-2)]
60    pub struct Centi;
61
62    /// Prefix for `1E-3`
63    #[unit_scale(to = 1e-3)]
64    pub struct Milli;
65
66    /// Prefix for `1E-6`
67    #[unit_scale(to = 1e-6)]
68    pub struct Micro;
69
70    /// Prefix for `1E-9`
71    #[unit_scale(to = 1e-9)]
72    pub struct Nano;
73
74    /// Prefix for `1E-12`
75    #[unit_scale(to = 1e-12)]
76    pub struct Pico;
77
78    /// Prefix for `1E-15`
79    #[unit_scale(to = 1e-15)]
80    pub struct Femto;
81}
82
83pub mod f64 {
84    use crate::prelude::unit_scale;
85
86    /// Prefix for `1E15`
87    #[unit_scale(to = 1e15, with = "f64")]
88    pub struct Peta;
89
90    /// Prefix for `1E12`
91    #[unit_scale(to = 1e12, with = "f64")]
92    pub struct Tera;
93
94    /// Prefix for `1E9`
95    #[unit_scale(to = 1e9, with = "f64")]
96    pub struct Giga;
97
98    /// Prefix for `1E6`
99    #[unit_scale(to = 1e6, with = "f64")]
100    pub struct Mega;
101
102    /// Prefix for `1E3`
103    #[unit_scale(to = 1e3, with = "f64")]
104    pub struct Kilo;
105
106    /// Prefix for `1E2`
107    #[unit_scale(to = 1e2, with = "f64")]
108    pub struct Hecto;
109
110    /// Prefix for `1E1`
111    #[unit_scale(to = 1e1, with = "f64")]
112    pub struct Deka;
113
114    /// Prefix for `Base scale 1.0`
115    #[unit_scale(to = 1e0, with = "f64")]
116    pub struct Base;
117
118    /// Prefix for `1E-1`
119    #[unit_scale(to = 1e-1, with = "f64")]
120    pub struct Deci;
121
122    /// Prefix for `1E-2`
123    #[unit_scale(to = 1e-2, with = "f64")]
124    pub struct Centi;
125
126    /// Prefix for `1E-3`
127    #[unit_scale(to = 1e-3, with = "f64")]
128    pub struct Milli;
129
130    /// Prefix for `1E-6`
131    #[unit_scale(to = 1e-6, with = "f64")]
132    pub struct Micro;
133
134    /// Prefix for `1E-9`
135    #[unit_scale(to = 1e-9, with = "f64")]
136    pub struct Nano;
137
138    /// Prefix for `1E-12`
139    #[unit_scale(to = 1e-12, with = "f64")]
140    pub struct Pico;
141
142    /// Prefix for `1E-15`
143    #[unit_scale(to = 1e-15, with = "f64")]
144    pub struct Femto;
145}