gstreamer-rs/gstreamer/src/auto/date_time.rs

147 lines
5.6 KiB
Rust
Raw Normal View History

2018-04-23 17:34:22 +00:00
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git)
2017-07-29 14:11:44 +00:00
// DO NOT EDIT
use glib::translate::*;
2020-12-17 22:34:53 +00:00
glib::wrapper! {
#[derive()]
2020-11-21 13:46:33 +00:00
pub struct DateTime(Shared<ffi::GstDateTime>);
2017-07-29 14:11:44 +00:00
match fn {
2020-11-21 13:46:33 +00:00
ref => |ptr| ffi::gst_date_time_ref(ptr),
unref => |ptr| ffi::gst_date_time_unref(ptr),
type_ => || ffi::gst_date_time_get_type(),
2017-07-29 14:11:44 +00:00
}
}
impl DateTime {
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_g_date_time")]
#[doc(alias = "new_from_g_date_time")]
pub fn from_g_date_time(dt: &glib::DateTime) -> DateTime {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gst_date_time_new_from_g_date_time(dt.to_glib_full())) }
}
2017-07-29 14:11:44 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_iso8601_string")]
#[doc(alias = "new_from_iso8601_string")]
2020-06-11 10:27:43 +00:00
pub fn from_iso8601_string(string: &str) -> Result<DateTime, glib::BoolError> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
unsafe {
2020-11-21 13:46:33 +00:00
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_iso8601_string(
string.to_glib_none().0,
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to create DateTime from ISO-8601 string"))
2017-07-29 14:11:44 +00:00
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_unix_epoch_local_time")]
#[doc(alias = "new_from_unix_epoch_local_time")]
pub fn from_unix_epoch_local_time(secs: i64) -> Result<DateTime, glib::BoolError> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time(secs))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
}
2017-07-29 14:11:44 +00:00
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_unix_epoch_local_time_usecs")]
#[doc(alias = "new_from_unix_epoch_local_time_usecs")]
pub fn from_unix_epoch_local_time_usecs(usecs: i64) -> Result<DateTime, glib::BoolError> {
2020-04-30 16:51:41 +00:00
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_local_time_usecs(
2020-04-30 16:51:41 +00:00
usecs,
))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
2020-04-30 16:51:41 +00:00
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_unix_epoch_utc")]
#[doc(alias = "new_from_unix_epoch_utc")]
pub fn from_unix_epoch_utc(secs: i64) -> Result<DateTime, glib::BoolError> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc(secs))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
}
2017-07-29 14:11:44 +00:00
}
2020-11-27 13:37:24 +00:00
#[cfg(any(feature = "v1_18", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_18")))]
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_from_unix_epoch_utc_usecs")]
#[doc(alias = "new_from_unix_epoch_utc_usecs")]
pub fn from_unix_epoch_utc_usecs(usecs: i64) -> Result<DateTime, glib::BoolError> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
unsafe {
Option::<_>::from_glib_full(ffi::gst_date_time_new_from_unix_epoch_utc_usecs(usecs))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Can't create DateTime from UNIX epoch"))
2017-07-29 14:11:44 +00:00
}
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_now_local_time")]
2021-04-17 10:11:52 +00:00
pub fn new_now_local_time() -> Option<DateTime> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
2020-11-21 13:46:33 +00:00
unsafe { from_glib_full(ffi::gst_date_time_new_now_local_time()) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_new_now_utc")]
2021-04-17 10:11:52 +00:00
pub fn new_now_utc() -> Option<DateTime> {
2017-07-29 14:11:44 +00:00
assert_initialized_main_thread!();
2020-11-21 13:46:33 +00:00
unsafe { from_glib_full(ffi::gst_date_time_new_now_utc()) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_get_year")]
#[doc(alias = "get_year")]
2021-04-11 19:38:18 +00:00
pub fn year(&self) -> i32 {
2020-11-21 13:46:33 +00:00
unsafe { ffi::gst_date_time_get_year(self.to_glib_none().0) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_has_day")]
2017-07-29 14:11:44 +00:00
pub fn has_day(&self) -> bool {
2020-11-21 13:46:33 +00:00
unsafe { from_glib(ffi::gst_date_time_has_day(self.to_glib_none().0)) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_has_month")]
2017-07-29 14:11:44 +00:00
pub fn has_month(&self) -> bool {
2020-11-21 13:46:33 +00:00
unsafe { from_glib(ffi::gst_date_time_has_month(self.to_glib_none().0)) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_has_second")]
2017-07-29 14:11:44 +00:00
pub fn has_second(&self) -> bool {
2020-11-21 13:46:33 +00:00
unsafe { from_glib(ffi::gst_date_time_has_second(self.to_glib_none().0)) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_has_time")]
2017-07-29 14:11:44 +00:00
pub fn has_time(&self) -> bool {
2020-11-21 13:46:33 +00:00
unsafe { from_glib(ffi::gst_date_time_has_time(self.to_glib_none().0)) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_has_year")]
2017-07-29 14:11:44 +00:00
pub fn has_year(&self) -> bool {
2020-11-21 13:46:33 +00:00
unsafe { from_glib(ffi::gst_date_time_has_year(self.to_glib_none().0)) }
2017-07-29 14:11:44 +00:00
}
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_to_g_date_time")]
pub fn to_g_date_time(&self) -> Result<glib::DateTime, glib::BoolError> {
unsafe {
2020-11-21 13:46:33 +00:00
Option::<_>::from_glib_full(ffi::gst_date_time_to_g_date_time(self.to_glib_none().0))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Can't create glib::DateTime from DateTime"))
}
}
2017-07-29 14:11:44 +00:00
2020-12-08 13:00:17 +00:00
#[doc(alias = "gst_date_time_to_iso8601_string")]
2020-11-21 13:46:33 +00:00
pub fn to_iso8601_string(&self) -> Result<glib::GString, glib::BoolError> {
2017-07-29 14:11:44 +00:00
unsafe {
2020-11-21 13:46:33 +00:00
Option::<_>::from_glib_full(ffi::gst_date_time_to_iso8601_string(self.to_glib_none().0))
2020-12-17 22:34:53 +00:00
.ok_or_else(|| glib::bool_error!("Failed to create ISO-8601 string from DateTime"))
2017-07-29 14:11:44 +00:00
}
}
}
unsafe impl Send for DateTime {}
unsafe impl Sync for DateTime {}