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<Function<'js>, Error> where
F: 'static + AsFunction<'js, A, R> + ParallelSend,
sourcepub fn set_name<S>(&self, name: S) -> Result<(), Error> where
S: AsRef<str>,
pub fn set_name<S>(&self, name: S) -> Result<(), Error> where
S: AsRef<str>,
Set the name
property
sourcepub fn call<A, R>(&self, args: A) -> Result<R, Error> where
A: AsArguments<'js>,
R: FromJs<'js>,
pub fn call<A, R>(&self, args: A) -> Result<R, Error> 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 defer_call<A>(&self, args: A) -> Result<(), Error> where
A: AsArguments<'js>,
pub fn defer_call<A>(&self, args: A) -> Result<(), Error> 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>, Error>
pub fn get_prototype(&self) -> Result<Object<'js>, Error>
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
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
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<'js, T> AsProperty<'js, T> for T where
T: IntoJs<'js>,
impl<'js, T> AsProperty<'js, T> for T where
T: IntoJs<'js>,
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more