Trait com::production::Class[][src]

pub unsafe trait Class {
    type Factory;
    unsafe fn dec_ref_count(&self) -> u32;
unsafe fn add_ref(&self) -> u32; }
Expand description

A COM compliant class

Safety

The implementing struct must have the following properties:

  • it is #[repr(C)]
  • The first fields of the struct are pointers to the backing VTables for each of the COM Interfaces the class implements

Associated Types

The factory object associated with this class

Required methods

Decrement the current reference count and return the new count

Safety

Because the caller is directly modifying the reference count of an object, and reference counts are used to determine object lifetime, the caller is responsible for ensuring that the object is destroyed if dec_ref_count reaches zero. All such adjustments to the reference count can only be used by unsafe code, because this method has a side effect (modifies the reference count) but this side effect is not represented in Rust’s type system (no refcount-holding object is destroyed).

This method should only be called in Drop implementations, or similar functions that terminate the lifetime of a reference-holding type.

Increment the current reference count and return the new count

Safety

Because the caller is directly modifying the reference count of an object, and reference counts are used to determine object lifetime, the caller is responsible for ensuring that the newly-created reference is correctly encapsulated within a Rust object. All such adjustments to the reference count can only be used by unsafe code, because this method has a side effect (modifies the reference count) but this side effect is not represented in Rust’s type system (no refcount-holding object is destroyed).

This method should only be called in type constructors, Clone implementations, IUnknown::query_interface() implementations, or similar code paths that create a new instance of a Rust type that holds the counted reference.

Implementors