pub struct TypeFunctionRegistry { /* private fields */ }Expand description
A finite overload set selected by name and complete argument identity.
Exact repeats are idempotent. Registrations merge each nominal identity’s capabilities and least diagnostic name across all recursive operands and results. Descriptors remain available for host binding and data-only projection; no resolver or emitter is retained.
§Examples
See the module example.
Implementations§
Source§impl TypeFunctionRegistry
impl TypeFunctionRegistry
Sourcepub fn with_builtins() -> Self
pub fn with_builtins() -> Self
Creates an overload set containing the builtin signatures and descriptor facts.
- Complexity: O(n) time and result space for builtin metadata area n.
§Examples
let functions = cel_parser::type_functions::TypeFunctionRegistry::with_builtins();
assert!(functions.resolve("RangeFull", &[]).is_some());Sourcepub fn register_descriptor(
&mut self,
leaf: ResolvedLeafType,
) -> Result<(), TypeFunctionError>
pub fn register_descriptor( &mut self, leaf: ResolvedLeafType, ) -> Result<(), TypeFunctionError>
Retains nominal descriptor facts for existing and future overloads.
Unions optional capabilities and selects the least retained diagnostic name per identity, including occurrences in recursive argument shapes. This does not declare a source alias or a type-function signature.
§Errors
Rejects unavailable descriptors and incompatible nominal layouts.
- Complexity: Expected O(n + r) time and peak space for new descriptor area n and combined old/new retained descriptor area r.
§Examples
use cel_parser::{ResolvedLeafType, type_functions::TypeFunctionRegistry};
let mut functions = TypeFunctionRegistry::new();
functions.register_descriptor(ResolvedLeafType::leaf::<i32>("Integer").unwrap()).unwrap();
assert_eq!(functions.descriptor(std::any::TypeId::of::<i32>()).unwrap().type_name(), "Integer");
assert_eq!(functions.signatures().count(), 0);Sourcepub fn descriptor(&self, identity: TypeId) -> Option<&ResolvedLeafType>
pub fn descriptor(&self, identity: TypeId) -> Option<&ResolvedLeafType>
Borrows the effective retained descriptor for a nominal identity, if registered.
§Examples
Sourcepub fn register(
&mut self,
name: &str,
arguments: &[ResolvedType],
result: ResolvedLeafType,
) -> Result<(), TypeFunctionError>
pub fn register( &mut self, name: &str, arguments: &[ResolvedType], result: ResolvedLeafType, ) -> Result<(), TypeFunctionError>
Registers a nominal result for the name and ordered argument identities.
Repeating a key with the same result identity merges descriptor facts: each nominal identity retains the union of optional capabilities and its least diagnostic name across arguments and results. Exact repeats are idempotent.
§Errors
Rejects non-identifiers, names exceeding 4096 bytes, reserved Fn,
incomplete descriptors, and a different result identity for an existing key.
- Complexity: Expected O(n + r) time and peak space for new descriptor/name area n and combined old/new retained descriptor area r.
§Examples
See the module example.
Sourcepub fn resolve(
&self,
name: &str,
arguments: &[TypeIdentity],
) -> Option<ResolvedLeafType>
pub fn resolve( &self, name: &str, arguments: &[TypeIdentity], ) -> Option<ResolvedLeafType>
Returns the registered result, or None for an unknown name or argument key.
- Complexity: Expected O(n + r) time and O(r) result space for name and identity shape size n and returned descriptor name size r.
§Examples
See the module example.
Sourcepub fn signatures(&self) -> impl Iterator<Item = &TypeFunctionSignature>
pub fn signatures(&self) -> impl Iterator<Item = &TypeFunctionSignature>
Borrows signatures in unspecified order.
- Complexity: O(n) to traverse n signatures.
§Examples
See the module example.