Function xpcom::getter_addrefs [] [src]

pub fn getter_addrefs<T: RefCounted, F>(f: F) -> Result<RefPtr<T>, nsresult> where
    F: FnOnce(*mut *const T) -> nsresult

Helper method for calling XPCOM methods which return a reference counted value through an outparameter. Takes a lambda, which is called with a valid outparameter argument (*mut *const T), and returns a nsresult. Returns either a RefPtr<T> with the value returned from the outparameter, or a nsresult.

NOTE:

Can return Err(NS_OK) if the call succeeded, but the outparameter was set to NULL.

Usage

let x: Result<RefPtr<T>, nsresult> =
    getter_addrefs(|p| iosvc.NewURI(uri, ptr::null(), ptr::null(), p));