pub struct Script {/* private fields */ }Expand description
ECMAScript’sScript Record.
Implementations§
Source§implScript
implScript
Sourcepub fnhost_defined(&self) -> &HostDefined
pub fnhost_defined(&self) -> &HostDefined
Returns theECMAScript specification defined\[\[HostDefined\]\] field of theModule.
Sourcepub fnparse<R:ReadChar>( src:Source<'_, R>, realm:Option<Realm>, context: &mutContext,) ->JsResult<Self>
pub fnparse<R:ReadChar>( src:Source<'_, R>, realm:Option<Realm>, context: &mutContext,) ->JsResult<Self>
Abstract operationParseScript ( sourceText, realm, hostDefined ).
Parses the providedsrc as an ECMAScript script, returning an error if parsing fails.
Sourcepub fncodeblock(&self, context: &mutContext) ->JsResult<Gc<CodeBlock>>
pub fncodeblock(&self, context: &mutContext) ->JsResult<Gc<CodeBlock>>
Compiles the codeblock of this script.
This is a no-op if this has been called previously.
Sourcepub fnevaluate(&self, context: &mutContext) ->JsResult<JsValue>
pub fnevaluate(&self, context: &mutContext) ->JsResult<JsValue>
Evaluates this script and returns its result.
Note that this won’t run any scheduled promise jobs; you need to callContext::run_jobson the context orJobExecutor::run_jobs on the provided queue to run them.
Sourcepub async fnevaluate_async(&self, context: &mutContext) ->JsResult<JsValue>
pub async fnevaluate_async(&self, context: &mutContext) ->JsResult<JsValue>
Evaluates this script and returns its result, periodically yielding to the executorin order to avoid blocking the current thread.
This uses an implementation defined amount of “clock cycles” that need to pass beforeexecution is suspended. SeeScript::evaluate_async_with_budget if you want to alsocustomize this parameter.
Sourcepub async fnevaluate_async_with_budget( &self, context: &mutContext, budget:u32,) ->JsResult<JsValue>
pub async fnevaluate_async_with_budget( &self, context: &mutContext, budget:u32,) ->JsResult<JsValue>
Evaluates this script and returns its result, yielding to the executor each timebudgetnumber of “clock cycles” pass.
Note that “clock cycle” is in quotation marks because we can’t determine exactly how manyCPU clock cycles a VM instruction will take, but all instructions have a “cost” associatedwith them that depends on their individual complexity. We’d recommend benchmarking withdifferent budget sizes in order to find the ideal yielding time for your application.
Trait Implementations§
Source§implTrace forScript
implTrace forScript
Source§unsafe fntrace_non_roots(&self)
unsafe fntrace_non_roots(&self)
Source§fnrun_finalizer(&self)
fnrun_finalizer(&self)
Finalize::finalize on this object and allcontained subobjects.Auto Trait Implementations§
implFreeze forScript
impl !RefUnwindSafe forScript
impl !Send forScript
impl !Sync forScript
implUnpin forScript
impl !UnwindSafe forScript
Blanket Implementations§
Source§impl<T>BorrowMut<T> for Twhere T: ?Sized,
impl<T>BorrowMut<T> for Twhere T: ?Sized,
Source§fnborrow_mut(&mut self) ->&mut T
fnborrow_mut(&mut self) ->&mut T
Source§impl<T>CloneToUninit for Twhere T:Clone,
impl<T>CloneToUninit for Twhere T:Clone,
Source§impl<T>IntoEither for T
impl<T>IntoEither for T
Source§fninto_either(self, into_left:bool) ->Either<Self, Self>
fninto_either(self, into_left:bool) ->Either<Self, Self>
self into aLeft variant ofEither<Self, Self>ifinto_left istrue.Convertsself into aRight variant ofEither<Self, Self>otherwise.Read moreSource§fninto_either_with<F>(self, into_left: F) ->Either<Self, Self>
fninto_either_with<F>(self, into_left: F) ->Either<Self, Self>
self into aLeft variant ofEither<Self, Self>ifinto_left(&self) returnstrue.Convertsself into aRight variant ofEither<Self, Self>otherwise.Read moreSource§impl<T>Pipe for Twhere T: ?Sized,
impl<T>Pipe for Twhere T: ?Sized,
Source§fnpipe<R>(self, func: implFnOnce(Self) -> R) -> Rwhere Self:Sized,
fnpipe<R>(self, func: implFnOnce(Self) -> R) -> Rwhere Self:Sized,
Source§fnpipe_ref<'a, R>(&'a self, func: implFnOnce(&'a Self) -> R) -> Rwhere R: 'a,
fnpipe_ref<'a, R>(&'a self, func: implFnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function.Read moreSource§fnpipe_ref_mut<'a, R>(&'a mut self, func: implFnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
fnpipe_ref_mut<'a, R>(&'a mut self, func: implFnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function.Read moreSource§fnpipe_borrow<'a, B, R>(&'a self, func: implFnOnce(&'a B) -> R) -> R
fnpipe_borrow<'a, B, R>(&'a self, func: implFnOnce(&'a B) -> R) -> R
Source§fnpipe_borrow_mut<'a, B, R>( &'a mut self, func: implFnOnce(&'a mut B) -> R,) -> R
fnpipe_borrow_mut<'a, B, R>( &'a mut self, func: implFnOnce(&'a mut B) -> R,) -> R
Source§fnpipe_as_ref<'a, U, R>(&'a self, func: implFnOnce(&'a U) -> R) -> R
fnpipe_as_ref<'a, U, R>(&'a self, func: implFnOnce(&'a U) -> R) -> R
self, then passesself.as_ref() into the pipe function.Source§fnpipe_as_mut<'a, U, R>(&'a mut self, func: implFnOnce(&'a mut U) -> R) -> R
fnpipe_as_mut<'a, U, R>(&'a mut self, func: implFnOnce(&'a mut U) -> R) -> R
self, then passesself.as_mut() into the pipefunction.Source§fnpipe_deref<'a, T, R>(&'a self, func: implFnOnce(&'a T) -> R) -> R
fnpipe_deref<'a, T, R>(&'a self, func: implFnOnce(&'a T) -> R) -> R
self, then passesself.deref() into the pipe function.Source§impl<T>Tap for T
impl<T>Tap for T
Source§fntap_borrow<B>(self, func: implFnOnce(&B)) -> Self
fntap_borrow<B>(self, func: implFnOnce(&B)) -> Self
Borrow<B> of a value.Read moreSource§fntap_borrow_mut<B>(self, func: implFnOnce(&mut B)) -> Self
fntap_borrow_mut<B>(self, func: implFnOnce(&mut B)) -> Self
BorrowMut<B> of a value.Read moreSource§fntap_ref<R>(self, func: implFnOnce(&R)) -> Self
fntap_ref<R>(self, func: implFnOnce(&R)) -> Self
AsRef<R> view of a value.Read moreSource§fntap_ref_mut<R>(self, func: implFnOnce(&mut R)) -> Self
fntap_ref_mut<R>(self, func: implFnOnce(&mut R)) -> Self
AsMut<R> view of a value.Read moreSource§fntap_deref<T>(self, func: implFnOnce(&T)) -> Self
fntap_deref<T>(self, func: implFnOnce(&T)) -> Self
Deref::Target of a value.Read moreSource§fntap_deref_mut<T>(self, func: implFnOnce(&mut T)) -> Self
fntap_deref_mut<T>(self, func: implFnOnce(&mut T)) -> Self
Deref::Target of a value.Read moreSource§fntap_dbg(self, func: implFnOnce(&Self)) -> Self
fntap_dbg(self, func: implFnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fntap_mut_dbg(self, func: implFnOnce(&mut Self)) -> Self
fntap_mut_dbg(self, func: implFnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in releasebuilds.Source§fntap_borrow_dbg<B>(self, func: implFnOnce(&B)) -> Self
fntap_borrow_dbg<B>(self, func: implFnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in releasebuilds.Source§fntap_borrow_mut_dbg<B>(self, func: implFnOnce(&mut B)) -> Self
fntap_borrow_mut_dbg<B>(self, func: implFnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in releasebuilds.Source§fntap_ref_dbg<R>(self, func: implFnOnce(&R)) -> Self
fntap_ref_dbg<R>(self, func: implFnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in releasebuilds.Source§fntap_ref_mut_dbg<R>(self, func: implFnOnce(&mut R)) -> Self
fntap_ref_mut_dbg<R>(self, func: implFnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in releasebuilds.Source§fntap_deref_dbg<T>(self, func: implFnOnce(&T)) -> Self
fntap_deref_dbg<T>(self, func: implFnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in releasebuilds.