pub trait ModuleGlobal: Default + 'static {
// Provided methods
fn ginit(&mut self) { ... }
fn gshutdown(&mut self) { ... }
}Expand description
Trait for types used as PHP module globals.
Requires Default for initialization. Override ginit
and gshutdown for custom per-thread (ZTS) or
per-module (non-ZTS) lifecycle logic.
§Examples
use ext_php_rs::zend::ModuleGlobal;
#[derive(Default)]
struct MyGlobals {
request_count: i64,
max_depth: i32,
}
impl ModuleGlobal for MyGlobals {
fn ginit(&mut self) {
self.max_depth = 512;
}
}Provided Methods§
Sourcefn ginit(&mut self)
fn ginit(&mut self)
Called after the struct is initialized with Default::default().
Use for setup that goes beyond what Default can express.
In ZTS mode, called once per thread. In non-ZTS mode, called once at module init.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.