pub struct TypedClassBuilder {
pub typed_class: TypedClass,
/* private fields */
}Expand description
Type information for a lua class. This happens to be a TypedUserData
Fields§
§typed_class: TypedClassImplementations§
Source§impl TypedClassBuilder
impl TypedClassBuilder
pub fn new<T: TypedUserData>() -> Self
pub fn build(self) -> TypedClass
Sourcepub fn skip_field(self, idx: impl Into<Index>) -> Self
pub fn skip_field(self, idx: impl Into<Index>) -> Self
Skip/Remove a field field from the class definition
Sourcepub fn skip_method(self, idx: impl Into<Index>) -> Self
pub fn skip_method(self, idx: impl Into<Index>) -> Self
Skip/Remove a method from the class definition
Sourcepub fn skip_meta_method(self, idx: impl Into<Index>) -> Self
pub fn skip_meta_method(self, idx: impl Into<Index>) -> Self
Skip/Remove a meta method from the class definition
Sourcepub fn skip_function(self, idx: impl Into<Index>) -> Self
pub fn skip_function(self, idx: impl Into<Index>) -> Self
Skip/Remove a function from the class definition
Sourcepub fn skip_meta_function(self, idx: impl Into<Index>) -> Self
pub fn skip_meta_function(self, idx: impl Into<Index>) -> Self
Skip/Remove a meta function from the class definition
Sourcepub fn field(
self,
key: impl Into<Index>,
ty: Type,
doc: impl IntoDocComment,
) -> Self
pub fn field( self, key: impl Into<Index>, ty: Type, doc: impl IntoDocComment, ) -> Self
Creates a new typed field and adds it to the class’s type information
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
static NAME: &str = "mlua_extras";
TypedClassBuilder::default()
.field("data1", Type::string() | Type::nil(), "doc comment goes last")
.field("data2", Type::array(Type::string()), ()) // Can also use `None` instead of `()`
.field("message", Type::string(), format!("A message for {NAME}"));pub fn static_field<V>( self, key: impl Into<Index>, value: V, doc: impl IntoDocComment, ) -> Self
pub fn inherit(self, parent: &TypedClass) -> Self
Sourcepub fn function<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
pub fn function<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
Creates a new typed function and adds it to the class’s type information
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
TypedClassBuilder::default()
.function::<String, ()>("greet", "Greet the given name")
// Can use `None` instead of `()` for specifying the doc comment
.function::<String, ()>("hello", ());Sourcepub fn method<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
pub fn method<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
Creates a new typed method and adds it to the class’s type information.
As with methods in lua, the self parameter is implicit and has the same type as the
parent class.
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
TypedClassBuilder::default()
.method::<String, ()>("greet", "Greet the given name")
// Can use `None` instead of `()` for specifying the doc comment
.method::<String, ()>("hello", ());Sourcepub fn meta_field(
self,
key: impl Into<Index>,
ty: Type,
doc: impl IntoDocComment,
) -> Self
pub fn meta_field( self, key: impl Into<Index>, ty: Type, doc: impl IntoDocComment, ) -> Self
Creates a new typed field and adds it to the class’s meta type information
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
static NAME: &str = "mlua_extras";
TypedClassBuilder::default()
.meta_field("data1", Type::string() | Type::nil(), "doc comment goes last")
.meta_field("data2", Type::array(Type::string()), ()) // Can also use `None` instead of `()`
.meta_field("message", Type::string(), format!("A message for {NAME}"));Sourcepub fn meta_function<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
pub fn meta_function<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
Creates a new typed function and adds it to the class’s meta type information
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
TypedClassBuilder::default()
.meta_function::<String, ()>("greet", "Greet the given name")
// Can use `None` instead of `()` for specifying the doc comment
.meta_function::<String, ()>("hello", ());Sourcepub fn meta_method<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
pub fn meta_method<Params, Returns>(
self,
key: impl Into<Index>,
doc: impl IntoDocComment,
) -> Selfwhere
Params: TypedMultiValue,
Returns: TypedMultiValue,
Creates a new typed method and adds it to the class’s type information.
As with methods in lua, the self parameter is implicit and has the same type as the
parent class.
§Example
use mlua_extras::typed::{TypedClassBuilder, Type};
static NAME: &str = "mlua_extras";
TypedClassBuilder::default()
.method::<String, ()>("greet", "Greet the given name")
// Can use `None` instead of `()` for specifying the doc comment
.method::<String, ()>("hello", ());Trait Implementations§
Source§impl Clone for TypedClassBuilder
impl Clone for TypedClassBuilder
Source§fn clone(&self) -> TypedClassBuilder
fn clone(&self) -> TypedClassBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TypedClassBuilder
impl Debug for TypedClassBuilder
Source§impl Default for TypedClassBuilder
impl Default for TypedClassBuilder
Source§fn default() -> TypedClassBuilder
fn default() -> TypedClassBuilder
Source§impl From<TypedClassBuilder> for Type
impl From<TypedClassBuilder> for Type
Source§fn from(value: TypedClassBuilder) -> Self
fn from(value: TypedClassBuilder) -> Self
Source§impl<T: TypedUserData> TypedDataDocumentation<T> for TypedClassBuilder
impl<T: TypedUserData> TypedDataDocumentation<T> for TypedClassBuilder
Source§impl<T: TypedUserData> TypedDataFields<T> for TypedClassBuilder
impl<T: TypedUserData> TypedDataFields<T> for TypedClassBuilder
Source§fn document(&mut self, doc: impl IntoDocComment) -> &mut Self
fn document(&mut self, doc: impl IntoDocComment) -> &mut Self
Source§fn coerce(&mut self, ty: impl Into<Type>) -> &mut Self
fn coerce(&mut self, ty: impl Into<Type>) -> &mut Self
Source§fn add_field_function_set<S, A, F>(&mut self, name: S, _: F)
fn add_field_function_set<S, A, F>(&mut self, name: S, _: F)
Source§fn add_field_function_get<S, R, F>(&mut self, name: S, _: F)
fn add_field_function_get<S, R, F>(&mut self, name: S, _: F)
Source§fn add_field_function_get_set<S, R, A, GET, SET>(
&mut self,
name: S,
_: GET,
_: SET,
)
fn add_field_function_get_set<S, R, A, GET, SET>( &mut self, name: S, _: GET, _: SET, )
Source§fn add_field_method_set<S, A, M>(&mut self, name: S, _: M)
fn add_field_method_set<S, A, M>(&mut self, name: S, _: M)
Source§fn add_field_method_get<S, R, M>(&mut self, name: S, _: M)
fn add_field_method_get<S, R, M>(&mut self, name: S, _: M)
Source§fn add_field_method_get_set<S, R, A, GET, SET>(
&mut self,
name: S,
_: GET,
_: SET,
)
fn add_field_method_get_set<S, R, A, GET, SET>( &mut self, name: S, _: GET, _: SET, )
Source§fn add_meta_field<V>(&mut self, meta: impl Into<String>, value: V)
fn add_meta_field<V>(&mut self, meta: impl Into<String>, value: V)
Source§impl<T: TypedUserData> TypedDataMethods<T> for TypedClassBuilder
impl<T: TypedUserData> TypedDataMethods<T> for TypedClassBuilder
Source§fn document(&mut self, doc: impl IntoDocComment) -> &mut Self
fn document(&mut self, doc: impl IntoDocComment) -> &mut Self
Source§fn param(&mut self, name: impl Display, doc: impl IntoDocComment) -> &mut Self
fn param(&mut self, name: impl Display, doc: impl IntoDocComment) -> &mut Self
Source§fn param_as(
&mut self,
ty: impl Into<Type>,
name: impl Display,
doc: impl IntoDocComment,
) -> &mut Self
fn param_as( &mut self, ty: impl Into<Type>, name: impl Display, doc: impl IntoDocComment, ) -> &mut Self
Source§fn ret(&mut self, doc: impl IntoDocComment) -> &mut Self
fn ret(&mut self, doc: impl IntoDocComment) -> &mut Self
Source§fn ret_as(&mut self, ty: impl Into<Type>, doc: impl IntoDocComment) -> &mut Self
fn ret_as(&mut self, ty: impl Into<Type>, doc: impl IntoDocComment) -> &mut Self
Source§fn index<I: Typed>(&mut self, idx: isize, doc: impl IntoDocComment) -> &mut Self
fn index<I: Typed>(&mut self, idx: isize, doc: impl IntoDocComment) -> &mut Self
Source§fn index_as(
&mut self,
idx: isize,
ty: impl Into<Type>,
doc: impl IntoDocComment,
) -> &mut Self
fn index_as( &mut self, idx: isize, ty: impl Into<Type>, doc: impl IntoDocComment, ) -> &mut Self
Source§fn add_method<S, A, R, M>(&mut self, name: S, _: M)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + Fn(&Lua, &T, A) -> Result<R>,
fn add_method<S, A, R, M>(&mut self, name: S, _: M)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + Fn(&Lua, &T, A) -> Result<R>,
Source§fn add_function<S, A, R, F>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(&Lua, A) -> Result<R>,
fn add_function<S, A, R, F>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(&Lua, A) -> Result<R>,
Source§fn add_method_mut<S, A, R, M>(&mut self, name: S, _: M)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<R>,
fn add_method_mut<S, A, R, M>(&mut self, name: S, _: M)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<R>,
Source§fn add_meta_method<A, R, M>(&mut self, meta: impl Into<String>, _: M)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + Fn(&Lua, &T, A) -> Result<R>,
fn add_meta_method<A, R, M>(&mut self, meta: impl Into<String>, _: M)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + Fn(&Lua, &T, A) -> Result<R>,
Source§fn add_async_method<S: Into<String>, A, R, M, MR>(&mut self, name: S, _: M)where
T: 'static,
M: Fn(Lua, UserDataRef<T>, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti + TypedMultiValue,
MR: Future<Output = Result<R>> + MaybeSend + 'static,
R: IntoLuaMulti + TypedMultiValue,
fn add_async_method<S: Into<String>, A, R, M, MR>(&mut self, name: S, _: M)where
T: 'static,
M: Fn(Lua, UserDataRef<T>, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti + TypedMultiValue,
MR: Future<Output = Result<R>> + MaybeSend + 'static,
R: IntoLuaMulti + TypedMultiValue,
Source§fn add_async_method_mut<S: Into<String>, A, R, M, MR>(
&mut self,
name: S,
_method: M,
)where
T: 'static,
M: Fn(Lua, UserDataRefMut<T>, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti + TypedMultiValue,
MR: Future<Output = Result<R>> + MaybeSend + 'static,
R: IntoLuaMulti + TypedMultiValue,
fn add_async_method_mut<S: Into<String>, A, R, M, MR>(
&mut self,
name: S,
_method: M,
)where
T: 'static,
M: Fn(Lua, UserDataRefMut<T>, A) -> MR + MaybeSend + 'static,
A: FromLuaMulti + TypedMultiValue,
MR: Future<Output = Result<R>> + MaybeSend + 'static,
R: IntoLuaMulti + TypedMultiValue,
Source§fn add_function_mut<S, A, R, F>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + FnMut(&Lua, A) -> Result<R>,
fn add_function_mut<S, A, R, F>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + FnMut(&Lua, A) -> Result<R>,
Source§fn add_meta_function<A, R, F>(&mut self, meta: impl Into<String>, _: F)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(&Lua, A) -> Result<R>,
fn add_meta_function<A, R, F>(&mut self, meta: impl Into<String>, _: F)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(&Lua, A) -> Result<R>,
Source§fn add_async_function<S, A, R, F, FR>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(Lua, A) -> FR,
FR: 'static + MaybeSend + Future<Output = Result<R>>,
fn add_async_function<S, A, R, F, FR>(&mut self, name: S, _: F)where
S: Into<String>,
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + Fn(Lua, A) -> FR,
FR: 'static + MaybeSend + Future<Output = Result<R>>,
Source§fn add_meta_method_mut<A, R, M>(&mut self, meta: impl Into<String>, _: M)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<R>,
fn add_meta_method_mut<A, R, M>(&mut self, meta: impl Into<String>, _: M)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<R>,
Source§fn add_meta_function_mut<A, R, F>(&mut self, meta: impl Into<String>, _: F)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + FnMut(&Lua, A) -> Result<R>,
fn add_meta_function_mut<A, R, F>(&mut self, meta: impl Into<String>, _: F)where
A: FromLuaMulti + TypedMultiValue,
R: IntoLuaMulti + TypedMultiValue,
F: 'static + MaybeSend + FnMut(&Lua, A) -> Result<R>,
Auto Trait Implementations§
impl Freeze for TypedClassBuilder
impl !RefUnwindSafe for TypedClassBuilder
impl Send for TypedClassBuilder
impl Sync for TypedClassBuilder
impl Unpin for TypedClassBuilder
impl UnsafeUnpin for TypedClassBuilder
impl !UnwindSafe for TypedClassBuilder
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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