Skip to main content

HostTypeBinding

Struct HostTypeBinding 

Source
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

Source

pub fn new(environment: &CheckingEnvironment) -> Self

Creates an empty binding owned by environment.

§Examples

See the type example.

Source

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.

Source

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§

Source§

impl Clone for HostTypeBinding

Source§

fn clone(&self) -> Self

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

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 = !

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.