Skip to main content

Value

Enum Value 

Source
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

Fields

§type_name: String
§

Function

Fields

§body: Vec<Stmt>
§

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

Fields

§name: String
§fields: Vec<TypeField>
§

Enum

Fields

§enum_name: String
§field_name: String
§title: String
§

Color(Color)

§

Matrix

Fields

§element_type: String
§data: Rc<RefCell<Vec<Vec<Value<O>>>>>

Implementations§

Source§

impl<O: PineOutput> Value<O>

Source

pub fn new_color(r: u8, g: u8, b: u8, t: u8) -> Value<O>

Source§

impl<O: PineOutput> Value<O>

Source

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.

Source

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.

Source

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.

Source

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).

Source

pub fn to_bool(&self) -> Result<Option<bool>, RuntimeError>

Returns Ok(None) when self is Na. Returns Err for type mismatches.

Source

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.

Source

pub fn as_string(&self) -> Result<String, RuntimeError>

Source

pub fn as_array(&self) -> Result<&Rc<RefCell<Vec<Value<O>>>>, RuntimeError>

Source

pub fn as_color(&self) -> Result<Color, RuntimeError>

Trait Implementations§

Source§

impl<O: Clone + PineOutput> Clone for Value<O>

Source§

fn clone(&self) -> Value<O>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<O: PineOutput> Debug for Value<O>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<O: PineOutput> From<Num> for Value<O>

Source§

fn from(n: Num) -> Self

A Num carries its own type, so it lands on the matching variant.

Source§

impl<O: PineOutput> PartialEq for Value<O>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<O> !RefUnwindSafe for Value<O>

§

impl<O> !Send for Value<O>

§

impl<O> !Sync for Value<O>

§

impl<O> !UnwindSafe for Value<O>

§

impl<O> Freeze for Value<O>

§

impl<O> Unpin for Value<O>

§

impl<O> UnsafeUnpin for Value<O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.