Skip to main content

ext_php_rs/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(clippy::unwrap_used)]
3#![allow(non_upper_case_globals)]
4#![allow(non_camel_case_types)]
5#![allow(non_snake_case)]
6#![allow(unsafe_attr_outside_unsafe)]
7#![warn(clippy::pedantic)]
8#![cfg_attr(docs, feature(doc_cfg))]
9#![cfg_attr(windows, feature(abi_vectorcall))]
10
11pub mod alloc;
12pub mod args;
13pub mod binary;
14pub mod binary_slice;
15pub mod builders;
16pub mod convert;
17pub mod error;
18pub mod exception;
19pub mod ffi;
20pub mod flags;
21#[macro_use]
22pub mod macros;
23pub mod boxed;
24pub mod class;
25#[cfg(any(docs, feature = "closure"))]
26#[cfg_attr(docs, doc(cfg(feature = "closure")))]
27pub mod closure;
28pub mod constant;
29pub mod describe;
30#[cfg(feature = "embed")]
31pub mod embed;
32#[cfg(feature = "enum")]
33pub mod enum_;
34#[cfg(feature = "observer")]
35#[cfg_attr(docs, doc(cfg(feature = "observer")))]
36pub mod observer {
37    //! Observer API for function call profiling and tracing.
38    pub use crate::zend::observer::{FcallInfo, FcallObserver};
39}
40#[doc(hidden)]
41pub mod internal;
42pub mod props;
43pub mod rc;
44#[cfg(test)]
45pub mod test;
46pub mod types;
47mod util;
48pub mod zend;
49
50/// A module typically glob-imported containing the typically required macros
51/// and imports.
52pub mod prelude {
53
54    pub use crate::builders::ModuleBuilder;
55    #[cfg(any(docs, feature = "closure"))]
56    #[cfg_attr(docs, doc(cfg(feature = "closure")))]
57    pub use crate::closure::Closure;
58    pub use crate::exception::{PhpException, PhpResult};
59    #[cfg(feature = "enum")]
60    pub use crate::php_enum;
61    pub use crate::php_print;
62    pub use crate::php_println;
63    pub use crate::php_write;
64    pub use crate::types::ZendCallable;
65    pub use crate::zend::BailoutGuard;
66    #[cfg(feature = "observer")]
67    pub use crate::zend::{FcallInfo, FcallObserver};
68    pub use crate::{
69        ZvalConvert, php_class, php_const, php_extern, php_function, php_impl, php_interface,
70        php_module, wrap_constant, wrap_function, zend_fastcall,
71    };
72}
73
74/// `ext-php-rs` version.
75pub const VERSION: &str = env!("CARGO_PKG_VERSION");
76
77/// Whether the extension is compiled for PHP debug mode.
78pub const PHP_DEBUG: bool = cfg!(php_debug);
79
80/// Whether the extension is compiled for PHP thread-safe mode.
81pub const PHP_ZTS: bool = cfg!(php_zts);
82
83/// Whether the extension is compiled for PHP 8.1 or later.
84pub const PHP_81: bool = cfg!(php81);
85
86/// Whether the extension is compiled for PHP 8.2 or later.
87pub const PHP_82: bool = cfg!(php82);
88
89/// Whether the extension is compiled for PHP 8.3 or later.
90pub const PHP_83: bool = cfg!(php83);
91
92/// Whether the extension is compiled for PHP 8.4 or later.
93pub const PHP_84: bool = cfg!(php84);
94
95/// Whether the extension is compiled for PHP 8.5 or later.
96pub const PHP_85: bool = cfg!(php85);
97
98#[cfg(feature = "enum")]
99pub use ext_php_rs_derive::php_enum;
100pub use ext_php_rs_derive::{
101    ZvalConvert, php_class, php_const, php_extern, php_function, php_impl, php_interface,
102    php_module, wrap_constant, wrap_function, zend_fastcall,
103};