dsq-functions
Built-in functions and function registry for DSQ.
Overview
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.
Features
- Extensive function library: Over 100+ built-in functions
- Function registry: Dynamic function registration and lookup
- Type-safe: Strong typing with automatic conversions
- Extensible: Easy to add custom functions
- Well-documented: Each function includes documentation and examples
- Platform support: Works on native and WASM targets
Installation
Add this to your Cargo.toml:
[]
= "0.1"
Usage
Using Built-in Functions
use ;
use Value;
Registering Custom Functions
use ;
use Value;
Function Categories
String Functions
uppercase,lowercase,capitalizesplit,join,trimcontains,startswith,endswithreplace,substringlength,reverseslugify,unidecode
Array Functions
length,first,last,nthmap,filter,reducesort,sort_by,reverseunique,unique_byflatten,group_byzip,unzip
Object Functions
keys,values,entrieshas,get,setmerge,assignpick,omitto_entries,from_entries
Math Functions
abs,ceil,floor,roundmin,max,sum,avgsqrt,pow,logsin,cos,tan
Date/Time Functions
now,date,timeformat_date,parse_dateadd_days,add_hours,add_minutesyear,month,day,hour,minute,second
Type Functions
type,is_string,is_number,is_boolean,is_array,is_objectto_string,to_number,to_booleanparse_json,to_json
Encoding Functions
base64_encode,base64_decodebase32_encode,base32_decodebase58_encode,base58_decodeurl_encode,url_decodehex_encode,hex_decode
Hash Functions
md5,sha1,sha256hash
UUID Functions
uuid_v4,uuid_v7uuid_parse,uuid_validate
Utility Functions
select,empty,errorrange,repeat,limitrandom,random_intdebug,assert
API Documentation
For detailed API documentation, including complete function signatures and examples, see docs.rs/dsq-functions.
Performance
Functions are optimized for performance:
- Zero-cost abstractions where possible
- Efficient string operations using
smartstring - Minimal allocations for numeric operations
- Lazy evaluation support for collection operations
Contributing
Contributions are welcome! To add new functions:
- Define the function in the appropriate module
- Register it in the function registry
- Add tests and documentation
- Submit a pull request
See CONTRIBUTING.md for more details.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.