Macro ext_php_rs::class_derives 
source · macro_rules! class_derives { ($type: ty) => { ... }; }
Expand description
Implements a set of traits required to convert types that implement
RegisteredClass to and from ZendObjects and Zvals. Generally,
this macro should not be called directly, as it is called on any type that
uses the php_class macro.
The following traits are implemented:
FromZendObject for &'a TFromZendObjectMut for &'a mut TFromZval for &'a TFromZvalMut for &'a mut TIntoZendObject for TIntoZval for T
These implementations are required while we wait on the stabilisation of specialisation.
Examples
use ext_php_rs::class_derives;
struct Test {
    a: i32,
    b: i64
}
impl RegisteredClass for Test {
    const CLASS_NAME: &'static str = "Test";
    const CONSTRUCTOR: Option<ext_php_rs::class::ConstructorMeta<Self>> = None;
    fn get_metadata() -> &'static ext_php_rs::class::ClassMetadata<Self> {
        todo!()
    }
    fn get_properties<'a>(
    ) -> std::collections::HashMap<&'static str, ext_php_rs::props::Property<'a, Self>>
    {
        todo!()
    }
}
class_derives!(Test);
fn into_zval_test() -> Zval {
    let x = Test { a: 5, b: 10 };
    x.into_zval(false).unwrap()
}
fn from_zval_test<'a>(zv: &'a Zval) -> &'a Test {
    <&Test>::from_zval(zv).unwrap()
}