Skip to main content

ZendExtensionBuilder

Struct ZendExtensionBuilder 

Source
pub struct ZendExtensionBuilder<'a> { /* private fields */ }
Available on crate feature observer only.
Expand description

Builder for a zend_extension registration.

Returned by crate::builders::ModuleBuilder::zend_extension. Call Self::finish to return to the outer ModuleBuilder after selecting opt-in hooks.

Each opt-in method enables one family of ZendExtensionHandler hooks. Self::hook_statements and Self::hook_fcalls also flip the matching ZEND_COMPILE_* flag so PHP emits the extra opcodes the hook depends on, which costs every compiled script. Self::hook_op_array_compile has no compile-time cost because its flag is already set by PHP’s defaults; it only controls whether the dispatcher callback runs.

Implementations§

Source§

impl<'a> ZendExtensionBuilder<'a>

Source

pub fn hook_op_array_compile(self) -> Self

Enable on_op_array_compiled, called after PHP finishes compiling each function or method.

Unlike Self::hook_statements and Self::hook_fcalls, this opt-in does not change the bytecode PHP emits: the matching flag (ZEND_COMPILE_HANDLE_OP_ARRAY) is already part of PHP’s default CG(compiler_options). The opt-in only controls whether the dispatcher is registered, so the cost scales with the number of compiled functions, not with every opcode.

Source

pub fn hook_statements(self) -> Self

Enable on_statement – called for every executed statement.

Flips ZEND_COMPILE_EXTENDED_STMT, which causes PHP to emit extra ZEND_EXT_STMT opcodes in every compiled script. Opt in only if your profiler actually needs per-statement granularity.

Source

pub fn hook_fcalls(self) -> Self

Enable on_fcall_begin / on_fcall_end – legacy per-call-site hooks.

Flips ZEND_COMPILE_EXTENDED_FCALL, which causes PHP to emit ZEND_EXT_FCALL_BEGIN/END opcodes around every call site.

Source

pub fn finish(self) -> ModuleBuilder<'a>

Consume the builder, register the extension, and return the outer ModuleBuilder so further module config can be chained.

§Panics

Panics if a ZendExtensionHandler has already been registered on this module. Each extension may register at most one handler.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.