Trait ext_php_rs::rc::PhpRc

source ·
pub trait PhpRc {
    fn get_rc(&self) -> &ZendRefcount;
    fn get_rc_mut(&mut self) -> &mut ZendRefcount;

    fn get_count(&self) -> u32 { ... }
    fn inc_count(&mut self) { ... }
    fn dec_count(&mut self) { ... }
}
Expand description

Implemented on refcounted types.

Required Methods§

Returns an immutable reference to the corresponding refcount object.

Returns a mutable reference to the corresponding refcount object.

Provided Methods§

Returns the number of references to the object.

Increments the reference counter by 1.

Examples found in repository?
src/types/zval.rs (line 450)
448
449
450
451
452
    pub fn set_object(&mut self, val: &mut ZendObject) {
        self.change_type(ZvalTypeFlags::ObjectEx);
        val.inc_count(); // TODO(david): not sure if this is needed :/
        self.value.obj = (val as *const ZendObject) as *mut ZendObject;
    }

Decrements the reference counter by 1.

Examples found in repository?
src/types/object.rs (line 309)
305
306
307
308
309
310
311
312
    fn set_zval(mut self, zv: &mut Zval, _: bool) -> Result<()> {
        // We must decrement the refcounter on the object before inserting into the
        // zval, as the reference counter will be incremented on add.
        // NOTE(david): again is this needed, we increment in `set_object`.
        self.dec_count();
        zv.set_object(self.into_raw());
        Ok(())
    }

Implementors§