Struct rquickjs_core::Function
source · [−]pub struct Function<'js>(_);
Expand description
Rust representation of a javascript function.
Implementations
sourceimpl<'js> Function<'js>
impl<'js> Function<'js>
pub fn new<F, A, R>(ctx: Ctx<'js>, func: F) -> Result<Self> where
F: AsFunction<'js, A, R> + ParallelSend + 'static,
sourcepub fn set_length(&self, len: usize) -> Result<()>
pub fn set_length(&self, len: usize) -> Result<()>
Set the length
property
sourcepub fn call<A, R>(&self, args: A) -> Result<R> where
A: AsArguments<'js>,
R: FromJs<'js>,
pub fn call<A, R>(&self, args: A) -> Result<R> where
A: AsArguments<'js>,
R: FromJs<'js>,
Call a function with given arguments
You can use tuples to pass arguments. The ()
treated as no arguments, the (arg,)
as a single argument and so on.
To call function on a given this
you can pass This(this)
as a first argument.
By default an undefined
will be passed as this
.
sourcepub fn construct<A, R>(&self, args: A) -> Result<R> where
A: AsArguments<'js>,
R: FromJs<'js>,
pub fn construct<A, R>(&self, args: A) -> Result<R> where
A: AsArguments<'js>,
R: FromJs<'js>,
Call a constructor with given arguments
You can use tuples to pass arguments. The ()
treated as no arguments, the (arg,)
as a single argument and so on.
To call constructor on a given this
you can pass This(this)
as a first argument.
sourcepub fn defer_call<A>(&self, args: A) -> Result<()> where
A: AsArguments<'js>,
pub fn defer_call<A>(&self, args: A) -> Result<()> where
A: AsArguments<'js>,
Deferred call a function with given arguments
You can use tuples to pass arguments. The ()
treated as no arguments, the (arg,)
as a single argument and so on.
To call function on a given this
you can pass This(this)
as a first argument.
By default an undefined
will be passed as this
.
sourcepub fn is_constructor(&self) -> bool
pub fn is_constructor(&self) -> bool
Check that function is a constructor
sourcepub fn set_constructor(&self, flag: bool)
pub fn set_constructor(&self, flag: bool)
Mark the function as a constructor
sourcepub fn set_prototype(&self, proto: &Object<'js>)
pub fn set_prototype(&self, proto: &Object<'js>)
Set a function prototype
Actually this method does the following:
func.prototype = proto;
proto.constructor = func;
sourcepub fn get_prototype(&self) -> Result<Object<'js>>
pub fn get_prototype(&self) -> Result<Object<'js>>
Get a function prototype
Actually this method returns the func.prototype
.
sourcepub fn into_object(self) -> Object<'js>
pub fn into_object(self) -> Object<'js>
Convert into an object
sourcepub fn from_object(object: Object<'js>) -> Result<Self>
pub fn from_object(object: Object<'js>) -> Result<Self>
Convert from an object
Methods from Deref<Target = Value<'js>>
sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if the value is a function
sourcepub unsafe fn ref_string(&self) -> &String<'js>
pub unsafe fn ref_string(&self) -> &String<'js>
sourcepub unsafe fn ref_symbol(&self) -> &Symbol<'js>
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
sourcepub unsafe fn ref_object(&self) -> &Object<'js>
pub unsafe fn ref_object(&self) -> &Object<'js>
sourcepub unsafe fn ref_function(&self) -> &Function<'js>
pub unsafe fn ref_function(&self) -> &Function<'js>
sourcepub fn as_function(&self) -> Option<&Function<'js>>
pub fn as_function(&self) -> Option<&Function<'js>>
Try reinterprete as
Trait Implementations
sourceimpl<'js> PartialEq<Function<'js>> for Function<'js>
impl<'js> PartialEq<Function<'js>> for Function<'js>
impl<'js> StructuralPartialEq for Function<'js>
Auto Trait Implementations
impl<'js> !RefUnwindSafe for Function<'js>
impl<'js> !Send for Function<'js>
impl<'js> !Sync for Function<'js>
impl<'js> Unpin for Function<'js>
impl<'js> UnwindSafe for Function<'js>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more