Struct ZVal

Source
pub struct ZVal { /* private fields */ }
Expand description

Wrapper of zval.

Implementations§

Source§

impl ZVal

Source

pub unsafe fn from_ptr<'a>(ptr: *const zval) -> &'a Self

Wraps a raw pointer.

§Safety

Create from raw pointer.

§Panics

Panics if pointer is null.

Source

pub unsafe fn try_from_ptr<'a>(ptr: *const zval) -> Option<&'a Self>

Wraps a raw pointer, return None if pointer is null.

§Safety

Create from raw pointer.

Source

pub unsafe fn from_mut_ptr<'a>(ptr: *mut zval) -> &'a mut Self

Wraps a raw pointer.

§Safety

Create from raw pointer.

§Panics

Panics if pointer is null.

Source

pub unsafe fn try_from_mut_ptr<'a>(ptr: *mut zval) -> Option<&'a mut Self>

Wraps a raw pointer, return None if pointer is null.

§Safety

Create from raw pointer.

Source

pub const fn as_ptr(&self) -> *const zval

Returns a raw pointer wrapped.

Source

pub fn as_mut_ptr(&mut self) -> *mut zval

Returns a raw pointer wrapped.

Source

pub fn into_inner(self) -> zval

Consumes the ZVal, returning the wrapped zval.

Source

pub fn get_type_info(&self) -> TypeInfo

Gets the type info of ZVal.

Source

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

Converts to null if ZVal is null.

Source

pub fn expect_null(&self) -> Result<()>

Converts to null if ZVal is null, otherwise returns ExpectTypeError.

Source

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

Converts to bool if ZVal is bool.

Source

pub fn expect_bool(&self) -> Result<bool>

Converts to bool if ZVal is bool, otherwise returns ExpectTypeError.

Source

pub fn as_long(&self) -> Option<i64>

Converts to long if ZVal is long.

Source

pub fn expect_long(&self) -> Result<i64>

Converts to long if ZVal is long, otherwise returns ExpectTypeError.

Source

pub fn as_mut_long(&mut self) -> Option<&mut i64>

Converts to mutable long if ZVal is long.

§Examples
use phper::values::ZVal;

let mut val = ZVal::from(100);
*val.as_mut_long().unwrap() += 100;
assert_eq!(val.as_long().unwrap(), 200);
Source

pub fn expect_mut_long(&mut self) -> Result<&mut i64>

Converts to mutable long if ZVal is long, otherwise returns ExpectTypeError.

§Examples
use phper::values::ZVal;

let mut val = ZVal::from(100);
*val.expect_mut_long().unwrap() += 100;
assert_eq!(val.expect_long().unwrap(), 200);
Source

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

Converts to double if ZVal is double.

Source

pub fn expect_double(&self) -> Result<f64>

Converts to double if ZVal is double, otherwise returns ExpectTypeError.

Source

pub fn as_mut_double(&mut self) -> Option<&mut f64>

Converts to mutable double if ZVal is double.

Source

pub fn expect_mut_double(&mut self) -> Result<&mut f64>

Converts to mutable double if ZVal is double, otherwise returns ExpectTypeError.

Source

pub fn as_z_str(&self) -> Option<&ZStr>

Converts to string if ZVal is string.

Source

pub fn expect_z_str(&self) -> Result<&ZStr>

Converts to string if ZVal is string, otherwise returns ExpectTypeError.

Source

pub fn as_mut_z_str(&mut self) -> Option<&mut ZStr>

Converts to mutable string if ZVal is string.

Source

pub fn expect_mut_z_str(&mut self) -> Result<&mut ZStr>

Converts to mutable string if ZVal is string, otherwise returns ExpectTypeError.

Source

pub fn as_z_arr(&self) -> Option<&ZArr>

Converts to array if ZVal is array.

Source

pub fn expect_z_arr(&self) -> Result<&ZArr>

Converts to array if ZVal is array, otherwise returns ExpectTypeError.

Source

pub fn as_mut_z_arr(&mut self) -> Option<&mut ZArr>

Converts to mutable array if ZVal is array.

Source

pub fn expect_mut_z_arr(&mut self) -> Result<&mut ZArr>

Converts to mutable array if ZVal is array, otherwise returns ExpectTypeError.

Source

pub fn as_z_obj(&self) -> Option<&ZObj>

Converts to object if ZVal is object.

Source

pub fn expect_z_obj(&self) -> Result<&ZObj>

Converts to object if ZVal is object, otherwise returns ExpectTypeError.

Source

pub fn as_mut_z_obj(&mut self) -> Option<&mut ZObj>

Converts to mutable object if ZVal is object.

Source

pub fn expect_mut_z_obj(&mut self) -> Result<&mut ZObj>

Converts to mutable object if ZVal is object, otherwise returns ExpectTypeError.

Source

pub fn as_z_res(&self) -> Option<&ZRes>

Converts to resource if ZVal is resource.

Source

pub fn expect_z_res(&self) -> Result<&ZRes>

Converts to resource if ZVal is resource, otherwise returns ExpectTypeError.

Source

pub fn as_mut_z_res(&mut self) -> Option<&mut ZRes>

Converts to mutable resource if ZVal is null.

Source

pub fn expect_mut_z_res(&mut self) -> Result<&mut ZRes>

Converts to mutable resource if ZVal is resource, otherwise returns ExpectTypeError.

Source

pub fn as_z_ref(&self) -> Option<&ZRef>

Converts to reference if ZVal is reference.

Source

pub fn expect_z_ref(&self) -> Result<&ZRef>

Converts to reference if ZVal is reference, otherwise returns ExpectTypeError.

Source

pub fn as_mut_z_ref(&mut self) -> Option<&mut ZRef>

Converts to mutable reference if ZVal is reference.

Source

pub fn expect_mut_z_ref(&mut self) -> Result<&mut ZRef>

Converts to mutable reference if ZVal is reference, otherwise returns ExpectTypeError.

Source

pub fn convert_to_long(&mut self)

Internally convert to long.

TODO To fix assertion failed.

Source

pub fn convert_to_string(&mut self)

Internally convert to string.

TODO To fix assertion failed.

Source

pub fn call(&mut self, arguments: impl AsMut<[ZVal]>) -> Result<ZVal>

Call only when self is a callable (string or array or closure).

§Errors

Return Err when self is not callable, or called failed.

Trait Implementations§

Source§

impl Clone for ZVal

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ZVal

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ZVal

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for ZVal

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<&[u8]> for ZVal

Source§

fn from(b: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&CStr> for ZVal

Source§

fn from(s: &CStr) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for ZVal

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<()> for ZVal

Source§

fn from(_: ()) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<ZVal>> From<EBox<T>> for ZVal

Source§

fn from(t: EBox<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Into<ZVal>> From<Option<T>> for ZVal

Source§

fn from(o: Option<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> From<StateObject<T>> for ZVal

Source§

fn from(obj: StateObject<T>) -> Self

Converts to this type from the input type.
Source§

impl From<String> for ZVal

Source§

fn from(s: String) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for ZVal

Source§

fn from(b: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<ZArray> for ZVal

Source§

fn from(arr: ZArray) -> Self

Converts to this type from the input type.
Source§

impl From<ZObject> for ZVal

Source§

fn from(obj: ZObject) -> Self

Converts to this type from the input type.
Source§

impl From<ZString> for ZVal

Source§

fn from(s: ZString) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for ZVal

Source§

fn from(b: bool) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for ZVal

Source§

fn from(f: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for ZVal

Source§

fn from(i: i64) -> Self

Converts to this type from the input type.
Source§

impl RefClone for ZVal

Source§

fn ref_clone(&mut self) -> Self

Returns a refcount value with same reference of the value.

Auto Trait Implementations§

§

impl Freeze for ZVal

§

impl RefUnwindSafe for ZVal

§

impl !Send for ZVal

§

impl !Sync for ZVal

§

impl Unpin for ZVal

§

impl UnwindSafe for ZVal

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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

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.