pub struct HostTypeBinding { /* private fields */ }Expand description
Binds host nominal identities explicitly to one checking catalog.
This object contains no executable descriptors and is never serialized. A separately imported catalog requires a new binding, even with identical bytes.
§Examples
use cel_parser::{Ty, checking::*};
let environment = CheckingBuilder::new().finish().unwrap();
let mut binding = HostTypeBinding::new(&environment);
binding.bind::<i32>(&environment, Ty::I32).unwrap();
assert_eq!(binding.resolve(&environment, std::any::TypeId::of::<i32>()), Some(Ty::I32));Implementations§
Source§impl HostTypeBinding
impl HostTypeBinding
Sourcepub fn new(environment: &CheckingEnvironment) -> Self
pub fn new(environment: &CheckingEnvironment) -> Self
Sourcepub fn bind<T: 'static>(
&mut self,
environment: &CheckingEnvironment,
ty: Ty,
) -> Result<(), MetadataError>
pub fn bind<T: 'static>( &mut self, environment: &CheckingEnvironment, ty: Ty, ) -> Result<(), MetadataError>
Binds T to the explicitly selected nominal type.
§Errors
Rejects foreign catalogs, structural/unknown types, and conflicting bindings.
- Complexity: Expected O(t) type comparison and retained type size t.
§Examples
See the type example.
Sourcepub fn resolve(
&self,
environment: &CheckingEnvironment,
id: TypeId,
) -> Option<Ty>
pub fn resolve( &self, environment: &CheckingEnvironment, id: TypeId, ) -> Option<Ty>
Resolves a host identity only in this binding’s owning catalog.
- Complexity: Expected O(t) for returned type size t.
§Examples
See the type example.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for HostTypeBinding
impl RefUnwindSafe for HostTypeBinding
impl Send for HostTypeBinding
impl Sync for HostTypeBinding
impl Unpin for HostTypeBinding
impl UnsafeUnpin for HostTypeBinding
impl UnwindSafe for HostTypeBinding
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