use crate::{BindExpr, BuiltinFilter};
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
)]
pub enum BindingKind {
Term,
Add,
Sub,
Mul,
Div,
Neg,
Abs,
Ceil,
Floor,
Round,
Str,
StrLen,
UCase,
LCase,
Concat,
SubStr,
StrBefore,
StrAfter,
Replace,
EncodeForUri,
Md5,
Sha1,
Sha256,
Sha384,
Sha512,
CastInteger,
CastDecimal,
CastDouble,
CastFloat,
CastString,
Year,
Month,
Day,
Hours,
Minutes,
Seconds,
Timezone,
Tz,
Now,
Lang,
Iri,
BNode,
}
impl BindingKind {
pub const ALL: &'static [Self] = &[
Self::Term,
Self::Add,
Self::Sub,
Self::Mul,
Self::Div,
Self::Neg,
Self::Abs,
Self::Ceil,
Self::Floor,
Self::Round,
Self::Str,
Self::StrLen,
Self::UCase,
Self::LCase,
Self::Concat,
Self::SubStr,
Self::StrBefore,
Self::StrAfter,
Self::Replace,
Self::EncodeForUri,
Self::Md5,
Self::Sha1,
Self::Sha256,
Self::Sha384,
Self::Sha512,
Self::CastInteger,
Self::CastDecimal,
Self::CastDouble,
Self::CastFloat,
Self::CastString,
Self::Year,
Self::Month,
Self::Day,
Self::Hours,
Self::Minutes,
Self::Seconds,
Self::Timezone,
Self::Tz,
Self::Now,
Self::Lang,
Self::Iri,
Self::BNode,
];
}
impl BindExpr {
#[must_use]
pub fn kind(&self) -> BindingKind {
match self {
Self::Term(..) => BindingKind::Term,
Self::Add(..) => BindingKind::Add,
Self::Sub(..) => BindingKind::Sub,
Self::Mul(..) => BindingKind::Mul,
Self::Div(..) => BindingKind::Div,
Self::Neg(..) => BindingKind::Neg,
Self::Abs(..) => BindingKind::Abs,
Self::Ceil(..) => BindingKind::Ceil,
Self::Floor(..) => BindingKind::Floor,
Self::Round(..) => BindingKind::Round,
Self::Str(..) => BindingKind::Str,
Self::StrLen(..) => BindingKind::StrLen,
Self::UCase(..) => BindingKind::UCase,
Self::LCase(..) => BindingKind::LCase,
Self::Concat(..) => BindingKind::Concat,
Self::SubStr { .. } => BindingKind::SubStr,
Self::StrBefore(..) => BindingKind::StrBefore,
Self::StrAfter(..) => BindingKind::StrAfter,
Self::Replace { .. } => BindingKind::Replace,
Self::EncodeForUri(..) => BindingKind::EncodeForUri,
Self::Md5(..) => BindingKind::Md5,
Self::Sha1(..) => BindingKind::Sha1,
Self::Sha256(..) => BindingKind::Sha256,
Self::Sha384(..) => BindingKind::Sha384,
Self::Sha512(..) => BindingKind::Sha512,
Self::CastInteger(..) => BindingKind::CastInteger,
Self::CastDecimal(..) => BindingKind::CastDecimal,
Self::CastDouble(..) => BindingKind::CastDouble,
Self::CastFloat(..) => BindingKind::CastFloat,
Self::CastString(..) => BindingKind::CastString,
Self::Year(..) => BindingKind::Year,
Self::Month(..) => BindingKind::Month,
Self::Day(..) => BindingKind::Day,
Self::Hours(..) => BindingKind::Hours,
Self::Minutes(..) => BindingKind::Minutes,
Self::Seconds(..) => BindingKind::Seconds,
Self::Timezone(..) => BindingKind::Timezone,
Self::Tz(..) => BindingKind::Tz,
Self::Now => BindingKind::Now,
Self::Lang(..) => BindingKind::Lang,
Self::Iri(..) => BindingKind::Iri,
Self::BNode(..) => BindingKind::BNode,
}
}
}
#[derive(
Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize,
)]
pub enum FilterKind {
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
StrStarts,
StrEnds,
Contains,
RegexMatch,
IsIri,
IsLiteral,
IsBlank,
IsNumeric,
LangMatches,
And,
Or,
Not,
}
impl FilterKind {
pub const ALL: &'static [Self] = &[
Self::Eq,
Self::Ne,
Self::Lt,
Self::Le,
Self::Gt,
Self::Ge,
Self::StrStarts,
Self::StrEnds,
Self::Contains,
Self::RegexMatch,
Self::IsIri,
Self::IsLiteral,
Self::IsBlank,
Self::IsNumeric,
Self::LangMatches,
Self::And,
Self::Or,
Self::Not,
];
}
impl BuiltinFilter {
#[must_use]
pub fn kind(&self) -> FilterKind {
match self {
Self::Eq(..) => FilterKind::Eq,
Self::Ne(..) => FilterKind::Ne,
Self::Lt(..) => FilterKind::Lt,
Self::Le(..) => FilterKind::Le,
Self::Gt(..) => FilterKind::Gt,
Self::Ge(..) => FilterKind::Ge,
Self::StrStarts(..) => FilterKind::StrStarts,
Self::StrEnds(..) => FilterKind::StrEnds,
Self::Contains(..) => FilterKind::Contains,
Self::RegexMatch { .. } => FilterKind::RegexMatch,
Self::IsIri(..) => FilterKind::IsIri,
Self::IsLiteral(..) => FilterKind::IsLiteral,
Self::IsBlank(..) => FilterKind::IsBlank,
Self::IsNumeric(..) => FilterKind::IsNumeric,
Self::LangMatches(..) => FilterKind::LangMatches,
Self::And(..) => FilterKind::And,
Self::Or(..) => FilterKind::Or,
Self::Not(..) => FilterKind::Not,
}
}
}