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
impl ResolvedLeafType
Sourcepub fn leaf<T: 'static>(type_name: impl Into<Cow<'static, str>>) -> Result<Self>
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());Sourcepub fn new(
type_name: impl Into<Cow<'static, str>>,
element_type: ValueType,
) -> Self
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_idmatcheselement_type, and itselement_typereportstype_name. - Precondition:
element_typedescribes 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");Sourcepub fn with_complete_value_type(self, complete: ValueType) -> Result<Self>
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());Sourcepub fn complete_value_type(&self) -> Result<&ValueType>
pub fn complete_value_type(&self) -> Result<&ValueType>
Sourcepub fn element_type(&self) -> &ValueType
pub fn element_type(&self) -> &ValueType
Returns complete canonical metadata for this leaf.
Trait Implementations§
Source§impl Clone for ResolvedLeafType
impl Clone for ResolvedLeafType
Source§fn clone(&self) -> ResolvedLeafType
fn clone(&self) -> ResolvedLeafType
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ResolvedLeafType
impl Debug for ResolvedLeafType
impl Eq for ResolvedLeafType
Source§impl From<ResolvedLeafType> for ResolvedType
impl From<ResolvedLeafType> for ResolvedType
Source§fn from(leaf: ResolvedLeafType) -> Self
fn from(leaf: ResolvedLeafType) -> Self
Promotes a registered leaf without changing its identity.