pub struct StateObj<T> { /* private fields */ }Expand description
The object owned state, usually as the parameter of method handler.
Implementations§
Methods from Deref<Target = ZObj>§
Sourcepub fn as_ptr(&self) -> *const zend_object
pub fn as_ptr(&self) -> *const zend_object
Returns a raw pointer wrapped.
Sourcepub fn as_mut_ptr(&mut self) -> *mut zend_object
pub fn as_mut_ptr(&mut self) -> *mut zend_object
Returns a raw pointer wrapped.
Sourcepub unsafe fn as_state_obj<T>(&self) -> &StateObj<T>
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.
Sourcepub unsafe fn as_mut_state_obj<T>(&mut self) -> &mut StateObj<T>
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.
Sourcepub fn get_class(&self) -> &ClassEntry
pub fn get_class(&self) -> &ClassEntry
Get the class reference of object.
Sourcepub fn get_mut_class(&mut self) -> &mut ClassEntry
pub fn get_mut_class(&mut self) -> &mut ClassEntry
Get the mutable class reference of object.
Sourcepub fn get_property(&self, name: impl AsRef<str>) -> &ZVal
pub fn get_property(&self, name: impl AsRef<str>) -> &ZVal
Get the property by name of object.
Sourcepub fn get_mut_property(&mut self, name: impl AsRef<str>) -> &mut ZVal
pub fn get_mut_property(&mut self, name: impl AsRef<str>) -> &mut ZVal
Get the mutable property by name of object.
Sourcepub fn set_property(&mut self, name: impl AsRef<str>, val: impl Into<ZVal>)
pub fn set_property(&mut self, name: impl AsRef<str>, val: impl Into<ZVal>)
Set the property by name of object.
Sourcepub fn call(
&mut self,
method_name: &str,
arguments: impl AsMut<[ZVal]>,
) -> Result<ZVal>
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§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more