spacetimedb_expr::ty

Struct TyCtx

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

When type checking a super::expr::RelExpr, types are stored in a typing context TyCtx. It will then hold references, in the form of TyIds, to the types defined in the TyCtx.

Implementations§

Source§

impl TyCtx

Source

pub fn bool(&self) -> TypeWithCtx<'_>

Return a wrapped Type::BOOL

Source

pub fn i8(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I8

Source

pub fn u8(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U8

Source

pub fn i16(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I16

Source

pub fn u16(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U16

Source

pub fn i32(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I32

Source

pub fn u32(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U32

Source

pub fn i64(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I64

Source

pub fn u64(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U64

Source

pub fn i128(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I128

Source

pub fn u128(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U128

Source

pub fn i256(&self) -> TypeWithCtx<'_>

Return a wrapped Type::I256

Source

pub fn u256(&self) -> TypeWithCtx<'_>

Return a wrapped Type::U256

Source

pub fn f32(&self) -> TypeWithCtx<'_>

Return a wrapped Type::F32

Source

pub fn f64(&self) -> TypeWithCtx<'_>

Return a wrapped Type::F64

Source

pub fn str(&self) -> TypeWithCtx<'_>

Return a wrapped Type::STR

Source

pub fn bytes(&self) -> TypeWithCtx<'_>

Return a wrapped AlgebraicType::bytes()

Source

pub fn ident(&self) -> TypeWithCtx<'_>

Return a wrapped AlgebraicType::identity()

Source

pub fn try_resolve(&self, id: TyId) -> Result<TypeWithCtx<'_>, InvalidTypeId>

Try to resolve an id to its Type. Return a resolution error if not found.

Source

pub fn resolve_symbol(&self, id: Symbol) -> Option<&str>

Resolve a Symbol to its name

Source

pub fn add_algebraic_type(&mut self, ty: &AlgebraicType) -> TyId

Add an AlgebraicType to the context and return a TyId for it. The TyId is not guaranteed to be unique to the type. However for primitive types it will be.

Source

pub fn add_var_type( &mut self, table_id: TableId, fields: Vec<(Symbol, TyId)>, ) -> TyId

Add a relvar or table type to the context and return a TyId for it. The TyId is not guaranteed to be unique to the type.

Source

pub fn add_row_type(&mut self, fields: Vec<(Symbol, TyId)>) -> TyId

Add a derived row type to the context and return a TyId for it. The TyId is not guaranteed to be unique to the type.

Source

pub fn gen_symbol(&mut self, name: impl AsRef<str>) -> Symbol

Generate a Symbol from a string

Source

pub fn get_symbol(&self, name: impl AsRef<str>) -> Option<Symbol>

Get an already generated Symbol

Source

pub fn eq(&self, a: TyId, b: TyId) -> Result<bool, InvalidTypeId>

Are these types structurally equivalent?

Trait Implementations§

Source§

impl Debug for TyCtx

Source§

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

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

impl Default for TyCtx

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for TyCtx

§

impl RefUnwindSafe for TyCtx

§

impl Send for TyCtx

§

impl Sync for TyCtx

§

impl Unpin for TyCtx

§

impl UnwindSafe for TyCtx

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.