mirror of
https://github.com/mlua-rs/mlua
synced 2026-06-08 16:05:43 +00:00
Make userdata module public
This commit is contained in:
+8
-5
@@ -85,7 +85,6 @@ mod stdlib;
|
||||
mod thread;
|
||||
mod traits;
|
||||
mod types;
|
||||
mod userdata;
|
||||
mod util;
|
||||
mod value;
|
||||
mod vector;
|
||||
@@ -95,6 +94,7 @@ pub mod function;
|
||||
pub mod prelude;
|
||||
pub mod string;
|
||||
pub mod table;
|
||||
pub mod userdata;
|
||||
|
||||
pub use bstr::BString;
|
||||
pub use ffi::{self, lua_CFunction, lua_State};
|
||||
@@ -116,14 +116,17 @@ pub use crate::types::{
|
||||
AppDataRef, AppDataRefMut, Either, Integer, LightUserData, MaybeSend, MaybeSync, Number, RegistryKey,
|
||||
VmState,
|
||||
};
|
||||
pub use crate::userdata::{
|
||||
AnyUserData, MetaMethod, UserData, UserDataFields, UserDataMetatable, UserDataMethods, UserDataRef,
|
||||
UserDataRefMut, UserDataRegistry,
|
||||
};
|
||||
pub use crate::userdata::AnyUserData;
|
||||
pub use crate::value::{Nil, Value};
|
||||
|
||||
// Re-export some types to keep backward compatibility and avoid breaking changes in the public API.
|
||||
#[doc(hidden)]
|
||||
pub use crate::string::LuaString as String;
|
||||
#[doc(hidden)]
|
||||
pub use crate::userdata::{
|
||||
MetaMethod, UserData, UserDataFields, UserDataMetatable, UserDataMethods, UserDataRef, UserDataRefMut,
|
||||
UserDataRegistry,
|
||||
};
|
||||
|
||||
#[cfg(not(feature = "luau"))]
|
||||
pub use crate::debug::HookTriggers;
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
//! Lua userdata handling.
|
||||
//!
|
||||
//! This module provides types for creating and working with Lua userdata from Rust.
|
||||
//!
|
||||
//! # Main Types
|
||||
//!
|
||||
//! - [`AnyUserData`] - A handle to a Lua userdata value of any Rust type.
|
||||
//! - [`UserData`] - Trait to implement for types that should be exposed to Lua as userdata.
|
||||
//! - [`UserDataFields`] - Trait for registering fields on userdata types.
|
||||
//! - [`UserDataMethods`] - Trait for registering methods on userdata types.
|
||||
//! - [`UserDataRegistry`] - Registry for userdata methods and fields.
|
||||
//! - [`UserDataMetatable`] - A handle to the metatable of a userdata type.
|
||||
//! - [`UserDataRef`] - A borrowed reference to a userdata value.
|
||||
//! - [`UserDataRefMut`] - A mutably borrowed reference to a userdata value.
|
||||
//! - [`MetaMethod`] - Metamethod names for customizing Lua operators.
|
||||
|
||||
use std::any::TypeId;
|
||||
use std::ffi::CStr;
|
||||
use std::fmt;
|
||||
|
||||
+1
-1
@@ -1376,7 +1376,7 @@ fn test_userdata_namecall() -> Result<()> {
|
||||
struct MyUserData;
|
||||
|
||||
impl UserData for MyUserData {
|
||||
fn register(registry: &mut mlua::UserDataRegistry<Self>) {
|
||||
fn register(registry: &mut UserDataRegistry<Self>) {
|
||||
registry.add_method("method", |_, _, ()| Ok("method called"));
|
||||
registry.add_field_method_get("field", |_, _| Ok("field value"));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user