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