Skip to main content

CheckingBuilder

Struct CheckingBuilder 

Source
pub struct CheckingBuilder { /* private fields */ }
Expand description

Builds an offline catalog by reading retained host registration facts.

Runtime descriptors remain in the caller’s registrations, never in the finished environment.

§Examples

See the module example.

Implementations§

Source§

impl CheckingBuilder

Source

pub fn register_type_function( &mut self, name: &str, arguments: &[ResolvedType], result: &ResolvedLeafType, ) -> Result<(), MetadataError>

Projects one nominal overload without executing a host resolver or emitter.

Repeated keys and result identities merge nominal descriptor facts. Exact repeats are idempotent.

§Errors

Rejects invalid constructor names, incomplete descriptors, conflicting results, and zero-operand names bound to a different source alias identity.

  • Complexity: O(n · m + k · s) time and O(n) retained space for incoming descriptor area n, retained nominal metadata area m, k existing signatures, and largest compared argument/name area s.
§Examples
use cel_parser::{ResolvedLeafType, checking::CheckingBuilder};
let mut builder = CheckingBuilder::new();
let argument = ResolvedLeafType::leaf::<i32>("Integer").unwrap().into();
let result = ResolvedLeafType::leaf::<std::ops::Range<i32>>("Bounds").unwrap();
builder.register_type_function("Bounds", &[argument], &result).unwrap();
assert!(builder.finish().is_ok());
Source

pub fn register_type_functions( &mut self, functions: &TypeFunctionRegistry, ) -> Result<(), MetadataError>

Projects retained argument and result descriptors without invoking callbacks.

§Errors

Reports invalid or conflicting registrations as Self::register_type_function.

  • Complexity: O(n · m + k² · s) time and O(n) retained space for incoming descriptor area n, combined nominal metadata area m, combined signature count k, and largest compared argument/name area s.
§Examples
let functions = cel_parser::type_functions::TypeFunctionRegistry::new();
let mut builder = cel_parser::checking::CheckingBuilder::new();
builder.register_type_functions(&functions).unwrap();
Source

pub fn new() -> Self

Creates a builder seeded with language primitive and range contracts.

§Examples

See the module example.

Source

pub fn register_type( &mut self, name: &str, leaf: &ResolvedLeafType, default_available: bool, ) -> Result<(), MetadataError>

Registers a source alias and default availability for a concrete host leaf.

  • Complexity: Expected O(m + l) time for retained type and signature metadata area m (including alias entries and name bytes) and incoming names’ bytes l; O(l) additional name storage.
§Errors

Rejects names exceeding metadata limits and conflicting source aliases or zero-operand type functions. Self::finish additionally validates source alias grammar.

§Examples
let mut builder = cel_parser::checking::CheckingBuilder::new();
let leaf = cel_parser::ResolvedLeafType::leaf::<std::path::PathBuf>("Path").unwrap();
builder.register_type("Path", &leaf, false).unwrap();
Source

pub fn set_default_available( &mut self, leaf: &ResolvedLeafType, available: bool, ) -> Result<(), MetadataError>

Selects the effective host default availability for an already registered leaf.

Unlike adding an alias, this replaces prior availability, including builtin defaults. It does not construct a value.

§Errors

Rejects leaves not registered in this builder.

§Examples
use cel_parser::{checking::*, ResolvedLeafType};
let mut builder = CheckingBuilder::new();
builder.set_default_available(&ResolvedLeafType::leaf::<i32>("i32").unwrap(), false).unwrap();
let environment = builder.finish().unwrap();
assert!(!environment.capabilities(&cel_parser::Ty::I32).unwrap().default_available);
Source

pub fn register_range( &mut self, range: &ResolvedLeafType, element: &ResolvedLeafType, ) -> Result<(), MetadataError>

Registers an inclusive range’s accepted element identity and both source names.

  • Complexity: Expected O(m + l) time for retained type metadata size m (including alias entries and name bytes) and incoming names’ bytes l; O(l) additional name storage.
§Errors

Rejects conflicting range element identities.

§Examples

See Self::register_type for creating host leaves.

Source

pub fn register_lookup( &mut self, lookup: &OpLookup, ) -> Result<(), MetadataError>

Projects persistent operation, function, and record metadata without invoking callbacks.

  • Complexity: O(n · (r + n)) time and O(r + n) peak space for new registration metadata area n and previously accumulated description area r, including names, aliases, and recursive shapes.
§Errors

Rejects callback-only scopes, legacy tuple registrations, and conflicting metadata.

§Examples
let mut builder = cel_parser::checking::CheckingBuilder::new();
builder.register_lookup(&cel_parser::OpLookup::new()).unwrap();
Source

pub fn finish(self) -> Result<CheckingEnvironment, MetadataError>

Validates and transfers the accumulated description into a fresh environment.

Ordering ignores registration and hash iteration order for unchanged runtime identities. Host-only TypeId ordering breaks ties between identical diagnostic names and alias lists; no raw TypeId is serialized. Catalog-local nominal IDs are not stable application identifiers across builds. A rebuild may reorder IDs and change description bytes without changing checking semantics.

  • Complexity: O(n log n · m) time and O(n) space for description size n and largest compared name or shape size m.
§Errors

Returns the description-validation errors documented by that method.

§Examples

See the module example.

Source

pub fn finish_with_host_binding( self, ) -> Result<(CheckingEnvironment, HostTypeBinding), MetadataError>

Finalizes a catalog and its explicit, nonserializable host identity binding.

§Errors

Reports the same invalid-registration conditions as Self::finish.

  • Complexity: Catalog finalization plus expected O(n) host bindings.
§Examples
let (environment, binding) = cel_parser::checking::CheckingBuilder::new()
    .finish_with_host_binding().unwrap();
assert_eq!(binding.resolve(&environment, std::any::TypeId::of::<i32>()),
    Some(cel_parser::Ty::I32));

Trait Implementations§

Source§

impl Default for CheckingBuilder

Source§

fn default() -> Self

Creates a builtin-seeded builder.

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> 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, 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.