Struct rink_core::context::Context [−][src]
The evaluation context that contains unit definitions.
Fields
dimensions: BTreeSet<Dimension>
canonicalizations: BTreeMap<String, String>
units: BTreeMap<String, Number>
quantities: BTreeMap<Quantity, String>
reverse: BTreeMap<Quantity, String>
prefixes: Vec<(String, Number)>
definitions: BTreeMap<String, Expr>
docs: BTreeMap<String, String>
categories: BTreeMap<String, String>
category_names: BTreeMap<String, String>
datepatterns: Vec<Vec<DatePattern>>
substances: BTreeMap<String, Substance>
substance_symbols: BTreeMap<String, String>
temporaries: BTreeMap<String, Number>
now: DateTime<Utc>
short_output: bool
use_humanize: bool
Implementations
impl Context
[src]
pub fn new() -> Context
[src]
Creates a new, empty context
pub fn set_time(&mut self, time: DateTime<Utc>)
[src]
pub fn update_time(&mut self)
[src]
pub fn load_dates(&mut self, dates: Vec<Vec<DatePattern>>)
[src]
pub fn lookup(&self, name: &str) -> Option<Number>
[src]
Given a unit name, returns its value if it exists. Supports SI prefixes, plurals, bare dimensions like length, and quantities.
pub fn canonicalize(&self, name: &str) -> Option<String>
[src]
Given a unit name, try to return a canonical name (expanding aliases and such)
pub fn describe_unit(&self, value: &Number) -> (bool, String)
[src]
Describes a value’s unit, gives true if the unit is reciprocal (e.g. you should prefix “1.0 / “ or replace “multiply” with “divide” when rendering it).
pub fn typo_dym<'a>(&'a self, what: &str) -> Option<&'a str>
[src]
pub fn unknown_unit_err(&self, name: &str) -> NotFoundError
[src]
impl Context
[src]
impl Context
[src]
pub fn eval(&self, expr: &Expr) -> Result<Value, QueryError>
[src]
Evaluates an expression to compute its value, excluding ->
conversions.
pub fn eval_unit_name(
&self,
expr: &Expr
) -> Result<(BTreeMap<String, isize>, Numeric), QueryError>
[src]
&self,
expr: &Expr
) -> Result<(BTreeMap<String, isize>, Numeric), QueryError>
pub fn show(
&self,
raw: &Number,
bottom: &Number,
bottom_name: BTreeMap<String, isize>,
bottom_const: Numeric,
base: u8,
digits: Digits
) -> ConversionReply
[src]
&self,
raw: &Number,
bottom: &Number,
bottom_name: BTreeMap<String, isize>,
bottom_const: Numeric,
base: u8,
digits: Digits
) -> ConversionReply
pub fn eval_outer(&self, expr: &Query) -> Result<QueryReply, QueryError>
[src]
Evaluates an expression, include ->
conversions.
impl Context
[src]
pub fn load(&mut self, defs: Defs)
[src]
Takes a parsed definitions.units from
gnu_units::parse()
. Prints if there are errors in the file.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Context
impl Send for Context
impl Sync for Context
impl Unpin for Context
impl UnwindSafe for Context
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,