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§
Sourcefn parse_literal(&self, cx: &mut Cx, text: &str) -> Result<Option<Value>>
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.
Sourcefn encode_literal(
&self,
cx: &mut Cx,
value: Value,
) -> Result<Option<NumberLiteral>>
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§
Sourcefn parse_priority(&self) -> i32
fn parse_priority(&self) -> i32
Tie-breaking priority when several domains can parse the same text.
Sourcefn promotions(&self) -> Vec<PromotionRule>
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".