pub struct RefGuard<T: Rc> { /* private fields */ }Expand description
A smart pointer for types from cef library.
Implementations§
Source§impl<T: Rc> RefGuard<T>
impl<T: Rc> RefGuard<T>
Sourcepub unsafe fn from_raw(ptr: *mut T) -> RefGuard<T>
pub unsafe fn from_raw(ptr: *mut T) -> RefGuard<T>
Create RefGuard from a raw C pointer.
§Safety
This should be used to get the return value of the FFI function. This means we get the ownership of the value. The reference count of the return value is already increased when you get it. So we don’t need to increase it again manually. Using this method elsewhere may cause incorrect reference count and memory safety issues.
Sourcepub unsafe fn from_raw_add_ref(ptr: *mut T) -> RefGuard<T>
pub unsafe fn from_raw_add_ref(ptr: *mut T) -> RefGuard<T>
Create RefGuard from a raw C pointer and increase a reference count. This should be used when you want to copy the value and create another wrapper type.
§Safety
THis should be used when you want to manually increase the reference count upon getting the raw pointer. Using this method elsewhere may cause incorrect reference count and memory safety issues.
Sourcepub unsafe fn into_raw(&self) -> *mut T
pub unsafe fn into_raw(&self) -> *mut T
§Safety
This should be used when you need to pass wrapper type to the FFI function as parameter, and it is
the self type (usually the first parameter). This means we pass the ownership of the
value to the function call. Using this method elsewhere may cause incorrect reference count
and memory safety issues.
Trait Implementations§
Source§impl<T> ConvertParam<*mut T> for &RefGuard<T>
impl<T> ConvertParam<*mut T> for &RefGuard<T>
Source§fn into_raw(self) -> *mut T
fn into_raw(self) -> *mut T
Access the RefGuard and return the raw pointer without decreasing the reference count.
§Safety
This should be used when you need to pass wrapper type to the FFI function as parameter, and it is not
the self type (usually the first parameter). This means we pass the ownership of the
value to the function call. Using this method elsewehre may cause incorrect reference count
and memory safety issues.