Skip to main content

ResolvedLeafType

Struct ResolvedLeafType 

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

One resolved scalar leaf type.

This pairs a human-readable type name with complete canonical leaf metadata. Hosts use [ValueType::cloneable_leaf] when this leaf may also appear in a closure annotation; the same descriptor then supplies its checked argument-cloning adapter.

Concrete element factories retain complete metadata. Use Self::with_complete_value_type to enrich its optional capabilities; metadata cannot be recovered from a TypeId. Equality compares registered identity, not optional capability availability.

Implementations§

Source§

impl ResolvedLeafType

Source

pub fn leaf<T: 'static>(type_name: impl Into<Cow<'static, str>>) -> Result<Self>

Registers an opaque concrete host leaf without optional capabilities.

Foreign types require no trait implementation or wrapper.

§Errors

Rejects an erased whole-value owner, which is not a concrete CEL leaf.

  • Complexity: O(l) time and space for a source-facing name of length l.
§Examples
use cel_parser::ResolvedLeafType;
let leaf = ResolvedLeafType::leaf::<std::path::PathBuf>("Path").unwrap();
assert!(leaf.complete_value_type().is_ok());
Source

pub fn new( type_name: impl Into<Cow<'static, str>>, element_type: ValueType, ) -> Self

Creates one resolved leaf from a user-facing type name and runtime element descriptor.

The descriptor adopts type_name, so a runtime mismatch diagnostic against this leaf reports the name the source annotation (or the host’s registry) uses rather than [ValueType::leaf]’s Rust type path.

  • Postcondition: the returned leaf’s type_id matches element_type, and its element_type reports type_name.
  • Precondition: element_type describes a concrete opaque leaf.
  • Complexity: O(l) for name length l.
§Examples
let leaf = cel_parser::ResolvedLeafType::new("Integer", cel_runtime::ValueType::leaf::<i32>());
assert_eq!(leaf.type_name(), "Integer");
Source

pub fn with_complete_value_type(self, complete: ValueType) -> Result<Self>

Attaches a complete leaf descriptor built while its concrete type was known.

Optional capabilities are retained unchanged and independently; attaching metadata emits no interpreter instructions.

§Errors

Returns an error if either descriptor is structural or concrete identity or layout differs.

§Examples
use cel_parser::ResolvedLeafType;
use cel_runtime::value_type::ValueType;
let leaf = ResolvedLeafType::leaf::<String>("Text").unwrap()
    .with_complete_value_type(ValueType::cloneable_leaf::<String>()).unwrap();
assert!(leaf.complete_value_type().is_ok());
Source

pub fn complete_value_type(&self) -> Result<&ValueType>

Borrows complete registration-time metadata without inventing erased adapters.

§Errors

Rejects an erased whole-value owner, which cannot be a registered leaf.

§Examples
use cel_parser::ResolvedLeafType;
assert!(ResolvedLeafType::leaf::<()>("HostUnit").unwrap()
    .complete_value_type().is_ok());
Source

pub fn type_id(&self) -> TypeId

Returns this leaf type’s concrete Rust TypeId.

Source

pub fn type_name(&self) -> &str

Returns this leaf type’s human-readable name.

Source

pub fn element_type(&self) -> &ValueType

Returns complete canonical metadata for this leaf.

Trait Implementations§

Source§

impl Clone for ResolvedLeafType

Source§

fn clone(&self) -> ResolvedLeafType

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 Debug for ResolvedLeafType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ResolvedLeafType

Source§

impl From<ResolvedLeafType> for ResolvedType

Source§

fn from(leaf: ResolvedLeafType) -> Self

Promotes a registered leaf without changing its identity.

Source§

impl PartialEq for ResolvedLeafType

Source§

fn eq(&self, other: &Self) -> bool

Compares registered leaf identities independently of optional capabilities.

  • Complexity: O(l) for name length l.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.