#[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, can_gc: CanGc) -> Rc<Promise>
pub fn new_in_current_realm(_comp: InRealm<'_>, can_gc: CanGc) -> 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<'_>, _can_gc: CanGc, )
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 is_rejected(&self) -> bool
pub fn is_pending(&self) -> bool
pub fn promise_obj(&self) -> HandleObject<'_>
pub fn append_native_handler( &self, handler: &PromiseNativeHandler, _comp: InRealm<'_>, can_gc: CanGc, )
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§impl PartialEq for Promise
impl PartialEq for Promise
source§impl ToJSValConvertible for Promise
impl ToJSValConvertible for Promise
impl Eq for Promise
Auto Trait Implementations§
impl !Freeze for Promise
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
Creates a filterable data provider with the given name for debugging. Read more
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> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> MaybeBoxed<Box<T>> for T
impl<T> MaybeBoxed<Box<T>> for T
source§fn maybe_boxed(self) -> Box<T>
fn maybe_boxed(self) -> Box<T>
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