Update documentation
This commit is contained in:
parent
1a81f8d447
commit
9f82cbe0c5
|
@ -18,6 +18,7 @@ with async/await features and support of writing native lua modules in Rust.
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["lua53", "async", "send", "serialize"]
|
features = ["lua53", "async", "send", "serialize"]
|
||||||
|
rustdoc-args = ["--cfg", "docsrs"]
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
|
|
@ -109,6 +109,8 @@ pub enum Error {
|
||||||
///
|
///
|
||||||
/// This error can happen either due to to being destructed in a previous __gc, or due to being
|
/// This error can happen either due to to being destructed in a previous __gc, or due to being
|
||||||
/// destructed from exiting a `Lua::scope` call.
|
/// destructed from exiting a `Lua::scope` call.
|
||||||
|
///
|
||||||
|
/// [`AnyUserData`]: struct.AnyUserData.html
|
||||||
UserDataDestructed,
|
UserDataDestructed,
|
||||||
/// An [`AnyUserData`] immutable borrow failed because it is already borrowed mutably.
|
/// An [`AnyUserData`] immutable borrow failed because it is already borrowed mutably.
|
||||||
///
|
///
|
||||||
|
@ -139,9 +141,11 @@ pub enum Error {
|
||||||
},
|
},
|
||||||
/// Serialization error.
|
/// Serialization error.
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
|
||||||
SerializeError(StdString),
|
SerializeError(StdString),
|
||||||
/// Deserialization error.
|
/// Deserialization error.
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
|
||||||
DeserializeError(StdString),
|
DeserializeError(StdString),
|
||||||
/// A custom error.
|
/// A custom error.
|
||||||
///
|
///
|
||||||
|
|
|
@ -119,6 +119,7 @@ impl<'lua> Function<'lua> {
|
||||||
///
|
///
|
||||||
/// [`AsyncThread`]: struct.AsyncThread.html
|
/// [`AsyncThread`]: struct.AsyncThread.html
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn call_async<'fut, A, R>(&self, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
pub fn call_async<'fut, A, R>(&self, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
||||||
where
|
where
|
||||||
'lua: 'fut,
|
'lua: 'fut,
|
||||||
|
|
22
src/lib.rs
22
src/lib.rs
|
@ -26,12 +26,12 @@
|
||||||
//!
|
//!
|
||||||
//! # Serde support
|
//! # Serde support
|
||||||
//!
|
//!
|
||||||
//! The [`LuaSerdeExt`] trait implemented for [`Lua`] allow conversion from Rust types to Lua values
|
//! The [`LuaSerdeExt`] trait implemented for [`Lua`] allows conversion from Rust types to Lua values
|
||||||
//! and vice versa using serde. Any user defined data type that implements `serde::Serialize` or
|
//! and vice versa using serde. Any user defined data type that implements [`serde::Serialize`] or
|
||||||
//! `serde::Deserialize` can be converted.
|
//! [`serde::Deserialize`] can be converted.
|
||||||
//! For convenience, additional functionality to handle NULL values and arrays is provided.
|
//! For convenience, additional functionality to handle `NULL` values and arrays is provided.
|
||||||
//!
|
//!
|
||||||
//! The [`Value`] struct implements `serde::Serialize` trait to support serializing Lua values
|
//! The [`Value`] enum implements [`serde::Serialize`] trait to support serializing Lua values
|
||||||
//! (including [`UserData`]) into Rust values.
|
//! (including [`UserData`]) into Rust values.
|
||||||
//!
|
//!
|
||||||
//! Requires `feature = "serialize"`.
|
//! Requires `feature = "serialize"`.
|
||||||
|
@ -46,7 +46,7 @@
|
||||||
//!
|
//!
|
||||||
//! # `Send` requirement
|
//! # `Send` requirement
|
||||||
//! By default `mlua` is `!Send`. This can be changed by enabling `feature = "send"` that adds `Send` requirement
|
//! By default `mlua` is `!Send`. This can be changed by enabling `feature = "send"` that adds `Send` requirement
|
||||||
//! to `Function`s and [`UserData`].
|
//! to [`Function`]s and [`UserData`].
|
||||||
//!
|
//!
|
||||||
//! [Lua programming language]: https://www.lua.org/
|
//! [Lua programming language]: https://www.lua.org/
|
||||||
//! [`Lua`]: struct.Lua.html
|
//! [`Lua`]: struct.Lua.html
|
||||||
|
@ -57,14 +57,19 @@
|
||||||
//! [`FromLua`]: trait.FromLua.html
|
//! [`FromLua`]: trait.FromLua.html
|
||||||
//! [`ToLuaMulti`]: trait.ToLuaMulti.html
|
//! [`ToLuaMulti`]: trait.ToLuaMulti.html
|
||||||
//! [`FromLuaMulti`]: trait.FromLuaMulti.html
|
//! [`FromLuaMulti`]: trait.FromLuaMulti.html
|
||||||
|
//! [`Function`]: struct.Function.html
|
||||||
//! [`UserData`]: trait.UserData.html
|
//! [`UserData`]: trait.UserData.html
|
||||||
//! [`UserDataMethods`]: trait.UserDataMethods.html
|
//! [`UserDataMethods`]: trait.UserDataMethods.html
|
||||||
//! [`LuaSerdeExt`]: trait.LuaSerdeExt.html
|
//! [`LuaSerdeExt`]: serde/trait.LuaSerdeExt.html
|
||||||
//! [`Value`]: struct.Value.html
|
//! [`Value`]: enum.Value.html
|
||||||
//! [`create_async_function`]: struct.Lua.html#method.create_async_function
|
//! [`create_async_function`]: struct.Lua.html#method.create_async_function
|
||||||
//! [`call_async`]: struct.Function.html#method.call_async
|
//! [`call_async`]: struct.Function.html#method.call_async
|
||||||
//! [`AsyncThread`]: struct.AsyncThread.html
|
//! [`AsyncThread`]: struct.AsyncThread.html
|
||||||
//! [`Future`]: ../futures_core/future/trait.Future.html
|
//! [`Future`]: ../futures_core/future/trait.Future.html
|
||||||
|
//! [`serde::Serialize`]: https://docs.serde.rs/serde/ser/trait.Serialize.html
|
||||||
|
//! [`serde::Deserialize`]: https://docs.serde.rs/serde/de/trait.Deserialize.html
|
||||||
|
|
||||||
|
#![cfg_attr(docsrs, feature(doc_cfg))]
|
||||||
|
|
||||||
// Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any*
|
// Deny warnings inside doc tests / examples. When this isn't present, rustdoc doesn't show *any*
|
||||||
// warnings at all.
|
// warnings at all.
|
||||||
|
@ -114,6 +119,7 @@ pub use crate::serde::LuaSerdeExt;
|
||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
|
||||||
pub mod serde;
|
pub mod serde;
|
||||||
|
|
||||||
// Re-export #[mlua_derive::lua_module].
|
// Re-export #[mlua_derive::lua_module].
|
||||||
|
|
|
@ -100,6 +100,7 @@ pub(crate) static EXTRA_REGISTRY_KEY: u8 = 0;
|
||||||
|
|
||||||
/// Requires `feature = "send"`
|
/// Requires `feature = "send"`
|
||||||
#[cfg(feature = "send")]
|
#[cfg(feature = "send")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "send")))]
|
||||||
unsafe impl Send for Lua {}
|
unsafe impl Send for Lua {}
|
||||||
|
|
||||||
impl Drop for Lua {
|
impl Drop for Lua {
|
||||||
|
@ -957,6 +958,7 @@ impl Lua {
|
||||||
/// [`Thread`]: struct.Thread.html
|
/// [`Thread`]: struct.Thread.html
|
||||||
/// [`AsyncThread`]: struct.AsyncThread.html
|
/// [`AsyncThread`]: struct.AsyncThread.html
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn create_async_function<'lua, 'callback, A, R, F, FR>(
|
pub fn create_async_function<'lua, 'callback, A, R, F, FR>(
|
||||||
&'lua self,
|
&'lua self,
|
||||||
func: F,
|
func: F,
|
||||||
|
@ -1006,6 +1008,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// Requires `feature = "serialize"`
|
/// Requires `feature = "serialize"`
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
|
||||||
pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData>
|
pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData>
|
||||||
where
|
where
|
||||||
T: 'static + MaybeSend + UserData + Serialize,
|
T: 'static + MaybeSend + UserData + Serialize,
|
||||||
|
@ -1071,6 +1074,7 @@ impl Lua {
|
||||||
///
|
///
|
||||||
/// [`scope`]: #method.scope
|
/// [`scope`]: #method.scope
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn async_scope<'lua, 'scope, R, F, FR>(
|
pub fn async_scope<'lua, 'scope, R, F, FR>(
|
||||||
&'lua self,
|
&'lua self,
|
||||||
f: F,
|
f: F,
|
||||||
|
@ -1963,6 +1967,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
|
||||||
///
|
///
|
||||||
/// [`Chunk::exec`]: struct.Chunk.html#method.exec
|
/// [`Chunk::exec`]: struct.Chunk.html#method.exec
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn exec_async<'fut>(self) -> LocalBoxFuture<'fut, Result<()>>
|
pub fn exec_async<'fut>(self) -> LocalBoxFuture<'fut, Result<()>>
|
||||||
where
|
where
|
||||||
'lua: 'fut,
|
'lua: 'fut,
|
||||||
|
@ -2002,6 +2007,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
|
||||||
///
|
///
|
||||||
/// [`Chunk::eval`]: struct.Chunk.html#method.eval
|
/// [`Chunk::eval`]: struct.Chunk.html#method.eval
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn eval_async<'fut, R>(self) -> LocalBoxFuture<'fut, Result<R>>
|
pub fn eval_async<'fut, R>(self) -> LocalBoxFuture<'fut, Result<R>>
|
||||||
where
|
where
|
||||||
'lua: 'fut,
|
'lua: 'fut,
|
||||||
|
@ -2036,6 +2042,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> {
|
||||||
///
|
///
|
||||||
/// [`Chunk::call`]: struct.Chunk.html#method.call
|
/// [`Chunk::call`]: struct.Chunk.html#method.call
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn call_async<'fut, A, R>(self, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
pub fn call_async<'fut, A, R>(self, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
||||||
where
|
where
|
||||||
'lua: 'fut,
|
'lua: 'fut,
|
||||||
|
|
|
@ -115,6 +115,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
||||||
/// [`Lua::scope`]: struct.Lua.html#method.scope
|
/// [`Lua::scope`]: struct.Lua.html#method.scope
|
||||||
/// [`Lua::async_scope`]: struct.Lua.html#method.async_scope
|
/// [`Lua::async_scope`]: struct.Lua.html#method.async_scope
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn create_async_function<'callback, A, R, F, FR>(
|
pub fn create_async_function<'callback, A, R, F, FR>(
|
||||||
&'callback self,
|
&'callback self,
|
||||||
func: F,
|
func: F,
|
||||||
|
@ -164,6 +165,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> {
|
||||||
/// [`Lua::create_ser_userdata`]: struct.Lua.html#method.create_ser_userdata
|
/// [`Lua::create_ser_userdata`]: struct.Lua.html#method.create_ser_userdata
|
||||||
/// [`Lua::scope`]: struct.Lua.html#method.scope
|
/// [`Lua::scope`]: struct.Lua.html#method.scope
|
||||||
#[cfg(feature = "serialize")]
|
#[cfg(feature = "serialize")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))]
|
||||||
pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData<'lua>>
|
pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData<'lua>>
|
||||||
where
|
where
|
||||||
T: 'static + UserData + Serialize,
|
T: 'static + UserData + Serialize,
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
//! (De)Serialization support using serde.
|
||||||
|
|
||||||
use std::os::raw::{c_int, c_void};
|
use std::os::raw::{c_int, c_void};
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
|
|
|
@ -550,6 +550,7 @@ pub trait TableExt<'lua> {
|
||||||
///
|
///
|
||||||
/// This might invoke the `__index` metamethod.
|
/// This might invoke the `__index` metamethod.
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
fn call_async_method<'fut, K, A, R>(&self, key: K, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
fn call_async_method<'fut, K, A, R>(&self, key: K, args: A) -> LocalBoxFuture<'fut, Result<R>>
|
||||||
where
|
where
|
||||||
'lua: 'fut,
|
'lua: 'fut,
|
||||||
|
@ -564,6 +565,7 @@ pub trait TableExt<'lua> {
|
||||||
///
|
///
|
||||||
/// This might invoke the `__index` metamethod.
|
/// This might invoke the `__index` metamethod.
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
fn call_async_function<'fut, K, A, R>(
|
fn call_async_function<'fut, K, A, R>(
|
||||||
&self,
|
&self,
|
||||||
key: K,
|
key: K,
|
||||||
|
|
|
@ -52,6 +52,7 @@ pub struct Thread<'lua>(pub(crate) LuaRef<'lua>);
|
||||||
/// [`Future`]: ../futures_core/future/trait.Future.html
|
/// [`Future`]: ../futures_core/future/trait.Future.html
|
||||||
/// [`Stream`]: ../futures_core/stream/trait.Stream.html
|
/// [`Stream`]: ../futures_core/stream/trait.Stream.html
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AsyncThread<'lua, R> {
|
pub struct AsyncThread<'lua, R> {
|
||||||
thread: Thread<'lua>,
|
thread: Thread<'lua>,
|
||||||
|
@ -218,6 +219,7 @@ impl<'lua> Thread<'lua> {
|
||||||
/// # }
|
/// # }
|
||||||
/// ```
|
/// ```
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
pub fn into_async<A, R>(self, args: A) -> AsyncThread<'lua, R>
|
pub fn into_async<A, R>(self, args: A) -> AsyncThread<'lua, R>
|
||||||
where
|
where
|
||||||
A: ToLuaMulti<'lua>,
|
A: ToLuaMulti<'lua>,
|
||||||
|
|
|
@ -191,6 +191,7 @@ pub trait UserDataMethods<'lua, T: UserData> {
|
||||||
///
|
///
|
||||||
/// [`add_method`]: #method.add_method
|
/// [`add_method`]: #method.add_method
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
fn add_async_method<S, A, R, M, MR>(&mut self, name: &S, method: M)
|
fn add_async_method<S, A, R, M, MR>(&mut self, name: &S, method: M)
|
||||||
where
|
where
|
||||||
T: Clone,
|
T: Clone,
|
||||||
|
@ -237,6 +238,7 @@ pub trait UserDataMethods<'lua, T: UserData> {
|
||||||
///
|
///
|
||||||
/// [`add_function`]: #method.add_function
|
/// [`add_function`]: #method.add_function
|
||||||
#[cfg(feature = "async")]
|
#[cfg(feature = "async")]
|
||||||
|
#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
|
||||||
fn add_async_function<S, A, R, F, FR>(&mut self, name: &S, function: F)
|
fn add_async_function<S, A, R, F, FR>(&mut self, name: &S, function: F)
|
||||||
where
|
where
|
||||||
T: Clone,
|
T: Clone,
|
||||||
|
|
Loading…
Reference in New Issue