]> git.proxmox.com Git - perlmod.git/blame - perlmod/src/lib.rs
make values Clone
[perlmod.git] / perlmod / src / lib.rs
CommitLineData
ac1ed611
WB
1//! Crate for creating perl packages/bindings for rust code.
2//!
2991a46a
WB
3//! The main feature of this crate is the [`package`] macro provided by the `perlmod-macro` crate
4//! and documented here.
ac1ed611
WB
5//!
6//! The underlying machinery for these macros is contained in this crate and provides ways to
7//! serialize and deserialize data between perl and rust.
8//!
9//! [`package`]: attr.package.html
10//! [`export`]: attr.export.html
ac1ed611 11
f7cc8c37 12pub(crate) mod error;
87c10237 13pub use error::Error;
f7cc8c37 14
89989b0f
WB
15#[macro_use]
16mod macros;
17
f7cc8c37
WB
18pub mod de;
19pub mod ffi;
20pub mod ser;
21
22#[doc(inline)]
dd7f83c3 23pub use de::{from_ref_value, from_value};
f7cc8c37
WB
24#[doc(inline)]
25pub use ser::to_value;
26
27pub mod scalar;
28#[doc(inline)]
29pub use scalar::{Mortal, Scalar};
30
31pub mod array;
32#[doc(inline)]
33pub use array::Array;
34
35pub mod hash;
36#[doc(inline)]
37pub use hash::Hash;
38
39pub mod value;
40#[doc(inline)]
41pub use value::Value;
42
43#[cfg(feature = "exporter")]
42f7a45b 44#[doc(inline)]
7de9fdf0
WB
45pub use perlmod_macro::package;
46
47#[cfg(feature = "exporter")]
48#[doc(inline)]
49/// Attribute to export a function so that it can be installed as an `xsub` in perl. See the
50/// [`package!`](macro@package) macro for a usage example.
51///
52/// This macro can optionally take a `raw_return` argument specifying that the return type, which
53/// must be a [`Value`], will be returned as is, and not go through serialization.
54///
55/// Additionally, function parameters can also use the following attributes:
56///
57/// * `#[raw]` with a parameter of type [`Value`]: The parameter will be passed as
58/// is and not go through deserialization.
59/// * `#[try_from_ref]`: Instead of regular deserialization, `TryFrom::try_from(&Value)` will be
60/// used.
61///
62/// Implementing the `TryFrom` trait accordingly can make using blessed references more
63/// convenient, but at the cost of hiding underlying `unsafe` code.
64pub use perlmod_macro::export;