Skip to main content

CheckingEnvironment

Struct CheckingEnvironment 

Source
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

Source

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.

Source

pub fn description(&self) -> &CheckingDescription

Borrows the validated wire description.

§Examples

See CheckingDescription.

Source

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

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

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

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

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

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.