Skip to content
/ qtty Public

A lightweight, standalone Rust crate that powers Siderust's dimensional analysis layer. It provides zero-cost type wrappers for physical quantities (length, time, angle, mass, velocity, etc.) with operator overloading and unit-aware constants so math stays readable while the compiler enforces correctness.

License

Notifications You must be signed in to change notification settings

Siderust/qtty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

119 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

qtty

Crates.io Docs.rs

Strongly typed physical and astronomy-friendly units built around a tiny, zero-cost type system.

This repository is a Cargo workspace containing four crates:

  • qtty — the user-facing crate that re-exports the core API plus curated unit modules.
  • qtty-core — the minimal type system (Quantity, Unit, Per, …) and predefined units.
  • qtty-derive — a proc-macro used to implement new Unit marker types.
  • qtty-ffi — a C-compatible ABI for constructing and converting quantities outside of Rust.

Most users should depend on the qtty crate; the other crates exist for advanced/custom use cases.

Install

[dependencies]
qtty = "0.1.0"

Disable default features for no_std (uses libm behind the scenes):

[dependencies]
qtty = { version = "0.1.0", default-features = false }

If you also need qtty::qtty_vec!(vec ...) in no_std, enable alloc:

[dependencies]
qtty = { version = "0.1.0", default-features = false, features = ["alloc"] }

Quick start

use qtty::{Degrees, Radian};

let a = Degrees::new(180.0);
let r = a.to::<Radian>();
assert!((r.value() - core::f64::consts::PI).abs() < 1e-12);

Features

  • std (default): enables std support in qtty-core.
  • cross-unit-ops (default): enables direct cross-unit comparison operators (==, <, etc.) for built-in units.
  • alloc: enables heap-backed helpers (including qtty::qtty_vec!(vec ...)) in no_std.
  • serde: serializes/deserializes Quantity<U> as bare f64 values.
  • pyo3: enables PyO3 conversions for Quantity<U> and #[pyclass] interop.

Need a C ABI? Use the companion qtty-ffi crate (see qtty-ffi/README.md).

Stability & documentation

This workspace is currently 0.x. Expect breaking changes between minor versions until 1.0.

License

Copyright (C) 2026 Vallés Puig, Ramon

This project is licensed under the GNU Affero General Public License v3.0 or later. See the LICENSE file for details.

Note for commercial or proprietary use: If you wish to incorporate this code into a closed-source or otherwise differently licensed project, a dual-licensing arrangement can be negotiated. Please contact the authors to discuss terms and conditions for a commercial or proprietary license that suits your needs.

About

A lightweight, standalone Rust crate that powers Siderust's dimensional analysis layer. It provides zero-cost type wrappers for physical quantities (length, time, angle, mass, velocity, etc.) with operator overloading and unit-aware constants so math stays readable while the compiler enforces correctness.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published