Skip to main content

TypedDataFields

Trait TypedDataFields 

Source
pub trait TypedDataFields<T> {
    // Required methods
    fn document(&mut self, doc: impl IntoDocComment) -> &mut Self;
    fn coerce(&mut self, ty: impl Into<Type>) -> &mut Self;
    fn add_field<V>(&mut self, name: impl Into<String>, value: V)
       where V: IntoLua + Clone + 'static + Typed;
    fn add_field_method_get<S, R, M>(&mut self, name: S, method: M)
       where S: Into<String>,
             R: IntoLua + Typed,
             M: 'static + MaybeSend + Fn(&Lua, &T) -> Result<R>;
    fn add_field_method_set<S, A, M>(&mut self, name: S, method: M)
       where S: Into<String>,
             A: FromLua + Typed,
             M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<()>;
    fn add_field_method_get_set<S, R, A, GET, SET>(
        &mut self,
        name: S,
        get: GET,
        set: SET,
    )
       where S: Into<String>,
             R: IntoLua + Typed,
             A: FromLua + Typed,
             GET: 'static + MaybeSend + Fn(&Lua, &T) -> Result<R>,
             SET: 'static + MaybeSend + Fn(&Lua, &mut T, A) -> Result<()>;
    fn add_field_function_get<S, R, F>(&mut self, name: S, function: F)
       where S: Into<String>,
             R: IntoLua + Typed,
             F: 'static + MaybeSend + Fn(&Lua, AnyUserData) -> Result<R>;
    fn add_field_function_set<S, A, F>(&mut self, name: S, function: F)
       where S: Into<String>,
             A: FromLua + Typed,
             F: 'static + MaybeSend + FnMut(&Lua, AnyUserData, A) -> Result<()>;
    fn add_field_function_get_set<S, R, A, GET, SET>(
        &mut self,
        name: S,
        get: GET,
        set: SET,
    )
       where S: Into<String>,
             R: IntoLua + Typed,
             A: FromLua + Typed,
             GET: 'static + MaybeSend + Fn(&Lua, AnyUserData) -> Result<R>,
             SET: 'static + MaybeSend + Fn(&Lua, AnyUserData, A) -> Result<()>;
    fn add_meta_field<V>(&mut self, meta: impl Into<String>, value: V)
       where V: IntoLua + Typed + 'static;
    fn add_meta_field_with<R, F>(&mut self, meta: impl Into<String>, f: F)
       where F: 'static + MaybeSend + Fn(&Lua) -> Result<R>,
             R: IntoLua + Typed + 'static;
}
Expand description

Typed variant of mlua::UserDataFields

Required Methods§

Source

fn document(&mut self, doc: impl IntoDocComment) -> &mut Self

Adds documentation to the next field that gets added

Source

fn coerce(&mut self, ty: impl Into<Type>) -> &mut Self

Adds a type to the queued overrides.

It will be used on the next field and will override the type that is automatically used.

Source

fn add_field<V>(&mut self, name: impl Into<String>, value: V)
where V: IntoLua + Clone + 'static + Typed,

Typed version of add_field

Source

fn add_field_method_get<S, R, M>(&mut self, name: S, method: M)
where S: Into<String>, R: IntoLua + Typed, M: 'static + MaybeSend + Fn(&Lua, &T) -> Result<R>,

Typed version of add_field_method_get

Source

fn add_field_method_set<S, A, M>(&mut self, name: S, method: M)
where S: Into<String>, A: FromLua + Typed, M: 'static + MaybeSend + FnMut(&Lua, &mut T, A) -> Result<()>,

Typed version of dd_field_method_set

Source

fn add_field_method_get_set<S, R, A, GET, SET>( &mut self, name: S, get: GET, set: SET, )
where S: Into<String>, R: IntoLua + Typed, A: FromLua + Typed, GET: 'static + MaybeSend + Fn(&Lua, &T) -> Result<R>, SET: 'static + MaybeSend + Fn(&Lua, &mut T, A) -> Result<()>,

Typed version of add_field_method_get and add_field_method_set combined

Source

fn add_field_function_get<S, R, F>(&mut self, name: S, function: F)
where S: Into<String>, R: IntoLua + Typed, F: 'static + MaybeSend + Fn(&Lua, AnyUserData) -> Result<R>,

Typed version of add_field_function_get

Source

fn add_field_function_set<S, A, F>(&mut self, name: S, function: F)
where S: Into<String>, A: FromLua + Typed, F: 'static + MaybeSend + FnMut(&Lua, AnyUserData, A) -> Result<()>,

Typed version of add_field_function_set

Source

fn add_field_function_get_set<S, R, A, GET, SET>( &mut self, name: S, get: GET, set: SET, )
where S: Into<String>, R: IntoLua + Typed, A: FromLua + Typed, GET: 'static + MaybeSend + Fn(&Lua, AnyUserData) -> Result<R>, SET: 'static + MaybeSend + Fn(&Lua, AnyUserData, A) -> Result<()>,

Typed version of add_field_function_get and add_field_function_set combined

Source

fn add_meta_field<V>(&mut self, meta: impl Into<String>, value: V)
where V: IntoLua + Typed + 'static,

Typed version of add_meta_field

Source

fn add_meta_field_with<R, F>(&mut self, meta: impl Into<String>, f: F)
where F: 'static + MaybeSend + Fn(&Lua) -> Result<R>, R: IntoLua + Typed + 'static,

Typed version of add_meta_field

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§