| Crates.io | dsq-functions |
| lib.rs | dsq-functions |
| version | 0.1.0 |
| created_at | 2025-12-15 17:53:25.558274+00 |
| updated_at | 2025-12-15 17:53:25.558274+00 |
| description | Built-in functions and registry for dsq |
| homepage | https://datasetq.com |
| repository | https://github.com/durableprogramming/dsq |
| max_upload_size | |
| id | 1986456 |
| size | 2,037,323 |
Built-in functions and function registry for DSQ.
dsq-functions provides a comprehensive library of built-in functions for data manipulation, transformation, and analysis in DSQ queries. The crate includes a function registry system that allows for dynamic function lookup and extensibility.
Add this to your Cargo.toml:
[dependencies]
dsq-functions = "0.1"
use dsq_functions::{call_function, FunctionRegistry};
use dsq_shared::value::Value;
fn main() {
let registry = FunctionRegistry::default();
// Call a string function
let input = Value::String("hello world".to_string());
let result = call_function("uppercase", &[input], ®istry)
.expect("Function call failed");
println!("Result: {:?}", result); // "HELLO WORLD"
}
use dsq_functions::{Function, FunctionRegistry};
use dsq_shared::value::Value;
fn main() {
let mut registry = FunctionRegistry::new();
// Register a custom function
registry.register("double", Function {
name: "double",
description: "Doubles a number",
handler: |args| {
let num = args[0].as_number()?;
Ok(Value::Number(num * 2.0))
},
});
// Use the custom function
let result = registry.call("double", &[Value::Number(5.0)])
.expect("Function call failed");
println!("Result: {:?}", result); // 10.0
}
uppercase, lowercase, capitalizesplit, join, trimcontains, startswith, endswithreplace, substringlength, reverseslugify, unidecodelength, first, last, nthmap, filter, reducesort, sort_by, reverseunique, unique_byflatten, group_byzip, unzipkeys, values, entrieshas, get, setmerge, assignpick, omitto_entries, from_entriesabs, ceil, floor, roundmin, max, sum, avgsqrt, pow, logsin, cos, tannow, date, timeformat_date, parse_dateadd_days, add_hours, add_minutesyear, month, day, hour, minute, secondtype, is_string, is_number, is_boolean, is_array, is_objectto_string, to_number, to_booleanparse_json, to_jsonbase64_encode, base64_decodebase32_encode, base32_decodebase58_encode, base58_decodeurl_encode, url_decodehex_encode, hex_decodemd5, sha1, sha256hashuuid_v4, uuid_v7uuid_parse, uuid_validateselect, empty, errorrange, repeat, limitrandom, random_intdebug, assertFor detailed API documentation, including complete function signatures and examples, see docs.rs/dsq-functions.
Functions are optimized for performance:
smartstringContributions are welcome! To add new functions:
See CONTRIBUTING.md for more details.
Licensed under either of:
at your option.