Struct ext_php_rs::types::ZendCallable[][src]

pub struct ZendCallable<'a>(_);
Expand description

Acts as a wrapper around a callable Zval. Allows the owner to call the Zval as if it was a PHP function through the try_call method.

Implementations

Attempts to create a new ZendCallable from a zval.

Parameters
  • callable - The underlying Zval that is callable.
Errors

Returns an error if the Zval was not callable.

Attempts to create a new ZendCallable by taking ownership of a Zval. Returns a result containing the callable if the zval was callable.

Parameters
  • callable - TThe underlying Zval that is callable.

Attempts to create a new ZendCallable from a function name. Returns a result containing the callable if the function existed and was callable.

Parameters
  • name - Name of the callable function.
Example
use ext_php_rs::types::ZendCallable;

let strpos = ZendCallable::try_from_name("strpos").unwrap();
let result = strpos.try_call(vec![&"hello", &"e"]).unwrap();
assert_eq!(result.long(), Some(1));

Attempts to call the callable with a list of arguments to pass to the function.

You should not call this function directly, rather through the call_user_func macro.

Parameters
  • params - A list of parameters to call the function with.
Returns

Returns the result wrapped in Ok upon success. If calling the callable fails, or an exception is thrown, an Err is returned.

Example
use ext_php_rs::types::ZendCallable;

let strpos = ZendCallable::try_from_name("strpos").unwrap();
let result = strpos.try_call(vec![&"hello", &"e"]).unwrap();
assert_eq!(result.long(), Some(1));

Trait Implementations

Formats the value using the given formatter. Read more

The corresponding type of the implemented value in PHP.

Attempts to retrieve an instance of Self from a reference to a Zval. Read more

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

The corresponding type of the implemented value in PHP.

Attempts to retrieve an instance of Self from a mutable reference to a Zval. Read more

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.