Struct script::test::TrustedPromise
source · pub struct TrustedPromise {
dom_object: *const Promise,
owner_thread: *const c_void,
}
Expand description
A safe wrapper around a DOM Promise object that can be shared among threads for use
in asynchronous operations. The underlying DOM object is guaranteed to live at least
as long as the last outstanding TrustedPromise
instance. These values cannot be cloned,
only created from existing Rc<Promise>
values.
Fields§
§dom_object: *const Promise
§owner_thread: *const c_void
Implementations§
source§impl TrustedPromise
impl TrustedPromise
sourcepub fn new(promise: Rc<Promise>) -> TrustedPromise
pub fn new(promise: Rc<Promise>) -> TrustedPromise
Create a new TrustedPromise
instance from an existing DOM object. The object will
be prevented from being GCed for the duration of the resulting TrustedPromise
object’s
lifetime.
sourcepub fn root(self) -> Rc<Promise>
pub fn root(self) -> Rc<Promise>
Obtain a usable DOM Promise from a pinned TrustedPromise
value. Fails if used on
a different thread than the original value from which this TrustedPromise
was
obtained.
sourcepub fn reject_task(self, error: Error) -> impl TaskOnce
pub fn reject_task(self, error: Error) -> impl TaskOnce
A task which will reject the promise.
sourcepub fn resolve_task<T>(self, value: T) -> impl TaskOncewhere
T: ToJSValConvertible + Send,
pub fn resolve_task<T>(self, value: T) -> impl TaskOncewhere
T: ToJSValConvertible + Send,
A task which will resolve the promise.
Trait Implementations§
impl Send for TrustedPromise
Auto Trait Implementations§
impl Freeze for TrustedPromise
impl !RefUnwindSafe for TrustedPromise
impl !Sync for TrustedPromise
impl Unpin for TrustedPromise
impl !UnwindSafe for TrustedPromise
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<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