pub unsafe trait CollectorId: Copy + Eq + Hash + Debug + NullTrace + TrustedDrop + 'static + for<'gc> GcSafe<'gc, Self> {
    type System: GcSystem<Id = Self, Context = Self::Context>;
    type Context: GcContext<System = Self::System, Id = Self>;
    type RawVec: GcRawVec<'gc, T, Id = Self>;
    type ArrayPtr: ~constGcArrayPtr<Id = Self>;
    fn from_gc_ptr<'a, 'gc, T>(gc: &'a Gc<'gc, T, Self>) -> &'a Self
    where
        T: ?Sized,
        'gc: 'a
;
fn resolve_array_id<'a, 'gc, T>(
        array: &'a GcArray<'gc, T, Self>
    ) -> &'a Self
    where
        'gc: 'a
;
fn resolve_array_len<T>(repr: &GcArray<'_, T, Self>) -> usize;
unsafe fn gc_write_barrier<'gc, O: GcSafe<'gc, Self> + ?Sized, V: GcSafe<'gc, Self> + ?Sized>(
        owner: &Gc<'gc, O, Self>,
        value: &Gc<'gc, V, Self>,
        field_offset: usize
    );
unsafe fn assume_valid_system(&self) -> &Self::System; }
Expand description

Uniquely identifies the collector in case there are multiple collectors.

Safety

To simply the typing, this contains no references to the lifetime of the associated GcSystem.

It’s implicitly held and is unsafe to access. As long as the collector is valid, this id should be too.

It should be safe to assume that a collector exists if any of its pointers still do!

Associated Types

The type of the garbage collector system

The type of GcContext associated with this id.

The implementation of GcRawVec for this type.

May be crate::vec::raw::Unsupported if vectors are unsupported.

The raw representation of GcArray pointers in this collector.

Required methods

Get the runtime id of the collector that allocated the Gc

Assumes that T: GcSafe<'gc, Self>, although that can’t be proven at compile time.

Resolve the CollectorId for the specified GcArray’s representation.

This is the GcArray counterpart of from_gc_ptr

Resolve the length of the specified array

Perform a write barrier before writing to a garbage collected field

Safety

Similar to the GcDirectBarrier trait, it can be assumed that the field offset is correct and the types match.

Assume the ID is valid and use it to access the GcSystem

NOTE: The system is bound to the lifetime of THIS id. A CollectorId may have an internal pointer to the system and the pointer may not have a stable address. In other words, it may be difficult to reliably take a pointer to a pointer.

Safety

Undefined behavior if the associated collector no longer exists.

Implementors