pub trait FromZendObject<'a>: Sized {
// Required method
fn from_zend_object(obj: &'a ZendObject) -> Result<Self>;
}Expand description
FromZendObject is implemented by types which can be extracted from a Zend
object.
Normal usage is through the helper method ZendObject::extract:
ⓘ
let obj: ZendObject = ...;
let repr: String = obj.extract();
let props: HashMap = obj.extract();Should be functionally equivalent to casting an object to another compatible type.
Required Methods§
Sourcefn from_zend_object(obj: &'a ZendObject) -> Result<Self>
fn from_zend_object(obj: &'a ZendObject) -> Result<Self>
Extracts Self from the source ZendObject.
§Errors
Error::ZvalConversion- If the object is not of the expected class.Error::InvalidProperty- If a property the conversion needs is missing.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl FromZendObject<'_> for String
impl FromZendObject<'_> for String
Source§fn from_zend_object(obj: &ZendObject) -> Result<Self>
fn from_zend_object(obj: &ZendObject) -> Result<Self>
Converts the object into a string by calling its __toString() method.
§Errors
Error::InvalidPointer- If the object has no class entry.Error::NotStringable- If the class does not implement__toString().Error::ExceptionPending- If__toString()threw an exception.Error::ZvalConversion- If__toString()did not return a string.
Implementors§
impl<'a, T: RegisteredClass> FromZendObject<'a> for &'a ZendClassObject<T>
impl<'a> FromZendObject<'a> for &'a Closure
Available on crate feature
closure only.impl<T> FromZendObject<'_> for Twhere
T: RegisteredEnum,
Available on crate feature
enum only.