Add GDateTime bindings

This commit is contained in:
Sebastian Dröge 2017-07-29 15:11:44 +01:00
parent 9d35eff8d5
commit 33ccfc7225
3 changed files with 193 additions and 0 deletions

View file

@ -141,6 +141,11 @@ name = "Gst.Query"
status = "manual"
ref_mode = "ref"
[[object]]
name = "Gst.DateTime"
status = "generate"
concurrency = "send"
[[object]]
name = "Gst.Clock"
status = "generate"

View file

@ -0,0 +1,185 @@
// This file was generated by gir (a01311c+) from gir-files (???)
// DO NOT EDIT
use ffi;
use glib::translate::*;
use glib_ffi;
use gobject_ffi;
use std::mem;
use std::ptr;
glib_wrapper! {
pub struct DateTime(Shared<ffi::GstDateTime>);
match fn {
ref => |ptr| ffi::gst_date_time_ref(ptr),
unref => |ptr| ffi::gst_date_time_unref(ptr),
get_type => || ffi::gst_date_time_get_type(),
}
}
impl DateTime {
pub fn new(tzoffset: f32, year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new(tzoffset, year, month, day, hour, minute, seconds))
}
}
//pub fn new_from_g_date_time(dt: /*Ignored*/&glib::DateTime) -> DateTime {
// unsafe { TODO: call ffi::gst_date_time_new_from_g_date_time() }
//}
pub fn new_from_iso8601_string(string: &str) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_from_iso8601_string(string.to_glib_none().0))
}
}
pub fn new_from_unix_epoch_local_time(secs: i64) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time(secs))
}
}
pub fn new_from_unix_epoch_utc(secs: i64) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc(secs))
}
}
pub fn new_local_time(year: i32, month: i32, day: i32, hour: i32, minute: i32, seconds: f64) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_local_time(year, month, day, hour, minute, seconds))
}
}
pub fn new_now_local_time() -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_now_local_time())
}
}
pub fn new_now_utc() -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_now_utc())
}
}
pub fn new_y(year: i32) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_y(year))
}
}
pub fn new_ym(year: i32, month: i32) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_ym(year, month))
}
}
pub fn new_ymd(year: i32, month: i32, day: i32) -> DateTime {
assert_initialized_main_thread!();
unsafe {
from_glib_full(ffi::gst_date_time_new_ymd(year, month, day))
}
}
pub fn get_day(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_day(self.to_glib_none().0)
}
}
pub fn get_hour(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_hour(self.to_glib_none().0)
}
}
pub fn get_microsecond(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_microsecond(self.to_glib_none().0)
}
}
pub fn get_minute(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_minute(self.to_glib_none().0)
}
}
pub fn get_month(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_month(self.to_glib_none().0)
}
}
pub fn get_second(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_second(self.to_glib_none().0)
}
}
pub fn get_time_zone_offset(&self) -> f32 {
unsafe {
ffi::gst_date_time_get_time_zone_offset(self.to_glib_none().0)
}
}
pub fn get_year(&self) -> i32 {
unsafe {
ffi::gst_date_time_get_year(self.to_glib_none().0)
}
}
pub fn has_day(&self) -> bool {
unsafe {
from_glib(ffi::gst_date_time_has_day(self.to_glib_none().0))
}
}
pub fn has_month(&self) -> bool {
unsafe {
from_glib(ffi::gst_date_time_has_month(self.to_glib_none().0))
}
}
pub fn has_second(&self) -> bool {
unsafe {
from_glib(ffi::gst_date_time_has_second(self.to_glib_none().0))
}
}
pub fn has_time(&self) -> bool {
unsafe {
from_glib(ffi::gst_date_time_has_time(self.to_glib_none().0))
}
}
pub fn has_year(&self) -> bool {
unsafe {
from_glib(ffi::gst_date_time_has_year(self.to_glib_none().0))
}
}
//pub fn to_g_date_time(&self) -> /*Ignored*/Option<glib::DateTime> {
// unsafe { TODO: call ffi::gst_date_time_to_g_date_time() }
//}
pub fn to_iso8601_string(&self) -> Option<String> {
unsafe {
from_glib_full(ffi::gst_date_time_to_iso8601_string(self.to_glib_none().0))
}
}
}
unsafe impl Send for DateTime {}

View file

@ -84,6 +84,9 @@ mod u_r_i_handler;
pub use self::u_r_i_handler::URIHandler;
pub use self::u_r_i_handler::URIHandlerExt;
mod date_time;
pub use self::date_time::DateTime;
mod segment;
pub use self::segment::Segment;