Struct xpcom::GetterAddrefs
[−]
[src]
pub struct GetterAddrefs<T: RefCounted + 'static> { /* fields omitted */ }
A helper struct for constructing RefPtr<T>
from raw pointer outparameters.
Holds a *const T
internally which will be released if non null when
destructed, and can be easily transformed into an Option<RefPtr<T>>
.
It many cases it may be easier to use the getter_addrefs
method.
Methods
impl<T: RefCounted + 'static> GetterAddrefs<T>
[src]
pub fn new() -> GetterAddrefs<T>
[src]
Create a GetterAddrefs
, initializing it with the null pointer.
pub unsafe fn ptr(&mut self) -> &mut *const T
[src]
Get a reference to the internal *const T
. This method is unsafe,
as the destructor of this class depends on the internal *const T
being either a valid reference to a value of type T
, or null.
pub unsafe fn void_ptr(&mut self) -> *mut *mut c_void
[src]
Get a reference to the internal *const T
as a *mut libc::c_void
.
This is useful to pass to functions like GetInterface
which take a
void pointer outparameter.
pub fn refptr(self) -> Option<RefPtr<T>>
[src]
Transform this GetterAddrefs
into an Option<RefPtr<T>>
, without
performing any addrefs or releases.