Skip to main content

NumberDomain

Trait NumberDomain 

Source
pub trait NumberDomain: RuntimeObject {
    // Required methods
    fn symbol(&self) -> Symbol;
    fn parse_literal(&self, cx: &mut Cx, text: &str) -> Result<Option<Value>>;
    fn encode_literal(
        &self,
        cx: &mut Cx,
        value: Value,
    ) -> Result<Option<NumberLiteral>>;

    // Provided methods
    fn parse_priority(&self) -> i32 { ... }
    fn promotions(&self) -> Vec<PromotionRule> { ... }
}
Expand description

Runtime protocol for a numeric semantic domain.

A number domain owns parsing, canonical encoding, and promotion rules for a family of number literals. Domains are runtime objects so they can be registered, reflected, browsed, and exported like other SIM values.

Required Methods§

Source

fn symbol(&self) -> Symbol

Symbol uniquely identifying this domain.

Source

fn parse_literal(&self, cx: &mut Cx, text: &str) -> Result<Option<Value>>

Parses literal text into a domain value, or Ok(None) if not ours.

Source

fn encode_literal( &self, cx: &mut Cx, value: Value, ) -> Result<Option<NumberLiteral>>

Encodes a value back to a canonical literal, or Ok(None) if not ours.

Provided Methods§

Source

fn parse_priority(&self) -> i32

Tie-breaking priority when several domains can parse the same text.

Source

fn promotions(&self) -> Vec<PromotionRule>

Promotion rules originating from this domain; empty by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§