datex_core/datex_values/
value.rs

1use std::fmt;
2
3use crate::global::binary_codes::BinaryCode;
4
5use super::{Error, Type};
6
7pub trait Value: mopa::Any {
8	fn to_string(&self) -> String;
9
10	fn cast(&self, dx_type: Type) -> ValueResult;
11	fn binary_operation(&self, code: BinaryCode, other: Box<dyn Value>) -> ValueResult;
12}
13
14impl fmt::Display for dyn Value {
15    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16        write!(f, "{}", Value::to_string(self))
17    }
18}
19
20mopafy!(Value);
21
22pub type ValueResult = Result<Box<dyn Value>, Error>;