neon::types

Trait Finalize

Source
pub trait Finalize: Sized {
    // Provided method
    fn finalize<'a, C: Context<'a>>(self, _: &mut C) { ... }
}
Expand description

A trait for finalizing values owned by the main JavaScript thread.

Finalize::finalize is executed on the main JavaScript thread immediately before garbage collection.

Values contained by a JsBox must implement Finalize.

§Examples

Finalize provides a default implementation that does not perform any finalization.

struct Point(f64, f64);

impl Finalize for Point {}

A finalize method may be specified for performing clean-up operations before dropping the contained value.

struct Point(f64, f64);

impl Finalize for Point {
    fn finalize<'a, C: Context<'a>>(self, cx: &mut C) {
        cx.global_object()
            .method(cx.cx_mut(), "emit").unwrap()
            .args(("gc_point", self.0, self.1)).unwrap()
            .exec().unwrap();
    }
}

Provided Methods§

Source

fn finalize<'a, C: Context<'a>>(self, _: &mut C)

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Finalize for bool

Source§

impl Finalize for char

Source§

impl Finalize for f32

Source§

impl Finalize for f64

Source§

impl Finalize for i8

Source§

impl Finalize for i16

Source§

impl Finalize for i32

Source§

impl Finalize for i64

Source§

impl Finalize for isize

Source§

impl Finalize for u8

Source§

impl Finalize for u16

Source§

impl Finalize for u32

Source§

impl Finalize for u64

Source§

impl Finalize for ()

Source§

impl Finalize for usize

Source§

impl Finalize for String

Source§

impl Finalize for PathBuf

Source§

impl<T0: Finalize> Finalize for (T0,)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize> Finalize for (T0, T1)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize> Finalize for (T0, T1, T2)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize, T3: Finalize> Finalize for (T0, T1, T2, T3)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize, T3: Finalize, T4: Finalize> Finalize for (T0, T1, T2, T3, T4)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize, T3: Finalize, T4: Finalize, T5: Finalize> Finalize for (T0, T1, T2, T3, T4, T5)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize, T3: Finalize, T4: Finalize, T5: Finalize, T6: Finalize> Finalize for (T0, T1, T2, T3, T4, T5, T6)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T0: Finalize, T1: Finalize, T2: Finalize, T3: Finalize, T4: Finalize, T5: Finalize, T6: Finalize, T7: Finalize> Finalize for (T0, T1, T2, T3, T4, T5, T6, T7)

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Option<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Box<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Rc<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Arc<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Vec<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Cell<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for RefCell<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for Mutex<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Source§

impl<T: Finalize> Finalize for RwLock<T>

Source§

fn finalize<'a, C: Context<'a>>(self, cx: &mut C)

Implementors§

Source§

impl<T: Object> Finalize for Root<T>