Struct cpp_utils::CppBox [] [src]

pub struct CppBox<T> { /* fields omitted */ }

A C++ pointer wrapper to manage deletion of objects.

Objects of CppBox should be created by calling into_box() for types that implement CppDeletable trait. The object will be deleted when corresponding CppBox is deleted.

Methods

impl<T> CppBox<T>
[src]

Returns the pointer that was used to create the object and destroys the box. The caller of the function becomes the owner of the object and should ensure that the object will be deleted at some point.

impl<T: CppDeletable> CppBox<T>
[src]

Encapsulates the object into a CppBox.

You should use this function only for pointers that were created on C++ side and passed through a FFI boundary to Rust. An object created with C++ "new" must be deleted using C++ "delete", which is executed by CppBox.

Do not use this function for objects created in memory managed by Rust. Any wrapper constructor or function that returns an owned object is supposed to be deleted using Rust's ownage system and Drop trait.

Do not use this function for objects that would be deleted by other means. If another C++ object is the owner of the passed object, it will attempt to delete it. Together with CppBox, it would result in a double deletion, which should never happen.

Trait Implementations

impl<T> AsRef<T> for CppBox<T>
[src]

Performs the conversion.

impl<T> AsMut<T> for CppBox<T>
[src]

Performs the conversion.

impl<T> Deref for CppBox<T>
[src]

The resulting type after dereferencing

The method called to dereference a value

impl<T> DerefMut for CppBox<T>
[src]

The method called to mutably dereference a value

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

A method called when the value goes out of scope. Read more