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 php_eval;
36#[cfg(feature = "observer")]
37#[cfg_attr(docs, doc(cfg(feature = "observer")))]
38pub mod observer {
39    //! Observer API for function call profiling, tracing, error and exception monitoring.
40    pub use crate::zend::error_observer::{BacktraceFrame, ErrorInfo, ErrorObserver, ErrorType};
41    pub use crate::zend::exception_observer::{ExceptionInfo, ExceptionObserver};
42    pub use crate::zend::observer::{FcallInfo, FcallObserver};
43    pub use crate::zend::zend_extension::{ZendExtensionBuilder, ZendExtensionHandler};
44}
45#[doc(hidden)]
46pub mod internal;
47
48// Re-export inventory for use by macros
49#[doc(hidden)]
50pub use inventory;
51#[cfg(test)]
52pub mod test;
53pub mod types;
54mod util;
55pub mod zend;
56
57/// A module typically glob-imported containing the typically required macros
58/// and imports.
59pub mod prelude {
60
61    pub use crate::builders::ModuleBuilder;
62    #[cfg(any(docs, feature = "closure"))]
63    #[cfg_attr(docs, doc(cfg(feature = "closure")))]
64    pub use crate::closure::Closure;
65    pub use crate::exception::{PhpException, PhpResult};
66    pub use crate::flags::{DataTypeExt, ErrorType};
67    #[cfg(feature = "enum")]
68    pub use crate::php_enum;
69    pub use crate::php_print;
70    pub use crate::php_println;
71    pub use crate::php_write;
72    pub use crate::types::ZendCallable;
73    #[cfg(feature = "observer")]
74    pub use crate::zend::{
75        BacktraceFrame, ErrorInfo, ErrorObserver, ExceptionInfo, ExceptionObserver, FcallInfo,
76        FcallObserver, ZendExtensionHandler,
77    };
78    pub use crate::zend::{BailoutGuard, ModuleGlobal, ModuleGlobals};
79    pub use crate::{
80        ZvalConvert, php_class, php_const, php_extern, php_function, php_impl, php_impl_interface,
81        php_interface, php_module, wrap_constant, wrap_function, zend_fastcall,
82    };
83}
84
85/// `ext-php-rs` version.
86pub const VERSION: &str = env!("CARGO_PKG_VERSION");
87
88/// Whether the extension is compiled for PHP debug mode.
89pub const PHP_DEBUG: bool = cfg!(php_debug);
90
91/// Whether the extension is compiled for PHP thread-safe mode.
92pub const PHP_ZTS: bool = cfg!(php_zts);
93
94/// Whether the extension is compiled for PHP 8.1 or later.
95pub const PHP_81: bool = cfg!(php81);
96
97/// Whether the extension is compiled for PHP 8.2 or later.
98pub const PHP_82: bool = cfg!(php82);
99
100/// Whether the extension is compiled for PHP 8.3 or later.
101pub const PHP_83: bool = cfg!(php83);
102
103/// Whether the extension is compiled for PHP 8.4 or later.
104pub const PHP_84: bool = cfg!(php84);
105
106/// Whether the extension is compiled for PHP 8.5 or later.
107pub const PHP_85: bool = cfg!(php85);
108
109#[cfg(feature = "enum")]
110pub use ext_php_rs_derive::php_enum;
111pub use ext_php_rs_derive::{
112    ZvalConvert, php_class, php_const, php_extern, php_function, php_impl, php_impl_interface,
113    php_interface, php_module, wrap_constant, wrap_function, zend_fastcall,
114};