Struct neon::handle::Handle[][src]

#[repr(C)]
pub struct Handle<'a, T: Managed + 'a> { /* fields omitted */ }
Expand description

A handle to a JavaScript value that is owned by the JavaScript engine.

Implementations

impl<'a, T: Value> Handle<'a, T>[src]

pub fn upcast<U: Value + SuperType<T>>(&self) -> Handle<'a, U>[src]

Safely upcast a handle to a supertype.

This method does not require an execution context because it only copies a handle.

pub fn is_a<'b, U: Value, C: Context<'b>>(&self, cx: &mut C) -> bool[src]

Tests whether this value is an instance of the given type.

Example:

let v: Handle<JsValue> = cx.number(17).upcast();
v.is_a::<JsString, _>(&mut cx); // false
v.is_a::<JsNumber, _>(&mut cx); // true
v.is_a::<JsValue, _>(&mut cx);  // true

pub fn downcast<'b, U: Value, C: Context<'b>>(
    &self,
    cx: &mut C
) -> DowncastResult<'a, T, U>
[src]

Attempts to downcast a handle to another type, which may fail. A failure to downcast does not throw a JavaScript exception, so it’s OK to continue interacting with the JS engine if this method produces an Err result.

pub fn downcast_or_throw<'b, U: Value, C: Context<'b>>(
    &self,
    cx: &mut C
) -> JsResult<'a, U>
[src]

Attempts to downcast a handle to another type, raising a JavaScript TypeError exception on failure. This method is a convenient shorthand, equivalent to self.downcast::<U>().or_throw::<C>(cx).

pub fn strict_equals<'b, U: Value, C: Context<'b>>(
    &self,
    cx: &mut C,
    other: Handle<'b, U>
) -> bool
[src]

Trait Implementations

impl<'a, T: Clone + Managed + 'a> Clone for Handle<'a, T>[src]

fn clone(&self) -> Handle<'a, T>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl<'a, T: Debug + Managed + 'a> Debug for Handle<'a, T>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a, T: Managed> Deref for Handle<'a, T>[src]

type Target = T

The resulting type after dereferencing.

fn deref(&self) -> &T[src]

Dereferences the value.

impl<'a, T: Managed> DerefMut for Handle<'a, T>[src]

fn deref_mut(&mut self) -> &mut T[src]

Mutably dereferences the value.

impl<'a, K: Value> PropertyKey for Handle<'a, K>[src]

unsafe fn get_from<'c, C: Context<'c>>(
    self,
    cx: &mut C,
    out: &mut Local,
    obj: Local
) -> bool
[src]

unsafe fn set_from<'c, C: Context<'c>>(
    self,
    cx: &mut C,
    out: &mut bool,
    obj: Local,
    val: Local
) -> bool
[src]

impl<'a, T: Copy + Managed + 'a> Copy for Handle<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for Handle<'a, T> where
    T: RefUnwindSafe

impl<'a, T> Send for Handle<'a, T> where
    T: Send + Sync

impl<'a, T> Sync for Handle<'a, T> where
    T: Sync

impl<'a, T> Unpin for Handle<'a, T> where
    T: Unpin

impl<'a, T> UnwindSafe for Handle<'a, T> where
    T: RefUnwindSafe + UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

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]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.