pub enum Value<O: PineOutput> {
Show 15 variants
Int(i64),
Number(f64),
String(String),
Bool(bool),
Na,
Array(Rc<RefCell<Vec<Value<O>>>>),
Series(Series<O>),
Object {
type_name: String,
fields: Rc<RefCell<HashMap<String, Value<O>>>>,
call: Option<BuiltinFn<O>>,
},
Function {
params: Vec<FunctionParam>,
body: Vec<Stmt>,
},
BuiltinFunction(Builtin<O>),
Expr(Rc<Expr>),
Type {
name: String,
fields: Vec<TypeField>,
},
Enum {
enum_name: String,
field_name: String,
title: String,
},
Color(Color),
Matrix {
element_type: String,
data: Rc<RefCell<Vec<Vec<Value<O>>>>>,
},
}Expand description
Value types in the interpreter
Variants§
Int(i64)
Number(f64)
String(String)
Bool(bool)
Na
Array(Rc<RefCell<Vec<Value<O>>>>)
Series(Series<O>)
Object
Function
BuiltinFunction(Builtin<O>)
Expr(Rc<Expr>)
An unevaluated expression, passed to a builtin that captured it (a lazy
parameter) to run in another context — e.g. request.security.
Type
Enum
Color(Color)
Matrix
Implementations§
Source§impl<O: PineOutput> Value<O>
impl<O: PineOutput> Value<O>
Sourcepub fn as_number(&self) -> Result<f64, RuntimeError>
pub fn as_number(&self) -> Result<f64, RuntimeError>
Extract as f64. Na → NaN (propagates via IEEE 754). Type mismatch → Err.
For external callers (builtins, adapters). Internal operator code uses to_number.
Sourcepub fn as_bool(&self) -> Result<bool, RuntimeError>
pub fn as_bool(&self) -> Result<bool, RuntimeError>
Extract as bool. Na → false (Pine v6: booleans are never na). Type mismatch → Err.
For external callers. Internal conditional code uses truthy_for_condition.
Sourcepub fn as_num(&self) -> Option<Num>
pub fn as_num(&self) -> Option<Num>
This value as a Num, preserving whether it is an int or a float, so
callers can apply Pine’s overload rule. None for na and for anything
non-numeric.
Sourcepub fn to_number(&self) -> Result<Option<f64>, RuntimeError>
pub fn to_number(&self) -> Result<Option<f64>, RuntimeError>
Returns Ok(None) when self is Na so callers can propagate na correctly. Returns Err for genuine type mismatches (e.g. passing a string to arithmetic).
Sourcepub fn to_bool(&self) -> Result<Option<bool>, RuntimeError>
pub fn to_bool(&self) -> Result<Option<bool>, RuntimeError>
Returns Ok(None) when self is Na. Returns Err for type mismatches.
Sourcepub fn truthy_for_condition(&self) -> Result<bool, RuntimeError>
pub fn truthy_for_condition(&self) -> Result<bool, RuntimeError>
For conditional boundaries only (if, while, ternary). Pine v6: na in a condition takes the false/else branch.