rayforce 1.0.1

Convenient, high-performance Rust bindings for RayforceDB v2
//! The [`Operation`] enum — RayforceDB builtin operators, identified by their
//! Rayfall name string. Expressions and queries compile to ASTs whose heads are
//! name references to these builtins (mirrors `rayforce-py/types/operators.py`).

/// A RayforceDB builtin operation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub enum Operation {
    // Arithmetic
    Add,
    Subtract,
    Multiply,
    Divide,
    Modulo,
    DivInt,
    Negate,
    // Comparison
    Equals,
    NotEquals,
    GreaterThan,
    GreaterEqual,
    LessThan,
    LessEqual,
    Like,
    // Logical
    And,
    Or,
    Not,
    // Aggregation
    Sum,
    Avg,
    Count,
    Min,
    Max,
    First,
    Last,
    Median,
    Deviation,
    Stddev,
    PearsonCorr,
    Row,
    // Statistical / math
    Xbar,
    Ceil,
    Floor,
    Round,
    Rand,
    // Collection
    In,
    Distinct,
    Reverse,
    Group,
    Take,
    Top,
    Bot,
    Remove,
    Filter,
    Find,
    Within,
    Sect,
    Except,
    Union,
    Raze,
    // Query
    Select,
    Update,
    Insert,
    Upsert,
    Where,
    // Join
    InnerJoin,
    LeftJoin,
    AsofJoin,
    WindowJoin,
    WindowJoin1,
    // Sort
    Asc,
    Desc,
    Xasc,
    Xdesc,
    Iasc,
    Idesc,
    Rank,
    Xrank,
    // Accessor
    At,
    Key,
    Value,
    Get,
    // Functional
    Map,
    MapLeft,
    MapRight,
    Pmap,
    Fold,
    Scan,
    Apply,
    // Composition
    Til,
    Enlist,
    // Type
    List,
    Type,
    As,
    Guid,
    NilQ,
    // Temporal
    Date,
    Time,
    Timestamp,
    // Serialization / eval
    Ser,
    De,
    Parse,
    Eval,
    Quote,
    Load,
    // Control flow
    Do,
    If,
    Try,
    Return,
    Raise,
    // Variables
    Set,
    Let,
    Env,
    // Data structures
    Dict,
    Table,
    Concat,
    // Metadata
    Meta,
    Rc,
}

impl Operation {
    /// The Rayfall builtin name this operation compiles to.
    pub fn as_str(self) -> &'static str {
        use Operation::*;
        match self {
            Add => "+",
            Subtract => "-",
            Multiply => "*",
            Divide => "/",
            Modulo => "%",
            DivInt => "div",
            Negate => "neg",
            Equals => "==",
            NotEquals => "!=",
            GreaterThan => ">",
            GreaterEqual => ">=",
            LessThan => "<",
            LessEqual => "<=",
            Like => "like",
            And => "and",
            Or => "or",
            Not => "not",
            Sum => "sum",
            Avg => "avg",
            Count => "count",
            Min => "min",
            Max => "max",
            First => "first",
            Last => "last",
            Median => "med",
            Deviation => "dev",
            Stddev => "stddev",
            PearsonCorr => "pearson_corr",
            Row => "row",
            Xbar => "xbar",
            Ceil => "ceil",
            Floor => "floor",
            Round => "round",
            Rand => "rand",
            In => "in",
            Distinct => "distinct",
            Reverse => "reverse",
            Group => "group",
            Take => "take",
            Top => "top",
            Bot => "bot",
            Remove => "remove",
            Filter => "filter",
            Find => "find",
            Within => "within",
            Sect => "sect",
            Except => "except",
            Union => "union",
            Raze => "raze",
            Select => "select",
            Update => "update",
            Insert => "insert",
            Upsert => "upsert",
            Where => "where",
            InnerJoin => "inner-join",
            LeftJoin => "left-join",
            AsofJoin => "asof-join",
            WindowJoin => "window-join",
            WindowJoin1 => "window-join1",
            Asc => "asc",
            Desc => "desc",
            Xasc => "xasc",
            Xdesc => "xdesc",
            Iasc => "iasc",
            Idesc => "idesc",
            Rank => "rank",
            Xrank => "xrank",
            At => "at",
            Key => "key",
            Value => "value",
            Get => "get",
            Map => "map",
            MapLeft => "map-left",
            MapRight => "map-right",
            Pmap => "pmap",
            Fold => "fold",
            Scan => "scan",
            Apply => "apply",
            Til => "til",
            Enlist => "enlist",
            List => "list",
            Type => "type",
            As => "as",
            Guid => "guid",
            NilQ => "nil?",
            Date => "date",
            Time => "time",
            Timestamp => "timestamp",
            Ser => "ser",
            De => "de",
            Parse => "parse",
            Eval => "eval",
            Quote => "quote",
            Load => "load",
            Do => "do",
            If => "if",
            Try => "try",
            Return => "return",
            Raise => "raise",
            Set => "set",
            Let => "let",
            Env => "env",
            Dict => "dict",
            Table => "table",
            Concat => "concat",
            Meta => "meta",
            Rc => "rc",
        }
    }
}

impl std::fmt::Display for Operation {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        f.write_str(self.as_str())
    }
}