Sha256: c11be14a0c95c3c9b055741e4b9c353d6bb6efe88075ceb05fd606b6ac34a2a6

Contents?: true

Size: 808 Bytes

Versions: 19

Compression:

Stored size: 808 Bytes

Contents

use super::*;

#[doc(hidden)]
#[repr(C)]
pub struct ScopedHeap {
    pub vtable: *const std::ffi::c_void,
    pub this: *const std::ffi::c_void,
}

#[doc(hidden)]
pub struct ScopedInterface<'a, T: Interface> {
    interface: T,
    lifetime: std::marker::PhantomData<&'a T>,
}

impl<'a, T: Interface> ScopedInterface<'a, T> {
    pub fn new(interface: T) -> Self {
        Self { interface, lifetime: std::marker::PhantomData }
    }
}

impl<'a, T: Interface> std::ops::Deref for ScopedInterface<'a, T> {
    type Target = T;

    fn deref(&self) -> &T {
        &self.interface
    }
}

impl<'a, T: Interface> Drop for ScopedInterface<'a, T> {
    fn drop(&mut self) {
        unsafe {
            let _ = std::boxed::Box::from_raw(self.interface.as_raw() as *const _ as *mut ScopedHeap);
        }
    }
}

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
wasmtime-29.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-28.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-27.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-26.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-25.0.2 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-25.0.1 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-25.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-24.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-23.0.2 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-22.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-21.0.1 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-20.0.2 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-20.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-18.0.3 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-17.0.1 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-17.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-16.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-15.0.1 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs
wasmtime-15.0.0 ./ext/cargo-vendor/windows-core-0.52.0/src/scoped_interface.rs