Skip to main content

TypeFunctionRegistry

Struct TypeFunctionRegistry 

Source
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

Source

pub fn new() -> Self

Creates an empty overload set.

§Examples

See the module example.

Source

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());
Source

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);
Source

pub fn descriptor(&self, identity: TypeId) -> Option<&ResolvedLeafType>

Borrows the effective retained descriptor for a nominal identity, if registered.

§Examples

See Self::register_descriptor.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for TypeFunctionRegistry

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for TypeFunctionRegistry

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.