script::dom::bindings::import::base

Type Alias Heap

Source
pub(crate) type Heap<T> = Heap<T>;

Aliased Type§

struct Heap<T> {
    pub ptr: UnsafeCell<T>,
}

Fields§

§ptr: UnsafeCell<T>

Implementations

Source§

impl<T> Heap<T>
where T: GCMethods + Copy,

Source

pub fn boxed(v: T) -> Box<Heap<T>>
where Heap<T>: Default,

This creates a Box-wrapped Heap value. Setting a value inside Heap object triggers a barrier, referring to the Heap object location, hence why it is not safe to construct a temporary Heap value, assign a non-null value and move it (e.g. typical object construction).

Using boxed Heap value guarantees that the underlying Heap value will not be moved when constructed.

Source

pub fn set(&self, v: T)

Source

pub fn get(&self) -> T

Source

pub fn get_unsafe(&self) -> *mut T

Source

pub unsafe fn handle(&self) -> Handle<T>

Retrieves a Handle to the underlying value.

§Safety

This is only safe to do on a rooted object (which Heap is not, it needs to be additionally rooted), like RootedGuard, so use this only if you know what you’re doing.

§Notes

Since Heap values need to be informed when a change to underlying value is made (e.g. via get()), this does not allow to create MutableHandle objects, which can bypass this and lead to crashes.

Trait Implementations

Source§

impl<T> Debug for Heap<T>
where T: Debug + GCMethods + Copy,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Heap<*mut T>

Source§

fn default() -> Heap<*mut T>

Returns the “default value” for a type. Read more
Source§

impl Default for Heap<Value>

Source§

fn default() -> Heap<Value>

Returns the “default value” for a type. Read more
Source§

impl<T> Drop for Heap<T>
where T: GCMethods + Copy,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> PartialEq for Heap<T>
where T: GCMethods + Copy + PartialEq,

Source§

fn eq(&self, other: &Heap<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl ToJSValConvertible for Heap<*mut JSObject>

Source§

unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandle<'_, Value>)

Convert self to a JSVal. JSAPI failure causes a panic.
Source§

impl ToJSValConvertible for Heap<Value>

Source§

unsafe fn to_jsval(&self, cx: *mut JSContext, rval: MutableHandle<'_, Value>)

Convert self to a JSVal. JSAPI failure causes a panic.
Source§

impl Traceable for Heap<*mut BigInt>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<*mut JSFunction>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<*mut JSObject>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<*mut JSScript>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<*mut JSString>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<*mut Symbol>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<PropertyKey>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.
Source§

impl Traceable for Heap<Value>

Source§

unsafe fn trace(&self, trc: *mut JSTracer)

Trace self.