pub struct OpaqueType {
pub name: String,
pub parameters: Vec<ValueType>,
}
Expand description
Opaque type for user-defined types.
Opaque types allow you to integrate custom Rust types into CEL expressions. They are identified by name and can have type parameters for generic types.
§Examples
use cel_cxx::*;
// Simple opaque type: MyType
let simple = OpaqueType::new("MyType", vec![]);
// Generic opaque type: MyGeneric<string, int>
let generic = OpaqueType::new("MyGeneric", vec![ValueType::String, ValueType::Int]);
Fields§
§name: String
The name of the opaque type.
parameters: Vec<ValueType>
Type parameters for generic opaque types.
Implementations§
Source§impl OpaqueType
impl OpaqueType
Sourcepub fn new<S: Into<String>>(name: S, parameters: Vec<ValueType>) -> Self
pub fn new<S: Into<String>>(name: S, parameters: Vec<ValueType>) -> Self
Creates a new opaque type with the given name and type parameters.
§Arguments
name
- The name of the opaque typeparameters
- Type parameters for generic opaque types
§Examples
use cel_cxx::*;
// Simple opaque type
let simple = OpaqueType::new("MyType", vec![]);
// Generic opaque type
let generic = OpaqueType::new("Container", vec![ValueType::String]);
Sourcepub fn name(&self) -> &str
pub fn name(&self) -> &str
Returns the name of this opaque type.
§Examples
use cel_cxx::*;
let opaque_type = OpaqueType::new("MyType", vec![]);
assert_eq!(opaque_type.name(), "MyType");
Sourcepub fn parameters(&self) -> &[ValueType]
pub fn parameters(&self) -> &[ValueType]
Returns the type parameters of this opaque type.
§Examples
use cel_cxx::*;
let opaque_type = OpaqueType::new("Container", vec![ValueType::Int, ValueType::String]);
assert_eq!(opaque_type.parameters().len(), 2);
Trait Implementations§
Source§impl Clone for OpaqueType
impl Clone for OpaqueType
Source§fn clone(&self) -> OpaqueType
fn clone(&self) -> OpaqueType
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for OpaqueType
impl Debug for OpaqueType
Source§impl Display for OpaqueType
impl Display for OpaqueType
Source§impl From<OpaqueType> for ValueType
impl From<OpaqueType> for ValueType
Source§fn from(value: OpaqueType) -> Self
fn from(value: OpaqueType) -> Self
Converts to this type from the input type.
Source§impl Hash for OpaqueType
impl Hash for OpaqueType
Source§impl PartialEq for OpaqueType
impl PartialEq for OpaqueType
impl Eq for OpaqueType
impl StructuralPartialEq for OpaqueType
Auto Trait Implementations§
impl Freeze for OpaqueType
impl RefUnwindSafe for OpaqueType
impl Send for OpaqueType
impl Sync for OpaqueType
impl Unpin for OpaqueType
impl UnwindSafe for OpaqueType
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more