Skip to main content

ext_php_rs/
lib.rs

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