mirror of
https://github.com/gorules/zen.git
synced 2026-10-05 08:02:28 +00:00
* feat: date v2 * implement more date functions * improve type safety * add more methods for dates * update utc to tz and add support * add unary node behaviour for date methods * add tests; fix errors in bindings * add date operators * fix types * change set date signature * update nightly
59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
pub use crate::functions::date_method::DateMethod;
|
|
pub use crate::functions::defs::FunctionTypecheck;
|
|
pub use crate::functions::deprecated::DeprecatedFunction;
|
|
pub use crate::functions::internal::InternalFunction;
|
|
pub use crate::functions::method::{MethodKind, MethodRegistry};
|
|
pub use crate::functions::registry::FunctionRegistry;
|
|
|
|
use std::fmt::Display;
|
|
use strum_macros::{Display, EnumIter, EnumString, IntoStaticStr};
|
|
|
|
pub(crate) mod arguments;
|
|
mod date_method;
|
|
pub(crate) mod defs;
|
|
mod deprecated;
|
|
pub(crate) mod internal;
|
|
mod method;
|
|
pub(crate) mod registry;
|
|
|
|
#[derive(Debug, PartialEq, Eq, Clone)]
|
|
pub enum FunctionKind {
|
|
Internal(InternalFunction),
|
|
Deprecated(DeprecatedFunction),
|
|
Closure(ClosureFunction),
|
|
}
|
|
|
|
impl TryFrom<&str> for FunctionKind {
|
|
type Error = strum::ParseError;
|
|
|
|
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
|
InternalFunction::try_from(value)
|
|
.map(FunctionKind::Internal)
|
|
.or_else(|_| DeprecatedFunction::try_from(value).map(FunctionKind::Deprecated))
|
|
.or_else(|_| ClosureFunction::try_from(value).map(FunctionKind::Closure))
|
|
}
|
|
}
|
|
|
|
impl Display for FunctionKind {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
match self {
|
|
FunctionKind::Internal(i) => write!(f, "{i}"),
|
|
FunctionKind::Deprecated(d) => write!(f, "{d}"),
|
|
FunctionKind::Closure(c) => write!(f, "{c}"),
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, PartialEq, Eq, Hash, Display, EnumString, EnumIter, IntoStaticStr, Clone, Copy)]
|
|
#[strum(serialize_all = "camelCase")]
|
|
pub enum ClosureFunction {
|
|
All,
|
|
None,
|
|
Some,
|
|
One,
|
|
Filter,
|
|
Map,
|
|
FlatMap,
|
|
Count,
|
|
}
|