Struct ext_php_rs::builders::ModuleBuilder
source · [−]pub struct ModuleBuilder { /* private fields */ }
Expand description
Builds a Zend module extension to be registered with PHP. Must be called
from within an external function called get_module
, returning a mutable
pointer to a ModuleEntry
.
use ext_php_rs::{
builders::ModuleBuilder,
zend::ModuleEntry,
info_table_start, info_table_end, info_table_row
};
#[no_mangle]
pub extern "C" fn php_module_info(_module: *mut ModuleEntry) {
info_table_start!();
info_table_row!("column 1", "column 2");
info_table_end!();
}
#[no_mangle]
pub extern "C" fn get_module() -> *mut ModuleEntry {
ModuleBuilder::new("ext-name", "ext-version")
.info_function(php_module_info)
.build()
.unwrap()
.into_raw()
}
Implementations
sourceimpl ModuleBuilder
impl ModuleBuilder
sourcepub fn new<T: Into<String>, U: Into<String>>(name: T, version: U) -> Self
pub fn new<T: Into<String>, U: Into<String>>(name: T, version: U) -> Self
Creates a new module builder with a given name and version.
Arguments
name
- The name of the extension.version
- The current version of the extension.
sourcepub fn startup_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
pub fn startup_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
sourcepub fn shutdown_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
pub fn shutdown_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
Sets the shutdown function for the extension.
Arguments
func
- The function to be called on shutdown.
sourcepub fn request_startup_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
pub fn request_startup_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
Sets the request startup function for the extension.
Arguments
func
- The function to be called when startup is requested.
sourcepub fn request_shutdown_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
pub fn request_shutdown_function(
self,
func: extern "C" fn(_type: i32, _module_number: i32) -> i32
) -> Self
Sets the request shutdown function for the extension.
Arguments
func
- The function to be called when shutdown is requested.
sourcepub fn info_function(
self,
func: extern "C" fn(zend_module: *mut ModuleEntry)
) -> Self
pub fn info_function(
self,
func: extern "C" fn(zend_module: *mut ModuleEntry)
) -> Self
Sets the extension information function for the extension.
Arguments
func
- The function to be called to retrieve the information about the extension.
sourcepub fn function(self, func: FunctionEntry) -> Self
pub fn function(self, func: FunctionEntry) -> Self
sourcepub fn build(self) -> Result<ModuleEntry>
pub fn build(self) -> Result<ModuleEntry>
Builds the extension and returns a ModuleEntry
.
Returns a result containing the module entry if successful.
Trait Implementations
sourceimpl Clone for ModuleBuilder
impl Clone for ModuleBuilder
sourcefn clone(&self) -> ModuleBuilder
fn clone(&self) -> ModuleBuilder
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl RefUnwindSafe for ModuleBuilder
impl !Send for ModuleBuilder
impl !Sync for ModuleBuilder
impl Unpin for ModuleBuilder
impl UnwindSafe for ModuleBuilder
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more