Struct rquickjs_core::Function [−][src]
Rust representation of a javascript function.
Implementations
impl<'js> Function<'js>
[src]
pub fn new<F, A, R>(ctx: Ctx<'js>, func: F) -> Result<Self> where
F: AsFunction<'js, A, R> + ParallelSend + 'static,
[src]
F: AsFunction<'js, A, R> + ParallelSend + 'static,
pub fn set_length(&self, len: usize) -> Result<()>
[src]
Set the length
property
pub fn set_name<S: AsRef<str>>(&self, name: S) -> Result<()>
[src]
Set the name
property
pub fn call<A, R>(&self, args: A) -> Result<R> where
A: AsArguments<'js>,
R: FromJs<'js>,
[src]
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
.
pub fn defer_call<A>(&self, args: A) -> Result<()> where
A: AsArguments<'js>,
[src]
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
.
pub fn is_constructor(&self) -> bool
[src]
Check that function is a constructor
pub fn set_constructor(&self, flag: bool)
[src]
Mark the function as a constructor
pub fn set_prototype(&self, proto: &Object<'js>)
[src]
Set a function prototype
Actually this method does the following:
func.prototype = proto;
proto.constructor = func;
pub fn get_prototype(&self) -> Result<Object<'js>>
[src]
Get a function prototype
Actually this method returns the func.prototype
.
pub fn as_object(&self) -> &Object<'js>
[src]
Reference as an object
pub fn into_object(self) -> Object<'js>
[src]
Convert into an object
pub fn from_object(object: Object<'js>) -> Result<Self>
[src]
Convert from an object
impl<'js> Function<'js>
[src]
pub fn as_value(&self) -> &Value<'js>
[src]
Reference to value
pub fn into_value(self) -> Value<'js>
[src]
Convert into value
pub fn from_value(value: Value<'js>) -> Result<Self>
[src]
Convert from value
Methods from Deref<Target = Value<'js>>
pub fn as_bool(&self) -> Option<bool>
[src]
Try get bool from value
pub fn as_int(&self) -> Option<i32>
[src]
Try get int from value
pub fn as_float(&self) -> Option<f64>
[src]
Try get float from value
pub fn as_number(&self) -> Option<f64>
[src]
Try get any number from value
pub fn is_bool(&self) -> bool
[src]
Check if the value is a bool
pub fn is_int(&self) -> bool
[src]
Check if the value is an int
pub fn is_float(&self) -> bool
[src]
Check if the value is a float
pub fn is_number(&self) -> bool
[src]
Check if the value is an any number
pub fn is_string(&self) -> bool
[src]
Check if the value is a string
pub fn is_symbol(&self) -> bool
[src]
Check if the value is a symbol
pub fn is_object(&self) -> bool
[src]
Check if the value is an object
pub fn is_module(&self) -> bool
[src]
Check if the value is a module
pub fn is_array(&self) -> bool
[src]
Check if the value is an array
pub fn is_function(&self) -> bool
[src]
Check if the value is a function
pub fn is_error(&self) -> bool
[src]
Check if the value is an error
pub fn as_value(&self) -> &Self
[src]
Reference as value
pub fn get<T: FromJs<'js>>(&self) -> Result<T>
[src]
Convert from value to specified type
pub fn type_of(&self) -> Type
[src]
Get the type of value
pub fn type_name(&self) -> &'static str
[src]
Get the name of type
pub unsafe fn ref_string(&self) -> &String<'js>
[src]
pub fn as_string(&self) -> Option<&String<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_symbol(&self) -> &Symbol<'js>
[src]
pub fn as_symbol(&self) -> Option<&Symbol<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_object(&self) -> &Object<'js>
[src]
pub fn as_object(&self) -> Option<&Object<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_array(&self) -> &Array<'js>
[src]
pub fn as_array(&self) -> Option<&Array<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_function(&self) -> &Function<'js>
[src]
pub fn as_function(&self) -> Option<&Function<'js>>
[src]
Try reinterprete as
pub unsafe fn ref_module(&self) -> &Module<'js, Evaluated>
[src]
pub fn as_module(&self) -> Option<&Module<'js, Evaluated>>
[src]
Try reinterprete as
Trait Implementations
impl<'js> AsRef<Value<'js>> for Function<'js>
[src]
impl<'js> Clone for Function<'js>
[src]
impl<'js> Debug for Function<'js>
[src]
impl<'js> Deref for Function<'js>
[src]
type Target = Value<'js>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'js> From<Function<'js>> for Value<'js>
[src]
impl<'js> FromJs<'js> for Function<'js>
[src]
impl<'js> IntoAtom<'js> for Function<'js>
[src]
impl<'js> IntoJs<'js> for Function<'js>
[src]
impl<'js, 't> Outlive<'t> for Function<'js>
[src]
impl<'js> PartialEq<Function<'js>> for Function<'js>
[src]
impl<'js> StructuralPartialEq for Function<'js>
[src]
Auto Trait Implementations
impl<'js> !RefUnwindSafe for Function<'js>
[src]
impl<'js> !Send for Function<'js>
[src]
impl<'js> !Sync for Function<'js>
[src]
impl<'js> Unpin for Function<'js>
[src]
impl<'js> UnwindSafe for Function<'js>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,