Alex Orlenko
63a255bbc9
Replace is_sync specialization trick with MaybeSync trait bound.
...
The `is_sync::<T>()` runtime check relied on implicit specialization via
`Copy`/`Clone` array behavior, which has changed in Rust 1.86+.
`UserDataRef` always taking an exclusive lock even for `Sync` userdata,
preventing concurrent shared borrows.
With the `send` feature flag enabled, userdata types must now be `Send + Sync`.
This is a breaking change, `T: Send + !Sync` userdata types can be wrapped in a `Mutex`
or used inside a `Scope` where this restriction is lifted.
2026-02-21 15:05:55 +00:00
Alex Orlenko
2ace892613
Rename string::String to LuaString
2026-01-29 18:45:41 +00:00
Alex Orlenko
d9c139b55f
Rust 2024
2026-01-29 10:33:28 +00:00
Alex Orlenko
5d27cb91b2
Add optional __namecall optimization for Luau
...
Add `UserDataRegistry::enable_namecall()` hint to set `__namecall` metamethod to enable Luau-specific method resolution optimization.
2025-09-02 00:53:12 +01:00
Alex Orlenko
4b9d1cf271
Replace impl ToString with Into<StdString>
...
This is a more canonical way to accept any types of stirng but not arbitrary types that implement `Display`
2025-07-05 11:21:18 +01:00
Alex Orlenko
97ca3e2c08
Check that type passed to scoped userdata self argument is userdata.
...
If passed type is non-userdata we try to get a pointer (which will be null) that triggers an assertion.
Having a check also allow us to generate right error message.
Fixes #569
2025-05-01 13:09:23 +01:00
Alex Orlenko
53ff494ab9
Prepare for custom (Luau) userdata destructors.
...
We need to add logic later to prevent calling any Lua functions when UserData destructor is running.
2025-04-04 16:36:06 +01:00
Alex Orlenko
0a1a1fe0b6
Move some userdata helpers from crate::util to crate::userdata::util
2025-03-21 15:13:53 +00:00
Alex Orlenko
4fe7d151a1
Refactor userdata-wrappers feature.
...
Support borrowing underlying data in `UserDataRef` and `UserDataRefMut`.
2025-03-21 14:19:38 +00:00
Alex Orlenko
4ef0d583fc
impl Send for UserDataTypeId (in send mode)
2024-11-16 01:56:18 +00:00
Alex Orlenko
3bfaee4ecc
Delay "any" userdata metatable creation until first instance
2024-11-16 01:47:04 +00:00
Alex Orlenko
89b68e2a24
Remove generic from RawLua::push_userdata_metatable.
...
This should help to reduce amount of generated code.
2024-11-16 01:44:17 +00:00
Alex Orlenko
cbf805f492
Avoid ptr->usize->ptr conversion to comply strict provenance
2024-11-15 21:47:19 +00:00
Alex Orlenko
c2eab173c5
Add userdata-wrappers feature
...
This feature allow to opt into `impl UserData` for `Rc<T>`/`Arc<T>`/`Rc<RefCell<T>>`/`Arc<Mutex<T>>` where `T: UserData`
Close #470
2024-11-03 11:48:47 +00:00
Alex Orlenko
9f6c78532f
Move IntoLua/FromLua and IntoLuaMulti/FromLuaMulti to traits module
2024-10-07 10:32:50 +01:00
Alex Orlenko
8274b5fa88
More user-friendly error message on userdata mismatch
2024-09-23 15:56:29 +01:00
Alex Orlenko
fce85381c6
Fix clippy warnings
2024-09-22 19:02:16 +01:00
Alex Orlenko
da4404baa5
Add Lua::scope back
2024-09-20 13:01:55 +01:00
Alex Orlenko
9891e86d16
Remove Clone requirement from UserDataFields::add_field()
2024-08-26 11:10:34 +01:00
Alex Orlenko
fdc50bffc9
Fix memory leak when polling async futures
2024-08-23 01:03:54 +01:00
Alex Orlenko
9931709ecd
Remove explicit lifetime from UserDataMethods and UserDataFields traits.
...
Pass `'static` arguments to async functions and require `'static` Future.
(in future we can use async closures to make it more elegant).
2024-08-23 00:10:29 +01:00
Alex Orlenko
c58f67b140
Add MaybeSend requirement to Lua futures
2024-08-10 17:55:39 +01:00
Alex Orlenko
4082b354fe
clippy
2024-08-01 00:55:10 +01:00
Alex Orlenko
3641c98959
Prepare for Rust 2024 edition (see rust-lang/rust#123748 )
...
Replace `IntoLua(Multi)` generic with positional arg (impl trait) where possible
This allow to shorten syntax from `a.get::<_, T>` to `a.get::<T>`
2024-07-31 23:42:43 +01:00
Alex Orlenko
b4892c228c
Add rustfmt.toml
2024-07-31 13:42:37 +01:00
Alex Orlenko
c1395ab543
clippy
2024-07-31 13:42:37 +01:00
Alex Orlenko
cd6d86a5ce
Split single lua module to multiple submodules under state
2024-07-31 13:42:37 +01:00
Alex Orlenko
d17dc54645
Rewrite call_async in traits to use impl Future instead of LocalBoxFuture.
...
More use `std::future` types instead of `future-utils`.
2024-07-31 13:42:36 +01:00
Alex Orlenko
baa8895cfb
Optimize creation of userdata callbacks (registry)
2024-07-31 13:42:36 +01:00
Alex Orlenko
550d6b2991
Remove wrapped UserData impl (Rc/Arc/etc)
2024-07-31 13:42:36 +01:00
Alex Orlenko
b3649a44e0
Move userdata-related top-level modules into the userdata module
2024-07-31 13:42:36 +01:00