https://github.com/deebloo/metrum
https://github.com/deebloo/metrum
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/deebloo/metrum
- Owner: deebloo
- License: mit
- Created: 2023-09-21T13:44:50.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T13:42:09.000Z (over 1 year ago)
- Last Synced: 2025-04-06T15:35:26.295Z (over 1 year ago)
- Language: Rust
- Size: 140 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# metrum
Easily handle measurement values in rust.
The goal is to work with measurements without needing to think about about units until you absolutely have to.
## Length
| Unit | Constructor | Conversion |
| ---- | ----------- | ---------- |
| | | |
### Units
| Unit | Constructor | Conversion |
| ----------- | --------------------- | ------------- |
| Celcius | `Temp::from_c(value)` | `temp.as_c()` |
| Farenheight | `Temp::from_f(value)` | `temp.as_f()` |
| Kelvin | `Temp::from_k(value)` | `temp.as_k()` |
## Speed
| Unit | Constructor | Conversion |
| ----- | ------------------------- | ----------------- |
| MPS | `Temp::from_mps(value)` | `temp.as_mps()` |
| KPH | `Temp::from_kph(value)` | `temp.as_kph()` |
| MPH | `Temp::from_mph(value)` | `temp.as_mph()` |
| Knots | `Temp::from_knots(value)` | `temp.as_knots()` |
## Temp
| Unit | Constructor | Conversion |
| ----------- | --------------------- | ------------- |
| Celcius | `Temp::from_c(value)` | `temp.as_c()` |
| Farenheight | `Temp::from_f(value)` | `temp.as_f()` |
| Kelvin | `Temp::from_k(value)` | `temp.as_k()` |
```rust
use metrum::Temp;
use metrum::temp::TempDelta;
let from_f = Temp::from_f(32.);
let from_c = Temp::from_c(0.);
assert_eq!(from_f, from_c);
assert_eq!(from_f - from_c, TempDelta { value: 0. });
```
## Weight
| Unit | Constructor | Conversion |
| ---- | ----------- | ---------- |
| | | |
## Serde
Values can be safely serialized and deserialized using serde when the `serde` feature is enabled.
```toml
[dependencies]
metrum = { version = "*", features = ["serde"] }
```
## WASM
Metrum has limited compatibility with WASM and wasm-packg
```toml
[dependencies]
metrum = { version = "*", features = ["wasm"] }
```