glib/
time_val.rs

1// Copyright 2013-2015, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib_sys;
6use std::mem;
7use translate::{StashMut, ToGlibPtrMut, Uninitialized};
8
9pub use glib_sys::GTimeVal as TimeVal;
10
11pub fn get_current_time() -> TimeVal {
12    unsafe {
13        let mut ret = mem::uninitialized();
14        glib_sys::g_get_current_time(&mut ret);
15        ret
16    }
17}
18
19#[doc(hidden)]
20impl<'a> ToGlibPtrMut<'a, *mut glib_sys::GTimeVal> for TimeVal {
21    type Storage = &'a mut Self;
22
23    fn to_glib_none_mut(&'a mut self) -> StashMut<'a, *mut glib_sys::GTimeVal, Self> {
24        StashMut(self as *mut _, self)
25    }
26}
27
28impl Uninitialized for TimeVal {
29    unsafe fn uninitialized() -> TimeVal {
30        mem::uninitialized()
31    }
32}