si+x86_64 +linux

si

A module for parsing, converting, and formatting physical quantities expressed in the International System of Units.

# Parsing

# Formatting

Index

Types

type dimension;
type encoding;
type notation;
type quantity;
type unit;

// Undocumented types:
type unexpected;

Errors

// Undocumented Errors:
type dimension_mismatch;
type divide_by_zero;
type error;
type invalid;
type invalid_exponent;
type no_match;
type not_implemented;
type unexpected_token;

Globals

// Undocumented globals:
const GIT_VERSION: str;
const SEM_VERSION: str;

Functions

fn div(a: unit, b: unit) (unit | divide_by_zero);
fn encodejson(out: io::handle, obj: (quantity | unit)) (size | error);
fn fprintq(h: io::handle, qty: quantity, unit_format: (str | void) = void, prec: (uint | void) = void, repr: notation = notation::GENERAL, enc: encoding = encoding::UTF8) (size | error);
fn fprintu(h: io::handle, u: unit) (size | error);
fn mul(a: unit, b: unit) unit;
fn pow_unit(a: unit, exp: int) unit;
fn tojson(obj: (quantity | unit)) (str | error);

// Undocumented functions:
fn count(s: str) size;
fn fprintqln(h: io::handle, qty: quantity, unit_format: (str | void) = void, prec: (uint | void) = void, repr: notation = notation::GENERAL, enc: encoding = encoding::UTF8) (size | error);
fn fprintuln(h: io::handle, u: unit) (size | error);
fn parse(s: str) (quantity | error);
fn printerror(err: error) (void | io::error);
fn strerror(err: error) str;

Types

type dimension[permalink]

type dimension = struct {
	// mass
	mass: int,
	// length
	length: int,
	// time
	time: int,
	// electric current
	current: int,
	// thermodynamic temperature
	temperature: int,
	// amount of substance
	substance: int,
	// luminous intensity
	luminosity: int,
};

Represents the dimensional exponents of the seven SI base dimensions.

type encoding[permalink]

type encoding = enum u8 {
	ASCII,
	UTF8,
	JSON,
};

Specifies the character encoding options.

type notation[permalink]

type notation = enum u8 {
	GENERAL,
	FIXED,
	SCIENTIFIC,
	E_UPPER,
	E_LOWER,
};

Specifies the notation used to format floating-point values.

type quantity[permalink]

type quantity = struct {
	unit: unit,
	value: f64,
};

Represents a physical quantity as a unit and numerical value.

type unit[permalink]

type unit = struct {
	dim: dimension,
	scale: f64,
};

Represents a unit of measurement by its physical dimension and scale.

type unexpected[permalink]

Show undocumented member
type unexpected = struct {
	pos: size,
	exp: str,
	got: str,
};

Errors

type dimension_mismatch[permalink]

Show undocumented member
type dimension_mismatch = !void;

type divide_by_zero[permalink]

Show undocumented member
type divide_by_zero = !void;

type error[permalink]

Show undocumented member
type error = !(no_match | divide_by_zero | invalid_exponent | dimension_mismatch | unexpected_token | not_implemented | invalid | io::error | strconv::invalid | strconv::overflow | utf8::invalid | nomem);

type invalid[permalink]

Show undocumented member
type invalid = !void;

type invalid_exponent[permalink]

Show undocumented member
type invalid_exponent = !rune;

type no_match[permalink]

Show undocumented member
type no_match = !str;

type not_implemented[permalink]

Show undocumented member
type not_implemented = !str;

type unexpected_token[permalink]

Show undocumented member
type unexpected_token = !rune;

Globals

let GIT_VERSION[permalink]

Show undocumented member
const GIT_VERSION: str;

let SEM_VERSION[permalink]

Show undocumented member
const SEM_VERSION: str;

Functions

fn div[permalink]

fn div(a: unit, b: unit) (unit | divide_by_zero);

Returns the quotiant of a and b.

fn encodejson[permalink]

fn encodejson(out: io::handle, obj: (quantity | unit)) (size | error);

Writes JSON encoded representation of a quantity or unit.

fn fprintq[permalink]

fn fprintq(h: io::handle, qty: quantity, unit_format: (str | void) = void, prec: (uint | void) = void, repr: notation = notation::GENERAL, enc: encoding = encoding::UTF8) (size | error);

Prints a quantity to stdout.

fn fprintu[permalink]

fn fprintu(h: io::handle, u: unit) (size | error);

Prints a unit to stdout.

fn mul[permalink]

fn mul(a: unit, b: unit) unit;

Returns the product of a and b.

fn pow_unit[permalink]

fn pow_unit(a: unit, exp: int) unit;

Returns the value of a raised to the power of b.

fn tojson[permalink]

fn tojson(obj: (quantity | unit)) (str | error);

Returns JSON encoded string representation of a quantity or unit.

fn count[permalink]

Show undocumented member
fn count(s: str) size;

fn fprintqln[permalink]

Show undocumented member
fn fprintqln(h: io::handle, qty: quantity, unit_format: (str | void) = void, prec: (uint | void) = void, repr: notation = notation::GENERAL, enc: encoding = encoding::UTF8) (size | error);

fn fprintuln[permalink]

Show undocumented member
fn fprintuln(h: io::handle, u: unit) (size | error);

fn parse[permalink]

Show undocumented member
fn parse(s: str) (quantity | error);

fn printerror[permalink]

Show undocumented member
fn printerror(err: error) (void | io::error);

fn strerror[permalink]

Show undocumented member
fn strerror(err: error) str;