macro_rules! define_context_function {
(
$struct_name:ident,
$func_name:literal,
() -> $ret:ident,
$impl_fn:expr
) => { ... };
}Expand description
Define a context-aware scalar function that needs access to EvalContext.
Context-aware functions are not pure (they depend on session state) but are not async. They synchronously access context information like session::ns(), session::db(), etc.
§Usage
ⓘ
// Function with no arguments that reads from context
define_context_function!(
SessionNs, // Struct name
"session::ns", // Function name
() -> Any, // Signature: () -> return type
session_ns_impl // Implementation function
);