Skip to main content

ZendClassObject

Struct ZendClassObject 

Source
pub struct ZendClassObject<T> {
    pub std: ZendObject,
    /* private fields */
}
Expand description

Representation of a Zend class object in memory.

Fields§

§std: ZendObject

The standard zend object.

Implementations§

Source§

impl<T: RegisteredClass> ZendClassObject<T>

Source

pub fn new(val: T) -> ZBox<Self>

Creates a new ZendClassObject of type T, where T is a RegisteredClass in PHP, storing the given value val inside the object.

§Parameters
  • val - The value to store inside the object.
§Panics

Panics if memory was unable to be allocated for the new object.

Source

pub fn new_uninit(ce: Option<&'static ClassEntry>) -> ZBox<Self>

Creates a new ZendClassObject of type T, with an uninitialized internal object.

Until initialize is called, try_borrow and try_borrow_mut return BorrowError::Uninitialized and the Clone implementation panics.

§Panics

Panics if memory was unable to be allocated for the new object.

Source

pub fn initialize(&self, val: T) -> Result<Option<T>, BorrowError>

Initializes the class object with the value val.

§Parameters
  • val - The value to initialize the object with.
§Returns

Returns the old value in an Option if the object had already been initialized, None otherwise.

§Errors
Source

pub fn try_borrow(&self) -> Result<ClassRef<'_, T>, BorrowError>

Borrows the Rust value of the object.

§Errors
Source

pub fn try_borrow_mut(&self) -> Result<ClassRefMut<'_, T>, BorrowError>

Borrows the Rust value of the object mutably.

§Errors
Source

pub fn from_zend_obj(std: &zend_object) -> Option<&Self>

Returns a reference to the ZendClassObject of a given zend object obj. Returns None if the given object is not of the type T.

§Parameters
§Panics
  • If the std offset over/underflows isize.
Source

pub fn get_mut_zend_obj(&mut self) -> &mut zend_object

Returns a mutable reference to the underlying Zend object.

Trait Implementations§

Source§

impl<T: Debug> Debug for ZendClassObject<T>

Source§

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

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

impl<'a, T: RegisteredClass> FromZendObject<'a> for &'a ZendClassObject<T>

Source§

fn from_zend_object(obj: &'a ZendObject) -> Result<Self>

Extracts Self from the source ZendObject. Read more
Source§

impl<'a, T: RegisteredClass> FromZval<'a> for &'a ZendClassObject<T>

Source§

const TYPE: DataType

The corresponding type of the implemented value in PHP.
Source§

fn from_zval(zval: &'a Zval) -> Option<Self>

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

const NULLABLE: bool = false

Whether a PHP argument of this type accepts null and may be omitted. Read more
Source§

fn from_missing() -> Option<Self>

The value to use when a PHP argument of this type was omitted by the caller. None means the argument is required. Read more
Source§

fn try_from_zval(zval: &'a Zval) -> Result<Self>

Attempts to retrieve an instance of Self from a reference to a Zval, and tells why it failed. Read more
Source§

impl<T: RegisteredClass> IntoZval for &ZendClassObject<T>

Source§

const TYPE: DataType

The corresponding type of the implemented value in PHP.
Source§

const NULLABLE: bool = false

Whether converting into a Zval may result in null.
Source§

fn set_zval(self, zv: &mut Zval, _: bool) -> Result<()>

Sets the content of a pre-existing zval. Returns a result containing nothing if setting the content was successful. Read more
Source§

fn into_zval(self, persistent: bool) -> Result<Zval>

Converts a Rust primitive type into a Zval. Returns a result containing the Zval if successful. Read more
Source§

impl<T: RegisteredClass> ZBoxable for ZendClassObject<T>

Source§

fn free(&mut self)

Frees the memory pointed to by self, calling any destructors required in the process.

Auto Trait Implementations§

§

impl<T> !Freeze for ZendClassObject<T>

§

impl<T> !RefUnwindSafe for ZendClassObject<T>

§

impl<T> !Send for ZendClassObject<T>

§

impl<T> !Sync for ZendClassObject<T>

§

impl<T> Forget for ZendClassObject<T>

§

impl<T> Move for ZendClassObject<T>

§

impl<T> Unpin for ZendClassObject<T>

§

impl<T> UnsafeUnpin for ZendClassObject<T>

§

impl<T> UnwindSafe for ZendClassObject<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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.