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