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
impl CheckingBuilder
Sourcepub fn register_type_function(
&mut self,
name: &str,
arguments: &[ResolvedType],
result: &ResolvedLeafType,
) -> Result<(), MetadataError>
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());Sourcepub fn register_type_functions(
&mut self,
functions: &TypeFunctionRegistry,
) -> Result<(), MetadataError>
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();Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a builder seeded with language primitive and range contracts.
§Examples
See the module example.
Sourcepub fn register_type(
&mut self,
name: &str,
leaf: &ResolvedLeafType,
default_available: bool,
) -> Result<(), MetadataError>
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();Sourcepub fn set_default_available(
&mut self,
leaf: &ResolvedLeafType,
available: bool,
) -> Result<(), MetadataError>
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);Sourcepub fn register_range(
&mut self,
range: &ResolvedLeafType,
element: &ResolvedLeafType,
) -> Result<(), MetadataError>
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.
Sourcepub fn register_lookup(
&mut self,
lookup: &OpLookup,
) -> Result<(), MetadataError>
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();Sourcepub fn finish(self) -> Result<CheckingEnvironment, MetadataError>
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.
Sourcepub fn finish_with_host_binding(
self,
) -> Result<(CheckingEnvironment, HostTypeBinding), MetadataError>
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));