pub struct CheckingEnvironment { /* private fields */ }Expand description
Owns validated nominal identities and indexed semantic contracts.
No environment contains executable descriptors or callbacks.
§Examples
See the module example.
Implementations§
Source§impl CheckingEnvironment
impl CheckingEnvironment
Sourcepub fn from_description(
description: CheckingDescription,
) -> Result<Self, MetadataError>
pub fn from_description( description: CheckingDescription, ) -> Result<Self, MetadataError>
Validates and owns a description with fresh catalog-local nominal identities.
- Complexity: Expected O(n) time and space for description size n, including alias syntax and recursive argument shapes.
§Errors
Rejects incompatible builtin contracts, duplicate identities/names/signatures, unresolved references, invalid primitives, and shapes deeper than 128 nodes.
§Examples
See the module example.
Sourcepub fn description(&self) -> &CheckingDescription
pub fn description(&self) -> &CheckingDescription
Sourcepub fn resolve_type(&self, name: &str) -> Option<Ty>
pub fn resolve_type(&self, name: &str) -> Option<Ty>
Resolves a registered source name, preserving aliases and catalog ownership.
- Complexity: Expected O(l + t) for name bytes l and returned shape size t.
§Examples
let env = cel_parser::checking::CheckingBuilder::new().finish().unwrap();
assert_eq!(env.resolve_type("i32"), Some(cel_parser::Ty::I32));Sourcepub fn capabilities(&self, ty: &Ty) -> Option<Capabilities>
pub fn capabilities(&self, ty: &Ty) -> Option<Capabilities>
Returns value capabilities for a nominal or primitive type in this catalog.
Structural and foreign-catalog types have no nominal capability entry.
§Examples
let env = cel_parser::checking::CheckingBuilder::new().finish().unwrap();
assert!(env.capabilities(&cel_parser::Ty::I32).unwrap().cloneable);Sourcepub fn range_element(&self, ty: &Ty) -> Option<Ty>
pub fn range_element(&self, ty: &Ty) -> Option<Ty>
Returns the element accepted by a registered inclusive range.
Types without range capability and foreign-catalog identities return None.
§Examples
let env = cel_parser::checking::CheckingBuilder::new().finish().unwrap();
let range = env.resolve_type("RangeInclusive(i32)").unwrap();
assert_eq!(env.range_element(&range), Some(cel_parser::Ty::I32));Sourcepub fn check_annotation(
&self,
expr: &TypeExpr,
availability: MetadataAvailability,
) -> CheckingReport<Ty>
pub fn check_annotation( &self, expr: &TypeExpr, availability: MetadataAvailability, ) -> CheckingReport<Ty>
Checks an annotation without constructing runtime descriptors.
Missing host types follow availability; invalid language type syntax
remains a definite diagnostic. Unresolved leaves become Any without
erasing tuple, array, or callable siblings. Every independent finding is retained.
- Complexity: O(n * (r + t)) for n annotation nodes, worst-case strict resolution cost r and returned type area t.
§Examples
use cel_parser::checking::*;
let environment = CheckingBuilder::new().finish().unwrap();
let ty = cel_parser::CELParser::new(cel_parser::OpLookup::new())
.parse_type_expr_str("i32").unwrap();
assert_eq!(environment.check_annotation(&ty, MetadataAvailability::Complete).value,
cel_parser::Ty::I32);
let ty = cel_parser::CELParser::new(cel_parser::OpLookup::new())
.parse_type_expr_str("(Missing, bool)").unwrap();
let report = environment.check_annotation(&ty, MetadataAvailability::Unavailable);
assert_eq!(report.value,
cel_parser::Ty::Tuple(vec![cel_parser::Ty::Any, cel_parser::Ty::Bool]));
assert!(report.diagnostics.is_empty());
assert_eq!(report.incomplete.len(), 1);Sourcepub fn type_reference(&self, ty: &Ty) -> Option<CheckingType>
pub fn type_reference(&self, ty: &Ty) -> Option<CheckingType>
Returns a local structural reference, or None for unknown or foreign types.
- Complexity: O(n) time and result space for n shape nodes.
§Examples
use cel_parser::{Ty, checking::{CheckingBuilder, CheckingType}};
let environment = CheckingBuilder::new().finish().unwrap();
assert!(matches!(environment.type_reference(&Ty::I32), Some(CheckingType::Leaf(_))));