Struct tealr::RecordGenerator

source ·
pub struct RecordGenerator {
Show 16 fields pub should_be_inlined: bool, pub is_user_data: bool, pub type_name: Cow<'static, [NamePart]>, pub fields: Vec<Field>, pub static_fields: Vec<Field>, pub methods: Vec<ExportedFunction>, pub mut_methods: Vec<ExportedFunction>, pub functions: Vec<ExportedFunction>, pub mut_functions: Vec<ExportedFunction>, pub meta_method: Vec<ExportedFunction>, pub meta_method_mut: Vec<ExportedFunction>, pub meta_function: Vec<ExportedFunction>, pub meta_function_mut: Vec<ExportedFunction>, pub documentation: HashMap<NameContainer, String>, pub type_doc: String, pub should_generate_help_method: bool, /* private fields */
}
Expand description

contains all the information needed to create a record

Fields§

§should_be_inlined: bool

Represents if the type should be inlined or not.

§is_user_data: bool

Represents if the type is UserData

§type_name: Cow<'static, [NamePart]>

The name of the type in teal

§fields: Vec<Field>

The exposed fields and their types

§static_fields: Vec<Field>

The exposed static fields and their types

§methods: Vec<ExportedFunction>

exported methods

§mut_methods: Vec<ExportedFunction>

exported methods that mutate something

§functions: Vec<ExportedFunction>

exported functions

§mut_functions: Vec<ExportedFunction>

exported functions that mutate something

§meta_method: Vec<ExportedFunction>

exported meta_methods

§meta_method_mut: Vec<ExportedFunction>

exported meta_methods that mutate something

§meta_function: Vec<ExportedFunction>

exported meta functions

§meta_function_mut: Vec<ExportedFunction>

exported meta functions that mutate something

§documentation: HashMap<NameContainer, String>

registered documentation

§type_doc: String

documentation for this type itself

§should_generate_help_method: bool

if this type needs to get a .help() function

Implementations§

source§

impl RecordGenerator

source

pub fn new<A: ToTypename>(should_be_inlined: bool) -> Self

creates a new RecordGenerator

Examples found in repository?
examples/rlua/manual.rs (line 49)
48
49
50
51
52
53
    fn get_type_body() -> TypeGenerator {
        let mut gen = RecordGenerator::new::<Self>(false);
        gen.is_user_data = true;
        <Self as TealData>::add_methods(&mut gen);
        gen.into()
    }
More examples
Hide additional examples
examples/rlua/manual_documentation.rs (line 49)
48
49
50
51
52
53
    fn get_type_body() -> tealr::TypeGenerator {
        let mut gen = tealr::RecordGenerator::new::<Self>(false);
        gen.is_user_data = true;
        <Self as TealData>::add_methods(&mut gen);
        gen.into()
    }
examples/mlua/manual.rs (line 73)
72
73
74
75
76
77
78
    fn get_type_body() -> tealr::TypeGenerator {
        let mut gen = tealr::RecordGenerator::new::<Self>(false);
        gen.is_user_data = true;
        <Self as TealData>::add_fields(&mut gen);
        <Self as TealData>::add_methods(&mut gen);
        gen.into()
    }
examples/mlua/manual_documentation.rs (line 85)
84
85
86
87
88
89
90
    fn get_type_body() -> tealr::TypeGenerator {
        let mut gen = tealr::RecordGenerator::new::<Self>(false);
        gen.is_user_data = true;
        <Self as TealData>::add_fields(&mut gen);
        <Self as TealData>::add_methods(&mut gen);
        gen.into()
    }
source§

impl RecordGenerator

source

pub fn copy_docs(&mut self, to: &[u8])

copies the documentation stored in “next_docs” to be linked to the given name Shouldn’t be called manually unless you add the fields/methods by hand rather than using the functions for this.

source

pub fn document(&mut self, documentation: &str)

adds documentation to the next field.

source

pub fn document_type(&mut self, documentation: &str) -> &mut Self

adds documentation to the type itself

Trait Implementations§

source§

impl Clone for RecordGenerator

source§

fn clone(&self) -> RecordGenerator

Returns a copy 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 Default for RecordGenerator

source§

fn default() -> RecordGenerator

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

impl<'de> Deserialize<'de> for RecordGenerator

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<RecordGenerator>> for RecordGenerator

source§

fn from(x: Box<RecordGenerator>) -> Self

Converts to this type from the input type.
source§

impl From<RecordGenerator> for TypeGenerator

source§

fn from(a: RecordGenerator) -> Self

Converts to this type from the input type.
source§

impl Serialize for RecordGenerator

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<'lua, T> TealDataFields<'lua, T> for RecordGenerator
where T: 'static + TealDataM + UserDataM + ToTypename,

source§

fn add_field_method_get<S, R, M>(&mut self, name: &S, _: M)
where S: AsRef<str> + ?Sized, R: IntoLua<'lua> + ToTypename, M: 'static + MaybeSend + Fn(&'lua Lua, &T) -> Result<R>,

the teal version of UserDataFields
source§

fn add_field_method_set<S, A, M>(&mut self, name: &S, _: M)
where S: AsRef<str> + ?Sized, A: FromLua<'lua> + ToTypename, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> Result<()>,

the teal version of UserDataFields
source§

fn add_field_function_get<S, R, F>(&mut self, name: &S, _: F)
where S: AsRef<str> + ?Sized, R: IntoLua<'lua> + ToTypename, F: 'static + MaybeSend + Fn(&'lua Lua, AnyUserData<'lua>) -> Result<R>,

the teal version of UserDataFields
source§

fn add_field_function_set<S, A, F>(&mut self, name: &S, _: F)
where S: AsRef<str> + ?Sized, A: FromLua<'lua> + ToTypename, F: 'static + MaybeSend + FnMut(&'lua Lua, AnyUserData<'lua>, A) -> Result<()>,

the teal version of UserDataFields
source§

fn add_meta_field_with<R, F>(&mut self, meta: MetaMethodM, _: F)
where F: 'static + MaybeSend + Fn(&'lua Lua) -> Result<R>, R: IntoLua<'lua> + ToTypename,

the teal version of UserDataFields
source§

fn document(&mut self, documentation: &str)

Adds documentation to the next field that gets added
source§

impl<'lua, T> TealDataMethods<'lua, T> for RecordGenerator
where T: 'static + TealDataM + UserDataM + ToTypename,

source§

fn add_method<S, A, R, M>(&mut self, name: &S, _: M)
where S: ?Sized + AsRef<str>, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> ResultM<R>,

Exposes a method to lua
source§

fn add_method_mut<S, A, R, M>(&mut self, name: &S, _: M)
where S: ?Sized + AsRef<str>, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> ResultM<R>,

Exposes a method to lua that has a mutable reference to Self
source§

fn add_function<S, A, R, F>(&mut self, name: &S, _: F)
where S: ?Sized + AsRef<str>, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> ResultM<R>,

Exposes a function to lua (its a method that does not take Self)
source§

fn add_function_mut<S, A, R, F>(&mut self, name: &S, _: F)
where S: ?Sized + AsRef<str>, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> ResultM<R>,

Exposes a mutable function to lua
source§

fn add_meta_method<A, R, M>(&mut self, name: MetaMethodM, _: M)
where A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + Fn(&'lua Lua, &T, A) -> ResultM<R>,

Exposes a meta method to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_method_mut<A, R, M>(&mut self, name: MetaMethodM, _: M)
where A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, M: 'static + MaybeSend + FnMut(&'lua Lua, &mut T, A) -> ResultM<R>,

Exposes a meta and mutable method to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_function<A, R, F>(&mut self, name: MetaMethodM, _: F)
where A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> ResultM<R>,

Exposes a meta function to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_function_mut<A, R, F>(&mut self, name: MetaMethodM, _: F)
where A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + FnMut(&'lua Lua, A) -> ResultM<R>,

Exposes a meta and mutable function to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_async_method<'s, S: ?Sized + AsRef<str>, A, R, M, MR>( &mut self, name: &S, _: M )
where T: 'static, M: Fn(&'lua Lua, &'s T, A) -> MR + MaybeSend + 'static, A: FromLuaMultiM<'lua> + TealMultiValue, MR: Future<Output = ResultM<R>> + 's, R: ToLuaMultiM<'lua> + TealMultiValue, 'lua: 's,

exposes an async method to lua
source§

fn add_async_function<S, A, R, F, FR>(&mut self, name: &S, _: F)
where S: AsRef<str> + ?Sized, A: FromLuaMultiM<'lua> + TealMultiValue, R: ToLuaMultiM<'lua> + TealMultiValue, F: 'static + MaybeSend + Fn(&'lua Lua, A) -> FR, FR: 'lua + Future<Output = ResultM<R>>,

exposes an async function to lua
source§

fn generate_help(&mut self)

generates a .help() function on lua’s/teals side, which can be used at run time to view the documentation.
source§

fn document(&mut self, documentation: &str) -> &mut Self

Adds documentation to the next method/function that gets added
source§

fn document_type(&mut self, documentation: &str) -> &mut Self

Adds documentation for this type itself. They will be written right above the record in the .d.tl file
source§

impl<'lua, T> TealDataMethods<'lua, T> for RecordGenerator
where T: 'static + TealDataR + UserDataR + ToTypename,

source§

fn add_method<S, A, R, M>(&mut self, name: &S, _: M)
where S: ?Sized + AsRef<str>, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + Fn(Context<'lua>, &T, A) -> ResultR<R>,

Exposes a method to lua
source§

fn add_method_mut<S, A, R, M>(&mut self, name: &S, _: M)
where S: ?Sized + AsRef<str>, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + FnMut(Context<'lua>, &mut T, A) -> ResultR<R>,

Exposes a method to lua that has a mutable reference to Self
source§

fn add_function<S, A, R, F>(&mut self, name: &S, _: F)
where S: ?Sized + AsRef<str>, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + Fn(Context<'lua>, A) -> ResultR<R>,

Exposes a function to lua (its a method that does not take Self)
source§

fn add_function_mut<S, A, R, F>(&mut self, name: &S, _: F)
where S: ?Sized + AsRef<str>, A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + FnMut(Context<'lua>, A) -> ResultR<R>,

Exposes a mutable function to lua
source§

fn add_meta_method<A, R, M>(&mut self, name: MetaMethodR, _: M)
where A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + Fn(Context<'lua>, &T, A) -> ResultR<R>,

Exposes a meta method to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_method_mut<A, R, M>(&mut self, name: MetaMethodR, _: M)
where A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, M: 'static + Send + FnMut(Context<'lua>, &mut T, A) -> ResultR<R>,

Exposes a meta and mutable method to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_function<A, R, F>(&mut self, name: MetaMethodR, _: F)
where A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + Fn(Context<'lua>, A) -> ResultR<R>,

Exposes a meta function to lua http://lua-users.org/wiki/MetatableEvents
source§

fn add_meta_function_mut<A, R, F>(&mut self, name: MetaMethodR, _: F)
where A: FromLuaMultiR<'lua> + TealMultiValue, R: ToLuaMultiR<'lua> + TealMultiValue, F: 'static + Send + FnMut(Context<'lua>, A) -> ResultR<R>,

Exposes a meta and mutable function to lua http://lua-users.org/wiki/MetatableEvents
source§

fn document(&mut self, documentation: &str) -> &mut Self

Adds documentation to the next method/function that gets added
source§

fn generate_help(&mut self)

generates an instance.help() function on lua’s/teals side, which can be used at run time to view the documentation.
source§

fn document_type(&mut self, documentation: &str) -> &mut Self

Adds documentation for this type itself. They will be written right above the record in the .d.tl file

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> 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> Serialize for T
where T: Serialize + ?Sized,

source§

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

source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> MaybeSend for T