#[repr(C)]pub struct Promise {
reflector: Reflector,
permanent_js_root: Heap<JSVal>,
}
Fields§
§reflector: Reflector
§permanent_js_root: Heap<JSVal>
Since Promise values are natively reference counted without the knowledge of the SpiderMonkey GC, an explicit root for the reflector is stored while any native instance exists. This ensures that the reflector will never be GCed while native code could still interact with its native representation.
Implementations§
source§impl Promise
impl Promise
pub fn new(global: &GlobalScope) -> Rc<Promise>
pub fn new_in_current_realm(_comp: InRealm<'_>) -> Rc<Promise>
pub fn duplicate(&self) -> Rc<Promise>
pub fn new_with_js_promise(
obj: HandleObject<'_>,
cx: SafeJSContext
) -> Rc<Promise>
fn create_js_promise(cx: SafeJSContext, obj: MutableHandleObject<'_>)
pub fn new_resolved(
global: &GlobalScope,
cx: SafeJSContext,
value: HandleValue<'_>
) -> Result<Rc<Promise>, Error>
pub fn new_rejected(
global: &GlobalScope,
cx: SafeJSContext,
value: HandleValue<'_>
) -> Result<Rc<Promise>, Error>
pub fn resolve_native<T>(&self, val: &T)where
T: ToJSValConvertible,
pub fn resolve(&self, cx: SafeJSContext, value: HandleValue<'_>)
pub fn reject_native<T>(&self, val: &T)where
T: ToJSValConvertible,
pub fn reject_error(&self, error: Error)
pub fn reject(&self, cx: SafeJSContext, value: HandleValue<'_>)
pub fn is_fulfilled(&self) -> bool
pub fn promise_obj(&self) -> HandleObject<'_>
pub fn append_native_handler(
&self,
handler: &PromiseNativeHandler,
_comp: InRealm<'_>
)
Trait Implementations§
source§impl MallocSizeOf for Promise
impl MallocSizeOf for Promise
source§fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
source§impl MutDomObject for Promise
impl MutDomObject for Promise
source§unsafe fn init_reflector(&self, obj: *mut JSObject)
unsafe fn init_reflector(&self, obj: *mut JSObject)
Initializes the Reflector
source§impl ToJSValConvertible for Promise
impl ToJSValConvertible for Promise
Auto Trait Implementations§
impl !RefUnwindSafe for Promise
impl !Send for Promise
impl !Sync for Promise
impl Unpin for Promise
impl UnwindSafe for Promise
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> MaybeBoxed<Box<T, Global>> for T
impl<T> MaybeBoxed<Box<T, Global>> for T
source§fn maybe_boxed(self) -> Box<T, Global>
fn maybe_boxed(self) -> Box<T, Global>
Convert
source§impl<T> MaybeBoxed<T> for T
impl<T> MaybeBoxed<T> for T
source§fn maybe_boxed(self) -> T
fn maybe_boxed(self) -> T
Convert