pub struct FunctionBuilder<'a> { /* private fields */ }
Expand description

Builder for registering a function in PHP.

Implementations§

source§

impl<'a> FunctionBuilder<'a>

source

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.
source

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.
source

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.
source

pub fn arg(self, arg: Arg<'a>) -> Self

Adds an argument to the function.

§Parameters
  • arg - The argument to add to the function.
source

pub fn not_required(self) -> Self

Sets the rest of the given arguments as not required.

source

pub fn variadic(self) -> Self

source

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.
source

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§

source§

impl<'a> Debug for FunctionBuilder<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.