diff options
author | Alex Orlenko <zxteam@protonmail.com> | 2020-12-30 01:43:00 +0000 |
---|---|---|
committer | Alex Orlenko <zxteam@protonmail.com> | 2020-12-31 13:39:38 +0000 |
commit | 9f82cbe0c5255de3b82971f54a3e3c4355eba351 (patch) | |
tree | 1f2da31603a70cc16818e73167edbe52ddbf9257 | |
parent | 1a81f8d4474dbff5b30bd7e9fc62c1fe8b735196 (diff) | |
download | mlua-9f82cbe0c5255de3b82971f54a3e3c4355eba351.zip |
Update documentation
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/error.rs | 4 | ||||
-rw-r--r-- | src/function.rs | 1 | ||||
-rw-r--r-- | src/lib.rs | 22 | ||||
-rw-r--r-- | src/lua.rs | 7 | ||||
-rw-r--r-- | src/scope.rs | 2 | ||||
-rw-r--r-- | src/serde/mod.rs | 2 | ||||
-rw-r--r-- | src/table.rs | 2 | ||||
-rw-r--r-- | src/thread.rs | 2 | ||||
-rw-r--r-- | src/userdata.rs | 2 |
10 files changed, 37 insertions, 8 deletions
@@ -18,6 +18,7 @@ with async/await features and support of writing native lua modules in Rust. [package.metadata.docs.rs] features = ["lua53", "async", "send", "serialize"] +rustdoc-args = ["--cfg", "docsrs"] [workspace] members = [ diff --git a/src/error.rs b/src/error.rs index a4ff8b1..ad58307 100644 --- a/src/error.rs +++ b/src/error.rs @@ -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 /// destructed from exiting a `Lua::scope` call. + /// + /// [`AnyUserData`]: struct.AnyUserData.html UserDataDestructed, /// An [`AnyUserData`] immutable borrow failed because it is already borrowed mutably. /// @@ -139,9 +141,11 @@ pub enum Error { }, /// Serialization error. #[cfg(feature = "serialize")] + #[cfg_attr(docsrs, doc(cfg(feature = "serialize")))] SerializeError(StdString), /// Deserialization error. #[cfg(feature = "serialize")] + #[cfg_attr(docsrs, doc(cfg(feature = "serialize")))] DeserializeError(StdString), /// A custom error. /// diff --git a/src/function.rs b/src/function.rs index 45ad4e1..9a9c205 100644 --- a/src/function.rs +++ b/src/function.rs @@ -119,6 +119,7 @@ impl<'lua> Function<'lua> { /// /// [`AsyncThread`]: struct.AsyncThread.html #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn call_async<'fut, A, R>(&self, args: A) -> LocalBoxFuture<'fut, Result<R>> where 'lua: 'fut, @@ -26,12 +26,12 @@ //! //! # Serde support //! -//! The [`LuaSerdeExt`] trait implemented for [`Lua`] allow conversion from Rust types to Lua values -//! and vice versa using serde. Any user defined data type that implements `serde::Serialize` or -//! `serde::Deserialize` can be converted. -//! For convenience, additional functionality to handle NULL values and arrays is provided. +//! 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 +//! [`serde::Deserialize`] can be converted. +//! 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. //! //! Requires `feature = "serialize"`. @@ -46,7 +46,7 @@ //! //! # `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`]: struct.Lua.html @@ -57,14 +57,19 @@ //! [`FromLua`]: trait.FromLua.html //! [`ToLuaMulti`]: trait.ToLuaMulti.html //! [`FromLuaMulti`]: trait.FromLuaMulti.html +//! [`Function`]: struct.Function.html //! [`UserData`]: trait.UserData.html //! [`UserDataMethods`]: trait.UserDataMethods.html -//! [`LuaSerdeExt`]: trait.LuaSerdeExt.html -//! [`Value`]: struct.Value.html +//! [`LuaSerdeExt`]: serde/trait.LuaSerdeExt.html +//! [`Value`]: enum.Value.html //! [`create_async_function`]: struct.Lua.html#method.create_async_function //! [`call_async`]: struct.Function.html#method.call_async //! [`AsyncThread`]: struct.AsyncThread.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* // warnings at all. @@ -114,6 +119,7 @@ pub use crate::serde::LuaSerdeExt; pub mod prelude; #[cfg(feature = "serialize")] +#[cfg_attr(docsrs, doc(cfg(feature = "serialize")))] pub mod serde; // Re-export #[mlua_derive::lua_module]. @@ -100,6 +100,7 @@ pub(crate) static EXTRA_REGISTRY_KEY: u8 = 0; /// Requires `feature = "send"` #[cfg(feature = "send")] +#[cfg_attr(docsrs, doc(cfg(feature = "send")))] unsafe impl Send for Lua {} impl Drop for Lua { @@ -957,6 +958,7 @@ impl Lua { /// [`Thread`]: struct.Thread.html /// [`AsyncThread`]: struct.AsyncThread.html #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn create_async_function<'lua, 'callback, A, R, F, FR>( &'lua self, func: F, @@ -1006,6 +1008,7 @@ impl Lua { /// /// Requires `feature = "serialize"` #[cfg(feature = "serialize")] + #[cfg_attr(docsrs, doc(cfg(feature = "serialize")))] pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData> where T: 'static + MaybeSend + UserData + Serialize, @@ -1071,6 +1074,7 @@ impl Lua { /// /// [`scope`]: #method.scope #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn async_scope<'lua, 'scope, R, F, FR>( &'lua self, f: F, @@ -1963,6 +1967,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> { /// /// [`Chunk::exec`]: struct.Chunk.html#method.exec #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn exec_async<'fut>(self) -> LocalBoxFuture<'fut, Result<()>> where 'lua: 'fut, @@ -2002,6 +2007,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> { /// /// [`Chunk::eval`]: struct.Chunk.html#method.eval #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn eval_async<'fut, R>(self) -> LocalBoxFuture<'fut, Result<R>> where 'lua: 'fut, @@ -2036,6 +2042,7 @@ impl<'lua, 'a> Chunk<'lua, 'a> { /// /// [`Chunk::call`]: struct.Chunk.html#method.call #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn call_async<'fut, A, R>(self, args: A) -> LocalBoxFuture<'fut, Result<R>> where 'lua: 'fut, diff --git a/src/scope.rs b/src/scope.rs index bfdae42..4965a1f 100644 --- a/src/scope.rs +++ b/src/scope.rs @@ -115,6 +115,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> { /// [`Lua::scope`]: struct.Lua.html#method.scope /// [`Lua::async_scope`]: struct.Lua.html#method.async_scope #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn create_async_function<'callback, A, R, F, FR>( &'callback self, func: F, @@ -164,6 +165,7 @@ impl<'lua, 'scope> Scope<'lua, 'scope> { /// [`Lua::create_ser_userdata`]: struct.Lua.html#method.create_ser_userdata /// [`Lua::scope`]: struct.Lua.html#method.scope #[cfg(feature = "serialize")] + #[cfg_attr(docsrs, doc(cfg(feature = "serialize")))] pub fn create_ser_userdata<T>(&self, data: T) -> Result<AnyUserData<'lua>> where T: 'static + UserData + Serialize, diff --git a/src/serde/mod.rs b/src/serde/mod.rs index a476d8f..3163d3d 100644 --- a/src/serde/mod.rs +++ b/src/serde/mod.rs @@ -1,3 +1,5 @@ +//! (De)Serialization support using serde. + use std::os::raw::{c_int, c_void}; use std::ptr; diff --git a/src/table.rs b/src/table.rs index f0a4acd..f294faf 100644 --- a/src/table.rs +++ b/src/table.rs @@ -550,6 +550,7 @@ pub trait TableExt<'lua> { /// /// This might invoke the `__index` metamethod. #[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>> where 'lua: 'fut, @@ -564,6 +565,7 @@ pub trait TableExt<'lua> { /// /// This might invoke the `__index` metamethod. #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] fn call_async_function<'fut, K, A, R>( &self, key: K, diff --git a/src/thread.rs b/src/thread.rs index 661abd3..f26eca1 100644 --- a/src/thread.rs +++ b/src/thread.rs @@ -52,6 +52,7 @@ pub struct Thread<'lua>(pub(crate) LuaRef<'lua>); /// [`Future`]: ../futures_core/future/trait.Future.html /// [`Stream`]: ../futures_core/stream/trait.Stream.html #[cfg(feature = "async")] +#[cfg_attr(docsrs, doc(cfg(feature = "async")))] #[derive(Debug)] pub struct AsyncThread<'lua, R> { thread: Thread<'lua>, @@ -218,6 +219,7 @@ impl<'lua> Thread<'lua> { /// # } /// ``` #[cfg(feature = "async")] + #[cfg_attr(docsrs, doc(cfg(feature = "async")))] pub fn into_async<A, R>(self, args: A) -> AsyncThread<'lua, R> where A: ToLuaMulti<'lua>, diff --git a/src/userdata.rs b/src/userdata.rs index ae6ff38..a6131a1 100644 --- a/src/userdata.rs +++ b/src/userdata.rs @@ -191,6 +191,7 @@ pub trait UserDataMethods<'lua, T: UserData> { /// /// [`add_method`]: #method.add_method #[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) where T: Clone, @@ -237,6 +238,7 @@ pub trait UserDataMethods<'lua, T: UserData> { /// /// [`add_function`]: #method.add_function #[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) where T: Clone, |