Skip to content

ProsiaLAB/codata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codata

A lightweight, no_std Rust crate providing CODATA 2022 physical constants and IAU 2015 astronomical constants.

Usage

Direct Access & Aliases

Familiar symbols are available in the aliases module.

use codata::aliases::{C, G_SI, G_CGS, AU, M_SUN};

fn main() {
    println!("Speed of light: {} m/s", C);
    println!("G (SI):  {}", G_SI);
    println!("G (CGS): {}", G_CGS);
    println!("Solar Mass: {} kg", M_SUN);
}

Dynamic Lookup

Search constants by their official NIST/IAU name.

use codata::find;

fn main() {
    if let Some(c) = find("speed of light in vacuum") {
        println!("Value: {} {}", c.value, c.unit);
    }
}

Unit Conversions

use codata::units::length::LIGHT_YEAR;
use codata::units::time::HOUR;

let dist_m = 5.0 * LIGHT_YEAR;
let duration_s = 2.0 * HOUR;

Data Sources

License

MIT OR Apache-2.0

About

Physical and astronomical constants from CODATA 2022 and IAU 2015 releases.

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Contributors