Struct ext_php_rs::builders::FunctionBuilder
source · pub struct FunctionBuilder<'a> { /* private fields */ }
Expand description
Builder for registering a function in PHP.
Implementations§
source§impl<'a> FunctionBuilder<'a>
impl<'a> FunctionBuilder<'a>
sourcepub fn new<T: Into<String>>(
name: T,
handler: extern "C" fn(execute_data: &mut ExecuteData, retval: &mut Zval)
) -> Self
pub fn new<T: Into<String>>( name: T, handler: extern "C" fn(execute_data: &mut ExecuteData, retval: &mut Zval) ) -> Self
Creates a new function builder, used to build functions to be exported to PHP.
§Parameters
name
- The name of the function.handler
- The handler to be called when the function is invoked from PHP.
sourcepub fn new_abstract<T: Into<String>>(name: T) -> Self
pub fn new_abstract<T: Into<String>>(name: T) -> Self
Create a new function builder for an abstract function that can be used on an abstract class or an interface.
§Parameters
name
- The name of the function.
sourcepub fn constructor(
handler: extern "C" fn(execute_data: &mut ExecuteData, retval: &mut Zval)
) -> Self
pub fn constructor( handler: extern "C" fn(execute_data: &mut ExecuteData, retval: &mut Zval) ) -> Self
Creates a constructor builder, used to build the constructor for classes.
§Parameters
handler
- The handler to be called when the function is invoked from PHP.
sourcepub fn not_required(self) -> Self
pub fn not_required(self) -> Self
Sets the rest of the given arguments as not required.
pub fn variadic(self) -> Self
sourcepub fn returns(self, type_: DataType, as_ref: bool, allow_null: bool) -> Self
pub fn returns(self, type_: DataType, as_ref: bool, allow_null: bool) -> Self
Sets the return value of the function.
§Parameters
type_
- The return type of the function.as_ref
- Whether the function returns a reference.allow_null
- Whether the function return value is nullable.
sourcepub fn build(self) -> Result<FunctionEntry>
pub fn build(self) -> Result<FunctionEntry>
Builds the function converting it into a Zend function entry.
Returns a result containing the function entry if successful.
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for FunctionBuilder<'a>
impl<'a> !Send for FunctionBuilder<'a>
impl<'a> !Sync for FunctionBuilder<'a>
impl<'a> Unpin for FunctionBuilder<'a>
impl<'a> !UnwindSafe for FunctionBuilder<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more