Type

Enum Type 

Source
pub enum Type {
    Function(FunctionRepresentation),
    Single(SingleType),
    Map(MapRepresentation),
    Or(Vec<Type>),
    Array(Box<Type>),
    Tuple(Vec<Type>),
}
Expand description

A type

Variants§

§

Function(FunctionRepresentation)

The type is a function

§

Single(SingleType)

The type is a simple, singular type

§

Map(MapRepresentation)

The type is a Map<K,V> (Think HashMap<K,V> and similar)

§

Or(Vec<Type>)

The type is a union (A | B)

§

Array(Box<Type>)

The type is an array

§

Tuple(Vec<Type>)

This one doesn’t really exist in lua/teal but will expand in (A,B,C) Sometimes useful for the return type or parameters but should be used very carefully As it can easily break things

Implementations§

Source§

impl Type

Source

pub fn new_single(name: impl AsRef<str>, kind: KindOfType) -> Self

Creates a new singular type

Examples found in repository?
examples/manual.rs (line 56)
55    fn to_typename() -> tealr::Type {
56        tealr::Type::new_single("Example", tealr::KindOfType::External)
57    }
More examples
Hide additional examples
examples/manual_documentation.rs (line 68)
67    fn to_typename() -> tealr::Type {
68        tealr::Type::new_single("Example", tealr::KindOfType::External)
69    }

Trait Implementations§

Source§

impl Clone for Type

Source§

fn clone(&self) -> Type

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Type

Source§

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

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

impl<'de> Deserialize<'de> for Type

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<Box<Type>> for Type

Source§

fn from(value: Box<Type>) -> Self

Converts to this type from the input type.
Source§

impl FromLua for Type

Source§

fn from_lua(lua_value: Value, lua: &Lua) -> Result<Self>

Performs the conversion.
Source§

impl Serialize for Type

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TealData for Type

Source§

fn add_fields<F: TealDataFields<Self>>(fields: &mut F)

same as UserData::add_fields. Refer to its documentation on how to use it. Read more
Source§

fn add_methods<T: TealDataMethods<Self>>(methods: &mut T)

same as UserData::add_methods. Refer to its documentation on how to use it. Read more
Source§

impl ToTypename for Type

Source§

fn to_typename() -> Type

generates the type representation
Source§

fn to_old_type_parts() -> Cow<'static, [NamePart]>

👎Deprecated
Used to get the old representation. Should basically never be used or implemented manually
Source§

fn to_function_param() -> Vec<FunctionParam>

generates the type representation when used as a parameter By default will assume no name was given Read more
Source§

impl TypeBody for Type

Source§

fn get_type_body() -> TypeGenerator

Fills in the TypeGenerator so a .d.tl file can be constructed.
Source§

impl UserData for Type

Source§

fn add_fields<F: UserDataFields<Self>>(fields: &mut F)

Adds custom fields specific to this userdata.
Source§

fn add_methods<M: UserDataMethods<Self>>(methods: &mut M)

Adds custom methods and operators specific to this userdata.
Source§

fn register(registry: &mut UserDataRegistry<Self>)

Registers this type for use in Lua. Read more

Auto Trait Implementations§

§

impl Freeze for Type

§

impl RefUnwindSafe for Type

§

impl Send for Type

§

impl Sync for Type

§

impl Unpin for Type

§

impl UnwindSafe for Type

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> FromLuaMulti for T
where T: FromLua,

Source§

fn from_lua_multi(values: MultiValue, lua: &Lua) -> Result<T, Error>

Performs the conversion. Read more
Source§

fn from_lua_args( args: MultiValue, i: usize, to: Option<&str>, lua: &Lua, ) -> Result<T, Error>

Source§

unsafe fn from_stack_multi(nvals: i32, lua: &RawLua) -> Result<T, Error>

Source§

unsafe fn from_stack_args( nargs: i32, i: usize, to: Option<&str>, lua: &RawLua, ) -> Result<T, Error>

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> IntoLua for T
where T: UserData + MaybeSend + 'static,

Source§

fn into_lua(self, lua: &Lua) -> Result<Value, Error>

Performs the conversion.
Source§

impl<T> IntoLuaMulti for T
where T: IntoLua,

Source§

fn into_lua_multi(self, lua: &Lua) -> Result<MultiValue, Error>

Performs the conversion.
Source§

unsafe fn push_into_stack_multi(self, lua: &RawLua) -> Result<i32, Error>

Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

Source§

impl<A> TealMultiValue for A
where A: ToTypename,

Source§

fn get_types_as_params() -> Vec<FunctionParam>

Gets the type representations as used for function parameters
Source§

fn get_types() -> Vec<Type>

Gets the types contained in this collection. Order IS important.
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 = 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.
Source§

impl<T> TypeName for T
where T: ToTypename,

Source§

fn get_type_parts() -> Cow<'static, [NamePart]>

returns the type name as how it should show up in the generated .d.tl file
Source§

fn get_type_parts_as_global() -> Cow<'static, [NamePart]>

Generates the typename when used to describe a global value. Read more
Source§

fn get_type_kind() -> KindOfType

This method tells the generator if this type is builtin to teal/lua, if it comes from somewhere else or if it stands in as a generic Read more
Source§

fn collect_children(_: &mut Vec<TealType>)

Creates/updates a list of every child type this type has This is used to properly label methods/functions as being generic.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> MaybeSend for T

Source§

impl<T> MaybeSend for T

Source§

impl<T> StaticUserdata for T
where T: UserData + 'static,