Function registry#
parcel_core::Registry maps function names to the definitions used when checking and compiling expressions. Its supporting types are in parcel_core::registry.
Registry methods#
impl Registry {
pub fn builtin() -> Self;
pub fn insert(&mut self, entry: FunctionEntry);
pub fn get(&self, name: &str) -> Option<&FunctionEntry>;
pub fn visible_to(&self, owner: Option<&str>) -> Registry;
pub fn entries(&self) -> impl Iterator<Item = &FunctionEntry>;
}
Method |
Arguments and result |
|---|---|
|
Creates a registry containing parcel’s built-in functions. |
|
Takes ownership of an entry; replaces any entry with the same name. |
|
Looks up a name and borrows the entry, or returns |
|
Creates a registry containing built-ins and functions for the supplied owner; |
|
Borrows all current entries through an iterator. |
use parcel_core::Registry;
let registry = Registry::builtin();
let redact = registry.get("redact").expect("built-in function");
assert!(redact.is_builtin());
FunctionEntry#
Field |
Type |
Meaning |
|---|---|---|
|
|
Function name used in expressions. |
|
|
Function revision. |
|
|
Supported argument and return types. |
|
|
Whether identical inputs produce identical outputs. |
|
|
Null handling; currently |
|
|
Execution cost: |
|
|
Optimization hint: |
|
|
Owner identifier; built-ins use |
|
|
Hash of implementation identity and manifest. |
|
|
WebAssembly module hash, or |
impl FunctionEntry {
pub fn user(
manifest: &FunctionManifest,
owner: &str,
module_sha256: &str,
) -> Result<FunctionEntry, String>;
pub fn pin(&self) -> FunctionPin;
pub fn is_builtin(&self) -> bool;
}
user constructs metadata from a manifest, owner, and module hash; invalid names or signatures return an error. It does not load executable code. wasm::install loads the module and creates an entry together. pin returns the exact implementation identity. is_builtin is true when module is absent.
FunctionManifest#
Field |
Type |
Meaning |
|---|---|---|
|
|
Exported function name. |
|
|
Function revision. |
|
|
Signature strings, such as |
|
|
Defaults to |
|
|
Defaults to |
Signature and FunctionPin#
Type |
Public fields |
|---|---|
|
|
|
|
pub fn parse_signature(s: &str) -> Result<Signature, String>;
Parses a signature such as (string, int) -> bool. Returns an error for malformed signatures or unsupported scalar types.