#[repr(C)]
pub struct _zval_struct { pub value: zend_value, pub u1: _zval_struct__bindgen_ty_1, pub u2: _zval_struct__bindgen_ty_2, }

Fields§

§value: zend_value§u1: _zval_struct__bindgen_ty_1§u2: _zval_struct__bindgen_ty_2

Implementations§

source§

impl _zval_struct

source

pub const fn new() -> Self

Creates a new, empty zval.

source

pub fn dereference(&self) -> &Self

Dereference the zval, if it is a reference.

source

pub fn dereference_mut(&mut self) -> &mut Self

Dereference the zval mutable, if it is a reference.

source

pub fn long(&self) -> Option<ZendLong>

Returns the value of the zval if it is a long.

source

pub fn bool(&self) -> Option<bool>

Returns the value of the zval if it is a bool.

source

pub fn double(&self) -> Option<f64>

Returns the value of the zval if it is a double.

source

pub fn zend_str(&self) -> Option<&ZendStr>

Returns the value of the zval as a zend string, if it is a string.

Note that this functions output will not be the same as string(), as this function does not attempt to convert other types into a String.

source

pub fn string(&self) -> Option<String>

Returns the value of the zval if it is a string.

source

pub fn str(&self) -> Option<&str>

Returns the value of the zval if it is a string.

Note that this functions output will not be the same as string(), as this function does not attempt to convert other types into a String, as it could not pass back a &str in those cases.

source

pub fn binary<T: Pack>(&self) -> Option<Vec<T>>

Returns the value of the zval if it is a string and can be unpacked into a vector of a given type. Similar to the unpack function in PHP, except you can only unpack one type.

§Safety

There is no way to tell if the data stored in the string is actually of the given type. The results of this function can also differ from platform-to-platform due to the different representation of some types on different platforms. Consult the pack function documentation for more details.

source

pub fn binary_slice<T: PackSlice>(&self) -> Option<&[T]>

Returns the value of the zval if it is a string and can be unpacked into a slice of a given type. Similar to the unpack function in PHP, except you can only unpack one type.

This function is similar to Zval::binary except that a slice is returned instead of a vector, meaning the contents of the string is not copied.

§Safety

There is no way to tell if the data stored in the string is actually of the given type. The results of this function can also differ from platform-to-platform due to the different representation of some types on different platforms. Consult the pack function documentation for more details.

source

pub fn resource(&self) -> Option<*mut zend_resource>

Returns the value of the zval if it is a resource.

source

pub fn array(&self) -> Option<&ZendHashTable>

Returns an immutable reference to the underlying zval hashtable if the zval contains an array.

source

pub fn array_mut(&mut self) -> Option<&mut ZendHashTable>

Returns a mutable reference to the underlying zval hashtable if the zval contains an array.

source

pub fn object(&self) -> Option<&ZendObject>

Returns the value of the zval if it is an object.

source

pub fn object_mut(&mut self) -> Option<&mut ZendObject>

Returns a mutable reference to the object contained in the Zval, if any.

source

pub fn try_call_method( &self, name: &str, params: Vec<&dyn IntoZvalDyn> ) -> Result<Zval>

source

pub fn indirect(&self) -> Option<&Zval>

Returns the value of the zval if it is an internal indirect reference.

source

pub fn indirect_mut(&self) -> Option<&mut Zval>

Returns a mutable reference to the zval if it is an internal indirect reference.

source

pub fn reference(&self) -> Option<&Zval>

Returns the value of the zval if it is a reference.

source

pub fn reference_mut(&mut self) -> Option<&mut Zval>

Returns a mutable reference to the underlying zval if it is a reference.

source

pub fn callable(&self) -> Option<ZendCallable<'_>>

Returns the value of the zval if it is callable.

source

pub fn traversable(&self) -> Option<&mut ZendIterator>

Returns an iterator over the zval if it is traversable.

source

pub fn iterable(&self) -> Option<Iterable<'_>>

Returns an iterable over the zval if it is an array or traversable. (is iterable)

source

pub unsafe fn ptr<T>(&self) -> Option<*mut T>

Returns the value of the zval if it is a pointer.

§Safety

The caller must ensure that the pointer contained in the zval is in fact a pointer to an instance of T, as the zval has no way of defining the type of pointer.

source

pub fn try_call(&self, params: Vec<&dyn IntoZvalDyn>) -> Result<Zval>

Attempts to call the zval as a callable with a list of arguments to pass to the function. Note that a thrown exception inside the callable is not detectable, therefore you should check if the return value is valid rather than unwrapping. Returns a result containing the return value of the function, or an error.

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

pub fn get_type(&self) -> DataType

Returns the type of the Zval.

source

pub fn is_long(&self) -> bool

Returns true if the zval is a long, false otherwise.

source

pub fn is_null(&self) -> bool

Returns true if the zval is null, false otherwise.

source

pub fn is_true(&self) -> bool

Returns true if the zval is true, false otherwise.

source

pub fn is_false(&self) -> bool

Returns true if the zval is false, false otherwise.

source

pub fn is_bool(&self) -> bool

Returns true if the zval is a bool, false otherwise.

source

pub fn is_double(&self) -> bool

Returns true if the zval is a double, false otherwise.

source

pub fn is_string(&self) -> bool

Returns true if the zval is a string, false otherwise.

source

pub fn is_resource(&self) -> bool

Returns true if the zval is a resource, false otherwise.

source

pub fn is_array(&self) -> bool

Returns true if the zval is an array, false otherwise.

source

pub fn is_object(&self) -> bool

Returns true if the zval is an object, false otherwise.

source

pub fn is_reference(&self) -> bool

Returns true if the zval is a reference, false otherwise.

source

pub fn is_indirect(&self) -> bool

Returns true if the zval is a reference, false otherwise.

source

pub fn is_callable(&self) -> bool

Returns true if the zval is callable, false otherwise.

source

pub fn is_identical(&self, other: &Self) -> bool

Checks if the zval is identical to another one. This works like === in php.

§Parameters
  • other - The the zval to check identity against.
source

pub fn is_traversable(&self) -> bool

Returns true if the zval is traversable, false otherwise.

source

pub fn is_iterable(&self) -> bool

Returns true if the zval is iterable (array or traversable), false otherwise.

source

pub fn is_ptr(&self) -> bool

Returns true if the zval contains a pointer, false otherwise.

source

pub fn set_string(&mut self, val: &str, persistent: bool) -> Result<()>

Sets the value of the zval as a string. Returns nothing in a result when successful.

§Parameters
  • val - The value to set the zval as.
  • persistent - Whether the string should persist between requests.
source

pub fn set_zend_string(&mut self, val: ZBox<ZendStr>)

Sets the value of the zval as a Zend string.

§Parameters
  • val - String content.
source

pub fn set_binary<T: Pack>(&mut self, val: Vec<T>)

Sets the value of the zval as a binary string, which is represented in Rust as a vector.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_interned_string(&mut self, val: &str, persistent: bool) -> Result<()>

Sets the value of the zval as a interned string. Returns nothing in a result when successful.

§Parameters
  • val - The value to set the zval as.
  • persistent - Whether the string should persist between requests.
source

pub fn set_long<T: Into<ZendLong>>(&mut self, val: T)

Sets the value of the zval as a long.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_double<T: Into<f64>>(&mut self, val: T)

Sets the value of the zval as a double.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_bool<T: Into<bool>>(&mut self, val: T)

Sets the value of the zval as a boolean.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_null(&mut self)

Sets the value of the zval as null.

This is the default of a zval.

source

pub fn set_resource(&mut self, val: *mut zend_resource)

Sets the value of the zval as a resource.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_object(&mut self, val: &mut ZendObject)

Sets the value of the zval as a reference to an object.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_array<T: TryInto<ZBox<ZendHashTable>, Error = Error>>( &mut self, val: T ) -> Result<()>

Sets the value of the zval as an array. Returns nothing in a result on success.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_hashtable(&mut self, val: ZBox<ZendHashTable>)

Sets the value of the zval as an array. Returns nothing in a result on success.

§Parameters
  • val - The value to set the zval as.
source

pub fn set_ptr<T>(&mut self, ptr: *mut T)

Sets the value of the zval as a pointer.

§Parameters
  • ptr - The pointer to set the zval as.
source

pub fn extract<'a, T>(&'a self) -> Option<T>
where T: FromZval<'a>,

Extracts some type from a Zval.

This is a wrapper function around TryFrom.

source

pub fn shallow_clone(&self) -> Zval

Creates a shallow clone of the Zval.

This copies the contents of the Zval, and increments the reference counter of the underlying value (if it is reference counted).

For example, if the zval contains a long, it will simply copy the value. However, if the zval contains an object, the new zval will point to the same object, and the objects reference counter will be incremented.

§Returns

The cloned zval.

Trait Implementations§

source§

impl FromIterator<_zval_struct> for ZBox<ZendHashTable>

source§

fn from_iter<T: IntoIterator<Item = Zval>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<T: Pack> TryFrom<_zval_struct> for Binary<T>

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for String

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<_zval_struct> for ZendCallable<'a>

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for bool

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for f64

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for i16

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for i32

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for i64

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for i8

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for isize

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for u16

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for u32

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for u64

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for u8

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.
source§

impl TryFrom<_zval_struct> for usize

§

type Error = Error

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

fn try_from(value: Zval) -> Result<Self>

Performs the conversion.

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

§

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.