Skip to main content

StateObj

Struct StateObj 

Source
pub struct StateObj<T> { /* private fields */ }
Expand description

The object owned state, usually as the parameter of method handler.

Implementations§

Source§

impl<T> StateObj<T>

Source

pub fn as_object(&self) -> &ZObj

Gets object.

Source

pub fn as_mut_object(&mut self) -> &mut ZObj

Gets mutable object.

Source§

impl<T: 'static> StateObj<T>

Source

pub fn as_state(&self) -> &T

Gets inner state.

Source

pub fn as_mut_state(&mut self) -> &mut T

Gets inner mutable state.

Methods from Deref<Target = ZObj>§

Source

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

Returns a raw pointer wrapped.

Source

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

Returns a raw pointer wrapped.

Source

pub unsafe fn as_state_obj<T>(&self) -> &StateObj<T>

Upgrade to state obj.

§Safety

Should only call this method for the class of object defined by the extension created by phper, otherwise, memory problems will caused.

Source

pub unsafe fn as_mut_state_obj<T>(&mut self) -> &mut StateObj<T>

Upgrade to mutable state obj.

§Safety

Should only call this method for the class of object defined by the extension created by phper, otherwise, memory problems will caused.

Source

pub fn handle(&self) -> u32

Get the inner handle of object.

Source

pub fn get_class(&self) -> &ClassEntry

Get the class reference of object.

Source

pub fn get_mut_class(&mut self) -> &mut ClassEntry

Get the mutable class reference of object.

Source

pub fn get_property(&self, name: impl AsRef<str>) -> &ZVal

Get the property by name of object.

Source

pub fn get_mut_property(&mut self, name: impl AsRef<str>) -> &mut ZVal

Get the mutable property by name of object.

Source

pub fn set_property(&mut self, name: impl AsRef<str>, val: impl Into<ZVal>)

Set the property by name of object.

Source

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

Call the object method by name.

§Examples
use phper::{alloc::EBox, classes::ClassEntry, values::ZVal};

fn example() -> phper::Result<ZVal> {
    let mut memcached = ClassEntry::from_globals("Memcached")?.new_object(&mut [])?;
    memcached.call(
        "addServer",
        &mut [ZVal::from("127.0.0.1"), ZVal::from(11211)],
    )?;
    let r = memcached.call("get", &mut [ZVal::from("hello")])?;
    Ok(r)
}

Trait Implementations§

Source§

impl<T> Debug for StateObj<T>

Source§

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

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

impl<T> Deref for StateObj<T>

Source§

type Target = ZObj

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T> DerefMut for StateObj<T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for StateObj<T>

§

impl<T> !Send for StateObj<T>

§

impl<T> !Sync for StateObj<T>

§

impl<T> !UnwindSafe for StateObj<T>

§

impl<T> Freeze for StateObj<T>

§

impl<T> Unpin for StateObj<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for StateObj<T>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.