     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53

    extern crate kawaii;

    use self::kawaii::Measure;

    use std::ffi::CStr;
    use std::ptr::null_mut;
    use std::mem::transmute;
    use std::os::raw::c_char;

    /// Constructs a new `Measure` on heap and returns pointer.
    #[no_mangle]
    pub extern "C" fn measure_init(name: *const c_char) -> *mut Measure {
        if name.is_null() {
            return null_mut();
        }

        unsafe {
            match CStr::from_ptr(name).to_str() {
                Err(_) => null_mut(),
                Ok(name) => transmute(Box::new(Measure::new(String::from(name)))),
            }
        }
    }

    /// Drops a `Measure` pointer on heap.
    #[no_mangle]
    pub extern "C" fn measure_clean(measure: *mut Measure) {
        let _measure: Box<Measure> = unsafe { transmute(measure) };
    }

    /// Starts measure on `Measure` pointer.
    #[no_mangle]
    pub extern "C" fn measure_start(measure: *mut Measure) {
        let measure = unsafe { &mut *measure };

        measure.start();
    }

    /// Pause measure on `Measure` pointer.
    #[no_mangle]
    pub extern "C" fn measure_pause(measure: *mut Measure) {
        let measure = unsafe { &mut *measure };

        measure.pause();
    }

    /// Stop measure on `Measure` pointer.
    #[no_mangle]
    pub extern "C" fn measure_stop(measure: *mut Measure) {
        let measure = unsafe { &mut *measure };

        measure.stop();
    }

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result
+
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)