use std::any::TypeId;
use crate::func::def::{FunctionDef, ParameterBindingProvider, Parameters};
use crate::operator::Operator;
use crate::types::matcher::ExactMatcher;
use crate::types::{Type, BINARY, BOOLEAN};
#[derive(Default, Clone)]
pub struct BinaryEq;
impl FunctionDef for BinaryEq {
fn name(&self) -> &'static str {
Operator::Eq.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}
#[derive(Default, Clone)]
pub struct BinaryNeq;
impl FunctionDef for BinaryNeq {
fn name(&self) -> &'static str {
Operator::Neq.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}
#[derive(Default, Clone)]
pub struct BinaryLt;
impl FunctionDef for BinaryLt {
fn name(&self) -> &'static str {
Operator::Lt.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}
#[derive(Default, Clone)]
pub struct BinaryLte;
impl FunctionDef for BinaryLte {
fn name(&self) -> &'static str {
Operator::Lte.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}
#[derive(Default, Clone)]
pub struct BinaryGt;
impl FunctionDef for BinaryGt {
fn name(&self) -> &'static str {
Operator::Gt.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}
#[derive(Default, Clone)]
pub struct BinaryGte;
impl FunctionDef for BinaryGte {
fn name(&self) -> &'static str {
Operator::Gte.str()
}
fn parameters(&self) -> Parameters {
Parameters::new()
.with("left", ExactMatcher::of(BINARY))
.with("right", ExactMatcher::of(BINARY))
}
fn return_type(&self, _bindings: &dyn ParameterBindingProvider) -> anyhow::Result<Type> {
Ok(BOOLEAN)
}
fn type_id(&self) -> TypeId {
TypeId::of::<Self>()
}
}