Struct neon::prelude::Root[][src]

#[repr(transparent)]pub struct Root<T> { /* fields omitted */ }

Root<T> holds a reference to a JavaScript object and prevents it from being garbage collected. Root<T> may be sent across threads, but the referenced objected may only be accessed on the JavaScript thread that created it.

Implementations

impl<T: Object> Root<T>[src]

pub fn new<'a, C: Context<'a>>(cx: &mut C, value: &T) -> Self[src]

Create a reference to a JavaScript object. The object will not be garbage collected until the Root is dropped. A Root<T> may only be dropped on the JavaScript thread that created it.

The caller must ensure Root::into_inner or Root::drop is called to properly dispose of the Root<T>. If the value is dropped without calling one of these methods, it will panic.

pub fn clone<'a, C: Context<'a>>(&self, cx: &mut C) -> Self[src]

Clone a reference to the contained JavaScript object. This method can be considered identical to the following:

let inner = root.into_inner(&mut cx);
let cloned = inner.root(&mut cx);
let root = inner.root(&mut cx);

pub fn drop<'a, C: Context<'a>>(self, cx: &mut C)[src]

Safely drop a Root<T> without returning the referenced JavaScript object.

pub fn into_inner<'a, C: Context<'a>>(self, cx: &mut C) -> Handle<'a, T>[src]

Return the referenced JavaScript object and allow it to be garbage collected

pub fn to_inner<'a, C: Context<'a>>(&self, cx: &mut C) -> Handle<'a, T>[src]

Access the inner JavaScript object without consuming the Root This method aliases the reference without changing the reference count. It can be used in place of a clone immediately followed by a call to into_inner.

Trait Implementations

impl<T> Debug for Root<T>[src]

impl<T> Drop for Root<T>[src]

impl<T: Object> Finalize for Root<T>[src]

impl<T> Send for Root<T>[src]

impl<T> Sync for Root<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for Root<T> where
    T: RefUnwindSafe
[src]

impl<T> Unpin for Root<T> where
    T: Unpin
[src]

impl<T> UnwindSafe for Root<T> where
    T: UnwindSafe
[src]

Blanket Implementations

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

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

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

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

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

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.

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.