pub fn init() -> Result<UI, UIError> {
        if ffi_tools::is_initialized() {
            return Err(UIError::MultipleInitError {});
        };

        unsafe {
            // Create the magic value needed to init libUI
            let mut init_options = ui_sys::uiInitOptions {
                Size: mem::size_of::<ui_sys::uiInitOptions>() as u64,
            };

            // Actually start up the library's functionality
            let err = ui_sys::uiInit(&mut init_options);
            if err.is_null() {
                // Success! We can safely give the user a token allowing them to do UI things.
                ffi_tools::set_initialized();
                Ok(UI {
                    token: Rc::new(UIToken { _pd: PhantomData }),
                })
            } else {
                // Error occurred; copy the string describing it, then free that memory.
                let error_string = CStr::from_ptr(err).to_string_lossy().into_owned();
                ui_sys::uiFreeInitError(err);
                Err(UIError::FailedInitError {
                    error: error_string,
                })
            }
        }
    }
/// Initializes the underlying UI bindings, producing a [`UI`](struct.UI.html) struct which can be used
/// to actually build your user interface. This is a reference counted type; clone it
/// to get an additional reference that can be passed to, e.g., callbacks.
///
/// Only one libUI binding can be active at once; if multiple instances are detected,
/// this function will return a [`MultipleInitError`](enum.UIError.html#variant.MultipleInitError).
/// Be aware the Cocoa (GUI toolkit on Mac OS) requires that the _first thread spawned_ controls
/// the UI, so do _not_ spin off your UI interactions into an alternative thread. You're likely to
/// have problems on Mac OS.
///
/// ```
/// # use iui::UI;
/// {
///     let ui1 = UI::init().unwrap();
///
///     // This will fail because there is already an instance of UI.
///     let ui2 = UI::init();
///     assert!(ui2.is_err());
///
///     // ui1 dropped here.
/// }
/// let ui3 = UI::init().unwrap();
/// ```
///
/// If libUI cannot initialize its hooks into the platform bindings, this function will
/// return a [`FailedInitError`](enum.UIError.html#variant.FailedInitError) with the description of the problem.
Initializes the underlying UI bindings, producing a [`UI`](struct.UI.html) struct which can be used
to actually build your user interface. This is a reference counted type; clone it
to get an additional reference that can be passed to, e.g., callbacks.

Only one libUI binding can be active at once; if multiple instances are detected,
this function will return a [`MultipleInitError`](enum.UIError.html#variant.MultipleInitError).
Be aware the Cocoa (GUI toolkit on Mac OS) requires that the _first thread spawned_ controls
the UI, so do _not_ spin off your UI interactions into an alternative thread. You're likely to
have problems on Mac OS.


Initializes the underlying UI bindings producing a [ ` UI ` ] ( struct . UI . html ) struct which can be used to actually build your user interface . This is a reference counted type ; clone it to get an additional reference that can be passed to e . g . callbacks . Only one libUI binding can be active at once ; if multiple instances are detected this function will return a [ ` MultipleInitError ` ] ( enum . UIError . html#variant . MultipleInitError ) . Be aware the Cocoa ( GUI toolkit on Mac OS ) requires that the _first thread spawned_ controls the UI so do _not_ spin off your UI interactions into an alternative thread . You ' re likely to have problems on Mac OS .
pub fn init() -> Result<UI, UIError> {
        if ffi_tools::is_initialized() {
            return Err(UIError::MultipleInitError {});
        };
        unsafe {
            // Create the magic value needed to init libUI
            let mut init_options = ui_sys::uiInitOptions {
                Size: mem::size_of::<ui_sys::uiInitOptions>() as u64,
            };
            // Actually start up the library's functionality
            let err = ui_sys::uiInit(&mut init_options);
            if err.is_null() {
                // Success! We can safely give the user a token allowing them to do UI things.
                ffi_tools::set_initialized();
                Ok(UI {
                    token: Rc::new(UIToken { _pd: PhantomData }),
                })
            } else {
                // Error occurred; copy the string describing it, then free that memory.
                let error_string = CStr::from_ptr(err).to_string_lossy().into_owned();
                ui_sys::uiFreeInitError(err);
                Err(UIError::FailedInitError {
                    error: error_string,
                })
            }
        }
    }
pub fn init ( ) -> Result < UI , UIError > { if ffi_tools :: is_initialized ( ) { return Err ( UIError :: MultipleInitError { } ) ; } ; unsafe { // Create the magic value needed to init libUI let mut init_options = ui_sys :: uiInitOptions { Size : mem :: size_of :: < ui_sys :: uiInitOptions > ( ) as u64 , } ; // Actually start up the library's functionality let err = ui_sys :: uiInit ( & mut init_options ) ; if err . is_null ( ) { // Success! We can safely give the user a token allowing them to do UI things. ffi_tools :: set_initialized ( ) ; Ok ( UI { token : Rc :: new ( UIToken { _pd : PhantomData } ) , } ) } else { // Error occurred; copy the string describing it, then free that memory. let error_string = CStr :: from_ptr ( err ) . to_string_lossy ( ) . into_owned ( ) ; ui_sys :: uiFreeInitError ( err ) ; Err ( UIError :: FailedInitError { error : error_string , } ) } } }
Initializes the underlying UI bindings, producing a [`UI`](struct.UI.html) struct which can be used
to actually build your user interface.
Initializes the underlying UI bindings producing a [ ` UI ` ] ( struct . UI . html ) struct which can be used to actually build your user interface .
use iui::ui;


This will fail because there is already an instance of UI.

ui1 dropped here.

If libUI cannot initialize its hooks into the platform bindings, this function will
return a [`FailedInitError`](enum.UIError.html#variant.FailedInitError) with the description of the problem.
This will fail because there is already an instance of UI . ui1 dropped here . If libUI cannot initialize its hooks into the platform bindings this function will return a [ ` FailedInitError ` ] ( enum . UIError . html#variant . FailedInitError ) with the description of the problem .