Skip to main content

ClassMetadata

Struct ClassMetadata 

Source
pub struct ClassMetadata<T: 'static> { /* private fields */ }
Expand description

Stores the class entry, handlers, and property descriptors for a Rust type which has been exported to PHP. Usually allocated statically.

Implementations§

Source§

impl<T: 'static> ClassMetadata<T>

Source

pub const fn new(field_properties: &'static [PropertyDescriptor<T>]) -> Self

Creates a new class metadata instance with the given field properties.

Source§

impl<T: RegisteredClass> ClassMetadata<T>

Source

pub fn handlers(&self) -> &ZendObjectHandlers

Returns an immutable reference to the object handlers contained inside the class metadata.

Source

pub fn has_ce(&self) -> bool

Checks if the class entry has been stored, returning a boolean.

Source

pub fn ce(&self) -> &'static ClassEntry

Retrieves a reference to the stored class entry.

§Panics

Panics if there is no class entry stored inside the class metadata.

Source

pub fn set_ce(&self, ce: &'static mut ClassEntry)

Stores a reference to a class entry inside the class metadata.

§Panics

Panics if the class entry has already been set in the class metadata. This function should only be called once.

Source

pub fn find_property(&self, name: &str) -> Option<&PropertyDescriptor<T>>

Finds a property descriptor by name.

Checks field properties first, then method properties. Linear scan is used since typical PHP classes have few properties and cache locality beats hashing at small N.

Source

pub fn field_properties(&self) -> &'static [PropertyDescriptor<T>]

Returns the field properties (from #[php(prop)] struct fields).

Source

pub fn method_properties(&self) -> &'static [PropertyDescriptor<T>]

Returns the method properties (from #[php(getter)]/#[php(setter)]). Lazily initialized on first access from RegisteredClass::method_properties().

Source

pub fn all_properties(&self) -> impl Iterator<Item = &PropertyDescriptor<T>>

Iterates over all properties (field + method).

Trait Implementations§

Source§

impl<T: 'static> Default for ClassMetadata<T>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<T> !Freeze for ClassMetadata<T>

§

impl<T> RefUnwindSafe for ClassMetadata<T>

§

impl<T> Send for ClassMetadata<T>

§

impl<T> Sync for ClassMetadata<T>

§

impl<T> Unpin for ClassMetadata<T>

§

impl<T> UnsafeUnpin for ClassMetadata<T>

§

impl<T> UnwindSafe for ClassMetadata<T>
where T: RefUnwindSafe,

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