Skip to main content

Expr

Struct Expr 

Source
pub struct Expr { /* private fields */ }

Implementations§

Source§

impl Expr

Source

pub fn identity() -> Expr

Source

pub fn lit(value: impl Into<AnyValue<'static>>) -> Expr

Source

pub fn range(sel: impl Into<Range<usize>>) -> Expr

Source

pub fn select(name: impl Into<SmallStr>) -> Expr

Source

pub fn warmup(period: usize) -> When

Source

pub fn when(cond: impl Into<Expr>) -> When

Source

pub fn every(interval: usize) -> When

Source

pub fn throttle(duration: Duration) -> When

Source

pub fn time(self) -> Expr

Source

pub fn value(self) -> Expr

Source

pub fn debug(self) -> Expr

Source

pub fn attr(self, attr: impl Into<SmallStr>) -> Expr

Source

pub fn rolling(self, window_size: usize) -> Expr

Source

pub fn coalesce(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn first(self) -> Expr

Source

pub fn last(self) -> Expr

Source

pub fn sum(self) -> Expr

Source

pub fn mean(self) -> Expr

Source

pub fn stddev(self) -> Expr

Source

pub fn min(self) -> Expr

Source

pub fn max(self) -> Expr

Source

pub fn var(self) -> Expr

Source

pub fn skew(self) -> Expr

Source

pub fn count(self) -> Expr

Source

pub fn slope(self) -> Expr

Source

pub fn unique(self) -> Expr

Source

pub fn pow(self, exp: impl Into<Expr>) -> Expr

Source

pub fn lt(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn lte(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn gt(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn gte(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn eq(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn ne(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn between(self, low: impl Into<Expr>, high: impl Into<Expr>) -> Expr

Source

pub fn and(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn or(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn not(self) -> Expr

Source

pub fn neg(self) -> Expr

Source

pub fn abs(self) -> Expr

Source

pub fn add(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn sub(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn mul(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn div(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn clamp(self, min: impl Into<Expr>, max: impl Into<Expr>) -> Expr

Source

pub fn or_else(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn min_with(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn max_with(self, rhs: impl Into<Expr>) -> Expr

Source

pub fn quantile(self, q: f32) -> Expr

Source

pub fn stagnation(self, epsilon: f32) -> Expr

Source

pub fn cast(self, to: DataType) -> Expr

Source

pub fn error(self, target: f32) -> Expr

Relative error from a target: (self - target) / target. Fuses into a single Affine node. target == 0 produces a degenerate expression (division by zero shows up as a NaN/Inf at eval time, then propagates to the outer Clamp).

Source§

impl Expr

Source

pub fn compile(self) -> Expr

Walks the tree bottom-up and rewrites algebraically equivalent shapes into the smallest possible form. Specifically:

  • Pure-literal subtrees fold (Lit(2) + Lit(3)Lit(5))
  • Add / Sub / Mul / Div with one literal operand fuses into a Unary(Affine) (x * 5 + 3Affine { scale: 5, bias: 3 })
  • Nested affines collapse: s2 * (s1*x + b1) + b2Affine(s2*s1, s2*b1 + b2)
Source§

impl Expr

Source

pub fn new(node: ExprNode) -> Self

Source

pub fn id(&self) -> ExprId

Source

pub fn name(&self) -> &str

Source

pub fn alias(self, name: impl Into<SmallStr>) -> Self

Source

pub fn is_literal(&self) -> bool

Source

pub fn is_selector(&self) -> bool

Source

pub fn is_schedule(&self) -> bool

Source

pub fn into_schedule(self) -> Option<Expr>

Source

pub fn walk(&self, f: &mut impl FnMut(&Expr))

Source§

impl Expr

Source

pub fn trigger(&mut self) -> Result<AnyValue<'a>, RadiateError>

Source

pub fn evaluate<'a>( &'a mut self, input: &'a impl ProjectExpr<'a>, ) -> Result<AnyValue<'a>, RadiateError>

Trait Implementations§

Source§

impl<T> Add<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Expr

Performs the + operation. Read more
Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Debug for Expr

Source§

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

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

impl<T> Div<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> Expr

Performs the / operation. Read more
Source§

impl<'a> From<AnyValue<'a>> for Expr

Source§

fn from(value: AnyValue<'a>) -> Self

Converts to this type from the input type.
Source§

impl From<Expr> for ExprSet

Source§

fn from(expr: Expr) -> Self

Converts to this type from the input type.
Source§

impl From<SelectOp> for Expr

Source§

fn from(selector: SelectOp) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Expr

Source§

fn from(value: String) -> Self

Converts to this type from the input type.
Source§

impl From<When> for Expr

Source§

fn from(val: When) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Expr

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Expr

Source§

fn from(value: char) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Expr

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Expr

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Expr

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Expr

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Expr

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Expr

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Expr

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Expr

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Expr

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Expr

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Expr

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Expr

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for Expr

Source§

fn from(value: usize) -> Self

Converts to this type from the input type.
Source§

impl<T> Mul<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> Expr

Performs the * operation. Read more
Source§

impl Neg for Expr

Source§

type Output = Expr

The resulting type after applying the - operator.
Source§

fn neg(self) -> Expr

Performs the unary - operation. Read more
Source§

impl Not for Expr

Source§

type Output = Expr

The resulting type after applying the ! operator.
Source§

fn not(self) -> Expr

Performs the unary ! operation. Read more
Source§

impl PartialEq for Expr

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Expr

Source§

impl<T> Sub<T> for Expr
where T: Into<Expr>,

Source§

type Output = Expr

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Expr

Performs the - operation. Read more
Source§

impl TryFrom<Expr> for f32

Source§

type Error = RadiateError

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

fn try_from(value: Expr) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.