drasi_core/evaluation/functions/
numeric.rs

1// Copyright 2024 The Drasi Authors.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15mod abs;
16mod ceil;
17mod floor;
18mod numeric_round;
19mod random;
20mod sign;
21
22#[cfg(test)]
23mod tests;
24
25use std::sync::Arc;
26
27pub use abs::Abs;
28pub use ceil::Ceil;
29pub use floor::Floor;
30pub use numeric_round::Round;
31pub use random::Rand;
32pub use sign::Sign;
33
34use super::{Function, FunctionRegistry};
35
36pub trait RegisterNumericFunctions {
37    fn register_numeric_functions(&self);
38}
39
40impl RegisterNumericFunctions for FunctionRegistry {
41    fn register_numeric_functions(&self) {
42        self.register_function("abs", Function::Scalar(Arc::new(Abs {})));
43        self.register_function("ceil", Function::Scalar(Arc::new(Ceil {})));
44        self.register_function("floor", Function::Scalar(Arc::new(Floor {})));
45        self.register_function("rand", Function::Scalar(Arc::new(Rand {})));
46        self.register_function("round", Function::Scalar(Arc::new(Round {})));
47        self.register_function("sign", Function::Scalar(Arc::new(Sign {})));
48    }
49}