Backport official GLib iterator safety fix for Linux desktop

This commit is contained in:
karl committed 2026-10-13 10:35:50 +02:00
1 parent 43c43ebdc9
commit 8ef874c609
133 files changed
+55342 -2

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#[allow(unused_imports)]
use crate::auto::*;
#[doc(alias = "GDateDay")]
pub type DateDay = u8;
#[doc(alias = "GDateYear")]
pub type DateYear = u16;
#[doc(alias = "GTime")]
pub type Time = i32;
+46
View File
@@ -0,0 +1,46 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, ChecksumType};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Checksum(Boxed<ffi::GChecksum>);
match fn {
copy => |ptr| ffi::g_checksum_copy(ptr),
free => |ptr| ffi::g_checksum_free(ptr),
type_ => || ffi::g_checksum_get_type(),
}
}
impl Checksum {
#[doc(alias = "g_checksum_new")]
pub fn new(checksum_type: ChecksumType) -> Option<Checksum> {
unsafe { from_glib_full(ffi::g_checksum_new(checksum_type.into_glib())) }
}
#[doc(alias = "g_checksum_reset")]
pub fn reset(&mut self) {
unsafe {
ffi::g_checksum_reset(self.to_glib_none_mut().0);
}
}
#[doc(alias = "g_checksum_update")]
pub fn update(&mut self, data: &[u8]) {
let length = data.len() as _;
unsafe {
ffi::g_checksum_update(self.to_glib_none_mut().0, data.to_glib_none().0, length);
}
}
#[doc(alias = "g_checksum_type_get_length")]
pub fn type_get_length(checksum_type: ChecksumType) -> isize {
unsafe { ffi::g_checksum_type_get_length(checksum_type.into_glib()) }
}
}
unsafe impl Send for Checksum {}
unsafe impl Sync for Checksum {}
+105
View File
@@ -0,0 +1,105 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::GStr;
#[doc(alias = "G_CSET_A_2_Z")]
pub static CSET_A_2_Z: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_CSET_A_2_Z) };
#[doc(alias = "G_CSET_DIGITS")]
pub static CSET_DIGITS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_CSET_DIGITS) };
#[doc(alias = "G_CSET_a_2_z")]
pub static CSET_a_2_z: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_CSET_a_2_z) };
#[doc(alias = "G_KEY_FILE_DESKTOP_GROUP")]
pub static KEY_FILE_DESKTOP_GROUP: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_GROUP) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_ACTIONS")]
pub static KEY_FILE_DESKTOP_KEY_ACTIONS: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_ACTIONS) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_CATEGORIES")]
pub static KEY_FILE_DESKTOP_KEY_CATEGORIES: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_CATEGORIES) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_COMMENT")]
pub static KEY_FILE_DESKTOP_KEY_COMMENT: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_COMMENT) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE")]
pub static KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_EXEC")]
pub static KEY_FILE_DESKTOP_KEY_EXEC: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_EXEC) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME")]
pub static KEY_FILE_DESKTOP_KEY_GENERIC_NAME: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_HIDDEN")]
pub static KEY_FILE_DESKTOP_KEY_HIDDEN: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_HIDDEN) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_ICON")]
pub static KEY_FILE_DESKTOP_KEY_ICON: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_ICON) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_MIME_TYPE")]
pub static KEY_FILE_DESKTOP_KEY_MIME_TYPE: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_MIME_TYPE) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_NAME")]
pub static KEY_FILE_DESKTOP_KEY_NAME: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_NAME) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN")]
pub static KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY")]
pub static KEY_FILE_DESKTOP_KEY_NO_DISPLAY: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN")]
pub static KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_PATH")]
pub static KEY_FILE_DESKTOP_KEY_PATH: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_PATH) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY")]
pub static KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS")]
pub static KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_TERMINAL")]
pub static KEY_FILE_DESKTOP_KEY_TERMINAL: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_TERMINAL) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_TRY_EXEC")]
pub static KEY_FILE_DESKTOP_KEY_TRY_EXEC: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_TRY_EXEC) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_TYPE")]
pub static KEY_FILE_DESKTOP_KEY_TYPE: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_TYPE) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_URL")]
pub static KEY_FILE_DESKTOP_KEY_URL: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_URL) };
#[doc(alias = "G_KEY_FILE_DESKTOP_KEY_VERSION")]
pub static KEY_FILE_DESKTOP_KEY_VERSION: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_KEY_VERSION) };
#[doc(alias = "G_KEY_FILE_DESKTOP_TYPE_APPLICATION")]
pub static KEY_FILE_DESKTOP_TYPE_APPLICATION: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_TYPE_APPLICATION) };
#[doc(alias = "G_KEY_FILE_DESKTOP_TYPE_DIRECTORY")]
pub static KEY_FILE_DESKTOP_TYPE_DIRECTORY: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_TYPE_DIRECTORY) };
#[doc(alias = "G_KEY_FILE_DESKTOP_TYPE_LINK")]
pub static KEY_FILE_DESKTOP_TYPE_LINK: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_KEY_FILE_DESKTOP_TYPE_LINK) };
#[doc(alias = "G_OPTION_REMAINING")]
pub static OPTION_REMAINING: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_OPTION_REMAINING) };
#[doc(alias = "G_STR_DELIMITERS")]
pub static STR_DELIMITERS: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_STR_DELIMITERS) };
#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
#[doc(alias = "G_TEST_OPTION_ISOLATE_DIRS")]
pub static TEST_OPTION_ISOLATE_DIRS: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TEST_OPTION_ISOLATE_DIRS) };
#[doc(alias = "G_URI_RESERVED_CHARS_GENERIC_DELIMITERS")]
pub static URI_RESERVED_CHARS_GENERIC_DELIMITERS: &GStr =
unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_URI_RESERVED_CHARS_GENERIC_DELIMITERS) };
#[doc(alias = "G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS")]
pub static URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS: &GStr = unsafe {
GStr::from_utf8_with_nul_unchecked(ffi::G_URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS)
};
+502
View File
@@ -0,0 +1,502 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, BoolError, TimeSpan, TimeZone};
use std::{cmp, hash, mem};
crate::wrapper! {
#[derive(Debug)]
pub struct DateTime(Shared<ffi::GDateTime>);
match fn {
ref => |ptr| ffi::g_date_time_ref(ptr),
unref => |ptr| ffi::g_date_time_unref(ptr),
type_ => || ffi::g_date_time_get_type(),
}
}
impl DateTime {
#[doc(alias = "g_date_time_new")]
pub fn new(
tz: &TimeZone,
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
seconds: f64,
) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new(
tz.to_glib_none().0,
year,
month,
day,
hour,
minute,
seconds,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_from_iso8601")]
#[doc(alias = "new_from_iso8601")]
pub fn from_iso8601(text: &str, default_tz: Option<&TimeZone>) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_from_iso8601(
text.to_glib_none().0,
default_tz.to_glib_none().0,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
//#[cfg_attr(feature = "v2_62", deprecated = "Since 2.62")]
//#[allow(deprecated)]
//#[doc(alias = "g_date_time_new_from_timeval_local")]
//#[doc(alias = "new_from_timeval_local")]
//pub fn from_timeval_local(tv: /*Ignored*/&TimeVal) -> Result<DateTime, BoolError> {
// unsafe { TODO: call ffi:g_date_time_new_from_timeval_local() }
//}
//#[cfg_attr(feature = "v2_62", deprecated = "Since 2.62")]
//#[allow(deprecated)]
//#[doc(alias = "g_date_time_new_from_timeval_utc")]
//#[doc(alias = "new_from_timeval_utc")]
//pub fn from_timeval_utc(tv: /*Ignored*/&TimeVal) -> Result<DateTime, BoolError> {
// unsafe { TODO: call ffi:g_date_time_new_from_timeval_utc() }
//}
#[doc(alias = "g_date_time_new_from_unix_local")]
#[doc(alias = "new_from_unix_local")]
pub fn from_unix_local(t: i64) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_from_unix_local(t))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_from_unix_utc")]
#[doc(alias = "new_from_unix_utc")]
pub fn from_unix_utc(t: i64) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_from_unix_utc(t))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_local")]
#[doc(alias = "new_local")]
pub fn from_local(
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
seconds: f64,
) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_local(
year, month, day, hour, minute, seconds,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_now")]
#[doc(alias = "new_now")]
pub fn now(tz: &TimeZone) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_now(tz.to_glib_none().0))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_now_local")]
#[doc(alias = "new_now_local")]
pub fn now_local() -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_now_local())
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_now_utc")]
#[doc(alias = "new_now_utc")]
pub fn now_utc() -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_now_utc())
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_new_utc")]
#[doc(alias = "new_utc")]
pub fn from_utc(
year: i32,
month: i32,
day: i32,
hour: i32,
minute: i32,
seconds: f64,
) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_new_utc(
year, month, day, hour, minute, seconds,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add")]
pub fn add(&self, timespan: TimeSpan) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add(
self.to_glib_none().0,
timespan.into_glib(),
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_days")]
pub fn add_days(&self, days: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_days(self.to_glib_none().0, days))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_full")]
pub fn add_full(
&self,
years: i32,
months: i32,
days: i32,
hours: i32,
minutes: i32,
seconds: f64,
) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_full(
self.to_glib_none().0,
years,
months,
days,
hours,
minutes,
seconds,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_hours")]
pub fn add_hours(&self, hours: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_hours(self.to_glib_none().0, hours))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_minutes")]
pub fn add_minutes(&self, minutes: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_minutes(
self.to_glib_none().0,
minutes,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_months")]
pub fn add_months(&self, months: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_months(self.to_glib_none().0, months))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_seconds")]
pub fn add_seconds(&self, seconds: f64) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_seconds(
self.to_glib_none().0,
seconds,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_weeks")]
pub fn add_weeks(&self, weeks: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_weeks(self.to_glib_none().0, weeks))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_add_years")]
pub fn add_years(&self, years: i32) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_add_years(self.to_glib_none().0, years))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_compare")]
fn compare(&self, dt2: &DateTime) -> i32 {
unsafe {
ffi::g_date_time_compare(
ToGlibPtr::<*mut ffi::GDateTime>::to_glib_none(self).0 as ffi::gconstpointer,
ToGlibPtr::<*mut ffi::GDateTime>::to_glib_none(dt2).0 as ffi::gconstpointer,
)
}
}
#[doc(alias = "g_date_time_difference")]
pub fn difference(&self, begin: &DateTime) -> TimeSpan {
unsafe {
from_glib(ffi::g_date_time_difference(
self.to_glib_none().0,
begin.to_glib_none().0,
))
}
}
#[doc(alias = "g_date_time_equal")]
fn equal(&self, dt2: &DateTime) -> bool {
unsafe {
from_glib(ffi::g_date_time_equal(
ToGlibPtr::<*mut ffi::GDateTime>::to_glib_none(self).0 as ffi::gconstpointer,
ToGlibPtr::<*mut ffi::GDateTime>::to_glib_none(dt2).0 as ffi::gconstpointer,
))
}
}
#[doc(alias = "g_date_time_format")]
pub fn format(&self, format: &str) -> Result<crate::GString, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_format(
self.to_glib_none().0,
format.to_glib_none().0,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[cfg(feature = "v2_62")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))]
#[doc(alias = "g_date_time_format_iso8601")]
pub fn format_iso8601(&self) -> Result<crate::GString, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_format_iso8601(self.to_glib_none().0))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_get_day_of_month")]
#[doc(alias = "get_day_of_month")]
pub fn day_of_month(&self) -> i32 {
unsafe { ffi::g_date_time_get_day_of_month(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_day_of_week")]
#[doc(alias = "get_day_of_week")]
pub fn day_of_week(&self) -> i32 {
unsafe { ffi::g_date_time_get_day_of_week(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_day_of_year")]
#[doc(alias = "get_day_of_year")]
pub fn day_of_year(&self) -> i32 {
unsafe { ffi::g_date_time_get_day_of_year(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_hour")]
#[doc(alias = "get_hour")]
pub fn hour(&self) -> i32 {
unsafe { ffi::g_date_time_get_hour(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_microsecond")]
#[doc(alias = "get_microsecond")]
pub fn microsecond(&self) -> i32 {
unsafe { ffi::g_date_time_get_microsecond(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_minute")]
#[doc(alias = "get_minute")]
pub fn minute(&self) -> i32 {
unsafe { ffi::g_date_time_get_minute(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_month")]
#[doc(alias = "get_month")]
pub fn month(&self) -> i32 {
unsafe { ffi::g_date_time_get_month(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_second")]
#[doc(alias = "get_second")]
pub fn second(&self) -> i32 {
unsafe { ffi::g_date_time_get_second(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_seconds")]
#[doc(alias = "get_seconds")]
pub fn seconds(&self) -> f64 {
unsafe { ffi::g_date_time_get_seconds(self.to_glib_none().0) }
}
#[cfg(feature = "v2_58")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
#[doc(alias = "g_date_time_get_timezone")]
#[doc(alias = "get_timezone")]
pub fn timezone(&self) -> TimeZone {
unsafe { from_glib_none(ffi::g_date_time_get_timezone(self.to_glib_none().0)) }
}
#[doc(alias = "g_date_time_get_timezone_abbreviation")]
#[doc(alias = "get_timezone_abbreviation")]
pub fn timezone_abbreviation(&self) -> crate::GString {
unsafe {
from_glib_none(ffi::g_date_time_get_timezone_abbreviation(
self.to_glib_none().0,
))
}
}
#[doc(alias = "g_date_time_get_utc_offset")]
#[doc(alias = "get_utc_offset")]
pub fn utc_offset(&self) -> TimeSpan {
unsafe { from_glib(ffi::g_date_time_get_utc_offset(self.to_glib_none().0)) }
}
#[doc(alias = "g_date_time_get_week_numbering_year")]
#[doc(alias = "get_week_numbering_year")]
pub fn week_numbering_year(&self) -> i32 {
unsafe { ffi::g_date_time_get_week_numbering_year(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_week_of_year")]
#[doc(alias = "get_week_of_year")]
pub fn week_of_year(&self) -> i32 {
unsafe { ffi::g_date_time_get_week_of_year(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_year")]
#[doc(alias = "get_year")]
pub fn year(&self) -> i32 {
unsafe { ffi::g_date_time_get_year(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_get_ymd")]
#[doc(alias = "get_ymd")]
pub fn ymd(&self) -> (i32, i32, i32) {
unsafe {
let mut year = mem::MaybeUninit::uninit();
let mut month = mem::MaybeUninit::uninit();
let mut day = mem::MaybeUninit::uninit();
ffi::g_date_time_get_ymd(
self.to_glib_none().0,
year.as_mut_ptr(),
month.as_mut_ptr(),
day.as_mut_ptr(),
);
(year.assume_init(), month.assume_init(), day.assume_init())
}
}
#[doc(alias = "g_date_time_hash")]
fn hash(&self) -> u32 {
unsafe {
ffi::g_date_time_hash(
ToGlibPtr::<*mut ffi::GDateTime>::to_glib_none(self).0 as ffi::gconstpointer,
)
}
}
#[doc(alias = "g_date_time_is_daylight_savings")]
pub fn is_daylight_savings(&self) -> bool {
unsafe { from_glib(ffi::g_date_time_is_daylight_savings(self.to_glib_none().0)) }
}
#[doc(alias = "g_date_time_to_local")]
pub fn to_local(&self) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_to_local(self.to_glib_none().0))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
//#[cfg_attr(feature = "v2_62", deprecated = "Since 2.62")]
//#[allow(deprecated)]
//#[doc(alias = "g_date_time_to_timeval")]
//pub fn to_timeval(&self, tv: /*Ignored*/&mut TimeVal) -> bool {
// unsafe { TODO: call ffi:g_date_time_to_timeval() }
//}
#[doc(alias = "g_date_time_to_timezone")]
pub fn to_timezone(&self, tz: &TimeZone) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_to_timezone(
self.to_glib_none().0,
tz.to_glib_none().0,
))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
#[doc(alias = "g_date_time_to_unix")]
pub fn to_unix(&self) -> i64 {
unsafe { ffi::g_date_time_to_unix(self.to_glib_none().0) }
}
#[doc(alias = "g_date_time_to_utc")]
pub fn to_utc(&self) -> Result<DateTime, BoolError> {
unsafe {
Option::<_>::from_glib_full(ffi::g_date_time_to_utc(self.to_glib_none().0))
.ok_or_else(|| crate::bool_error!("Invalid date"))
}
}
}
impl PartialOrd for DateTime {
#[inline]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
Some(self.cmp(other))
}
}
impl Ord for DateTime {
#[inline]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.compare(other).cmp(&0)
}
}
impl PartialEq for DateTime {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for DateTime {}
impl hash::Hash for DateTime {
#[inline]
fn hash<H>(&self, state: &mut H)
where
H: hash::Hasher,
{
hash::Hash::hash(&self.hash(), state)
}
}
unsafe impl Send for DateTime {}
unsafe impl Sync for DateTime {}
File diff suppressed because it is too large. Load diff
+636
View File
@@ -0,0 +1,636 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{bitflags::bitflags, prelude::*, translate::*};
use std::fmt;
#[cfg(feature = "v2_66")]
bitflags! {
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GFileSetContentsFlags")]
pub struct FileSetContentsFlags: u32 {
#[doc(alias = "G_FILE_SET_CONTENTS_NONE")]
const NONE = ffi::G_FILE_SET_CONTENTS_NONE as _;
#[doc(alias = "G_FILE_SET_CONTENTS_CONSISTENT")]
const CONSISTENT = ffi::G_FILE_SET_CONTENTS_CONSISTENT as _;
#[doc(alias = "G_FILE_SET_CONTENTS_DURABLE")]
const DURABLE = ffi::G_FILE_SET_CONTENTS_DURABLE as _;
#[doc(alias = "G_FILE_SET_CONTENTS_ONLY_EXISTING")]
const ONLY_EXISTING = ffi::G_FILE_SET_CONTENTS_ONLY_EXISTING as _;
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
impl fmt::Display for FileSetContentsFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for FileSetContentsFlags {
type GlibType = ffi::GFileSetContentsFlags;
#[inline]
fn into_glib(self) -> ffi::GFileSetContentsFlags {
self.bits()
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GFileSetContentsFlags> for FileSetContentsFlags {
#[inline]
unsafe fn from_glib(value: ffi::GFileSetContentsFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GFileTest")]
pub(crate) struct FileTest: u32 {
#[doc(alias = "G_FILE_TEST_IS_REGULAR")]
const IS_REGULAR = ffi::G_FILE_TEST_IS_REGULAR as _;
#[doc(alias = "G_FILE_TEST_IS_SYMLINK")]
const IS_SYMLINK = ffi::G_FILE_TEST_IS_SYMLINK as _;
#[doc(alias = "G_FILE_TEST_IS_DIR")]
const IS_DIR = ffi::G_FILE_TEST_IS_DIR as _;
#[doc(alias = "G_FILE_TEST_IS_EXECUTABLE")]
const IS_EXECUTABLE = ffi::G_FILE_TEST_IS_EXECUTABLE as _;
#[doc(alias = "G_FILE_TEST_EXISTS")]
const EXISTS = ffi::G_FILE_TEST_EXISTS as _;
}
}
impl fmt::Display for FileTest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for FileTest {
type GlibType = ffi::GFileTest;
#[inline]
fn into_glib(self) -> ffi::GFileTest {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GFileTest> for FileTest {
#[inline]
unsafe fn from_glib(value: ffi::GFileTest) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GFormatSizeFlags")]
pub struct FormatSizeFlags: u32 {
#[doc(alias = "G_FORMAT_SIZE_DEFAULT")]
const DEFAULT = ffi::G_FORMAT_SIZE_DEFAULT as _;
#[doc(alias = "G_FORMAT_SIZE_LONG_FORMAT")]
const LONG_FORMAT = ffi::G_FORMAT_SIZE_LONG_FORMAT as _;
#[doc(alias = "G_FORMAT_SIZE_IEC_UNITS")]
const IEC_UNITS = ffi::G_FORMAT_SIZE_IEC_UNITS as _;
#[doc(alias = "G_FORMAT_SIZE_BITS")]
const BITS = ffi::G_FORMAT_SIZE_BITS as _;
#[cfg(feature = "v2_74")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))]
#[doc(alias = "G_FORMAT_SIZE_ONLY_VALUE")]
const ONLY_VALUE = ffi::G_FORMAT_SIZE_ONLY_VALUE as _;
#[cfg(feature = "v2_74")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))]
#[doc(alias = "G_FORMAT_SIZE_ONLY_UNIT")]
const ONLY_UNIT = ffi::G_FORMAT_SIZE_ONLY_UNIT as _;
}
}
impl fmt::Display for FormatSizeFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for FormatSizeFlags {
type GlibType = ffi::GFormatSizeFlags;
#[inline]
fn into_glib(self) -> ffi::GFormatSizeFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GFormatSizeFlags> for FormatSizeFlags {
#[inline]
unsafe fn from_glib(value: ffi::GFormatSizeFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GIOCondition")]
pub struct IOCondition: u32 {
#[doc(alias = "G_IO_IN")]
const IN = ffi::G_IO_IN as _;
#[doc(alias = "G_IO_OUT")]
const OUT = ffi::G_IO_OUT as _;
#[doc(alias = "G_IO_PRI")]
const PRI = ffi::G_IO_PRI as _;
#[doc(alias = "G_IO_ERR")]
const ERR = ffi::G_IO_ERR as _;
#[doc(alias = "G_IO_HUP")]
const HUP = ffi::G_IO_HUP as _;
#[doc(alias = "G_IO_NVAL")]
const NVAL = ffi::G_IO_NVAL as _;
}
}
impl fmt::Display for IOCondition {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for IOCondition {
type GlibType = ffi::GIOCondition;
#[inline]
fn into_glib(self) -> ffi::GIOCondition {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GIOCondition> for IOCondition {
#[inline]
unsafe fn from_glib(value: ffi::GIOCondition) -> Self {
Self::from_bits_truncate(value)
}
}
impl StaticType for IOCondition {
#[inline]
#[doc(alias = "g_io_condition_get_type")]
fn static_type() -> crate::Type {
unsafe { from_glib(ffi::g_io_condition_get_type()) }
}
}
impl crate::HasParamSpec for IOCondition {
type ParamSpec = crate::ParamSpecFlags;
type SetValue = Self;
type BuilderFn = fn(&str) -> crate::ParamSpecFlagsBuilder<Self>;
fn param_spec_builder() -> Self::BuilderFn {
Self::ParamSpec::builder
}
}
impl crate::value::ValueType for IOCondition {
type Type = Self;
}
unsafe impl<'a> crate::value::FromValue<'a> for IOCondition {
type Checker = crate::value::GenericValueTypeChecker<Self>;
#[inline]
unsafe fn from_value(value: &'a crate::Value) -> Self {
from_glib(crate::gobject_ffi::g_value_get_flags(
value.to_glib_none().0,
))
}
}
impl ToValue for IOCondition {
#[inline]
fn to_value(&self) -> crate::Value {
let mut value = crate::Value::for_value_type::<Self>();
unsafe {
crate::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib());
}
value
}
#[inline]
fn value_type(&self) -> crate::Type {
Self::static_type()
}
}
impl From<IOCondition> for crate::Value {
#[inline]
fn from(v: IOCondition) -> Self {
ToValue::to_value(&v)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GKeyFileFlags")]
pub struct KeyFileFlags: u32 {
#[doc(alias = "G_KEY_FILE_NONE")]
const NONE = ffi::G_KEY_FILE_NONE as _;
#[doc(alias = "G_KEY_FILE_KEEP_COMMENTS")]
const KEEP_COMMENTS = ffi::G_KEY_FILE_KEEP_COMMENTS as _;
#[doc(alias = "G_KEY_FILE_KEEP_TRANSLATIONS")]
const KEEP_TRANSLATIONS = ffi::G_KEY_FILE_KEEP_TRANSLATIONS as _;
}
}
impl fmt::Display for KeyFileFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for KeyFileFlags {
type GlibType = ffi::GKeyFileFlags;
#[inline]
fn into_glib(self) -> ffi::GKeyFileFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GKeyFileFlags> for KeyFileFlags {
#[inline]
unsafe fn from_glib(value: ffi::GKeyFileFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GLogLevelFlags")]
pub struct LogLevelFlags: u32 {
#[doc(alias = "G_LOG_FLAG_RECURSION")]
const FLAG_RECURSION = ffi::G_LOG_FLAG_RECURSION as _;
#[doc(alias = "G_LOG_FLAG_FATAL")]
const FLAG_FATAL = ffi::G_LOG_FLAG_FATAL as _;
#[doc(alias = "G_LOG_LEVEL_ERROR")]
const LEVEL_ERROR = ffi::G_LOG_LEVEL_ERROR as _;
#[doc(alias = "G_LOG_LEVEL_CRITICAL")]
const LEVEL_CRITICAL = ffi::G_LOG_LEVEL_CRITICAL as _;
#[doc(alias = "G_LOG_LEVEL_WARNING")]
const LEVEL_WARNING = ffi::G_LOG_LEVEL_WARNING as _;
#[doc(alias = "G_LOG_LEVEL_MESSAGE")]
const LEVEL_MESSAGE = ffi::G_LOG_LEVEL_MESSAGE as _;
#[doc(alias = "G_LOG_LEVEL_INFO")]
const LEVEL_INFO = ffi::G_LOG_LEVEL_INFO as _;
#[doc(alias = "G_LOG_LEVEL_DEBUG")]
const LEVEL_DEBUG = ffi::G_LOG_LEVEL_DEBUG as _;
#[doc(alias = "G_LOG_LEVEL_MASK")]
const LEVEL_MASK = ffi::G_LOG_LEVEL_MASK as _;
}
}
impl fmt::Display for LogLevelFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for LogLevelFlags {
type GlibType = ffi::GLogLevelFlags;
#[inline]
fn into_glib(self) -> ffi::GLogLevelFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GLogLevelFlags> for LogLevelFlags {
#[inline]
unsafe fn from_glib(value: ffi::GLogLevelFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(feature = "v2_72")]
bitflags! {
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GMainContextFlags")]
pub struct MainContextFlags: u32 {
#[doc(alias = "G_MAIN_CONTEXT_FLAGS_NONE")]
const NONE = ffi::G_MAIN_CONTEXT_FLAGS_NONE as _;
#[doc(alias = "G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING")]
const OWNERLESS_POLLING = ffi::G_MAIN_CONTEXT_FLAGS_OWNERLESS_POLLING as _;
}
}
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
impl fmt::Display for MainContextFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
#[doc(hidden)]
impl IntoGlib for MainContextFlags {
type GlibType = ffi::GMainContextFlags;
#[inline]
fn into_glib(self) -> ffi::GMainContextFlags {
self.bits()
}
}
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
#[doc(hidden)]
impl FromGlib<ffi::GMainContextFlags> for MainContextFlags {
#[inline]
unsafe fn from_glib(value: ffi::GMainContextFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GOptionFlags")]
pub struct OptionFlags: u32 {
#[doc(alias = "G_OPTION_FLAG_NONE")]
const NONE = ffi::G_OPTION_FLAG_NONE as _;
#[doc(alias = "G_OPTION_FLAG_HIDDEN")]
const HIDDEN = ffi::G_OPTION_FLAG_HIDDEN as _;
#[doc(alias = "G_OPTION_FLAG_IN_MAIN")]
const IN_MAIN = ffi::G_OPTION_FLAG_IN_MAIN as _;
#[doc(alias = "G_OPTION_FLAG_REVERSE")]
const REVERSE = ffi::G_OPTION_FLAG_REVERSE as _;
#[doc(alias = "G_OPTION_FLAG_NO_ARG")]
const NO_ARG = ffi::G_OPTION_FLAG_NO_ARG as _;
#[doc(alias = "G_OPTION_FLAG_FILENAME")]
const FILENAME = ffi::G_OPTION_FLAG_FILENAME as _;
#[doc(alias = "G_OPTION_FLAG_OPTIONAL_ARG")]
const OPTIONAL_ARG = ffi::G_OPTION_FLAG_OPTIONAL_ARG as _;
#[doc(alias = "G_OPTION_FLAG_NOALIAS")]
const NOALIAS = ffi::G_OPTION_FLAG_NOALIAS as _;
}
}
impl fmt::Display for OptionFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for OptionFlags {
type GlibType = ffi::GOptionFlags;
#[inline]
fn into_glib(self) -> ffi::GOptionFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GOptionFlags> for OptionFlags {
#[inline]
unsafe fn from_glib(value: ffi::GOptionFlags) -> Self {
Self::from_bits_truncate(value)
}
}
bitflags! {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GSpawnFlags")]
pub struct SpawnFlags: u32 {
#[doc(alias = "G_SPAWN_DEFAULT")]
const DEFAULT = ffi::G_SPAWN_DEFAULT as _;
#[doc(alias = "G_SPAWN_LEAVE_DESCRIPTORS_OPEN")]
const LEAVE_DESCRIPTORS_OPEN = ffi::G_SPAWN_LEAVE_DESCRIPTORS_OPEN as _;
#[doc(alias = "G_SPAWN_DO_NOT_REAP_CHILD")]
const DO_NOT_REAP_CHILD = ffi::G_SPAWN_DO_NOT_REAP_CHILD as _;
#[doc(alias = "G_SPAWN_SEARCH_PATH")]
const SEARCH_PATH = ffi::G_SPAWN_SEARCH_PATH as _;
#[doc(alias = "G_SPAWN_STDOUT_TO_DEV_NULL")]
const STDOUT_TO_DEV_NULL = ffi::G_SPAWN_STDOUT_TO_DEV_NULL as _;
#[doc(alias = "G_SPAWN_STDERR_TO_DEV_NULL")]
const STDERR_TO_DEV_NULL = ffi::G_SPAWN_STDERR_TO_DEV_NULL as _;
#[doc(alias = "G_SPAWN_CHILD_INHERITS_STDIN")]
const CHILD_INHERITS_STDIN = ffi::G_SPAWN_CHILD_INHERITS_STDIN as _;
#[doc(alias = "G_SPAWN_FILE_AND_ARGV_ZERO")]
const FILE_AND_ARGV_ZERO = ffi::G_SPAWN_FILE_AND_ARGV_ZERO as _;
#[doc(alias = "G_SPAWN_SEARCH_PATH_FROM_ENVP")]
const SEARCH_PATH_FROM_ENVP = ffi::G_SPAWN_SEARCH_PATH_FROM_ENVP as _;
#[doc(alias = "G_SPAWN_CLOEXEC_PIPES")]
const CLOEXEC_PIPES = ffi::G_SPAWN_CLOEXEC_PIPES as _;
#[cfg(feature = "v2_74")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))]
#[doc(alias = "G_SPAWN_CHILD_INHERITS_STDOUT")]
const CHILD_INHERITS_STDOUT = ffi::G_SPAWN_CHILD_INHERITS_STDOUT as _;
#[cfg(feature = "v2_74")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))]
#[doc(alias = "G_SPAWN_CHILD_INHERITS_STDERR")]
const CHILD_INHERITS_STDERR = ffi::G_SPAWN_CHILD_INHERITS_STDERR as _;
#[cfg(feature = "v2_74")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))]
#[doc(alias = "G_SPAWN_STDIN_FROM_DEV_NULL")]
const STDIN_FROM_DEV_NULL = ffi::G_SPAWN_STDIN_FROM_DEV_NULL as _;
}
}
impl fmt::Display for SpawnFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[doc(hidden)]
impl IntoGlib for SpawnFlags {
type GlibType = ffi::GSpawnFlags;
#[inline]
fn into_glib(self) -> ffi::GSpawnFlags {
self.bits()
}
}
#[doc(hidden)]
impl FromGlib<ffi::GSpawnFlags> for SpawnFlags {
#[inline]
unsafe fn from_glib(value: ffi::GSpawnFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(feature = "v2_66")]
bitflags! {
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GUriFlags")]
pub struct UriFlags: u32 {
#[doc(alias = "G_URI_FLAGS_NONE")]
const NONE = ffi::G_URI_FLAGS_NONE as _;
#[doc(alias = "G_URI_FLAGS_PARSE_RELAXED")]
const PARSE_RELAXED = ffi::G_URI_FLAGS_PARSE_RELAXED as _;
#[doc(alias = "G_URI_FLAGS_HAS_PASSWORD")]
const HAS_PASSWORD = ffi::G_URI_FLAGS_HAS_PASSWORD as _;
#[doc(alias = "G_URI_FLAGS_HAS_AUTH_PARAMS")]
const HAS_AUTH_PARAMS = ffi::G_URI_FLAGS_HAS_AUTH_PARAMS as _;
#[doc(alias = "G_URI_FLAGS_ENCODED")]
const ENCODED = ffi::G_URI_FLAGS_ENCODED as _;
#[doc(alias = "G_URI_FLAGS_NON_DNS")]
const NON_DNS = ffi::G_URI_FLAGS_NON_DNS as _;
#[doc(alias = "G_URI_FLAGS_ENCODED_QUERY")]
const ENCODED_QUERY = ffi::G_URI_FLAGS_ENCODED_QUERY as _;
#[doc(alias = "G_URI_FLAGS_ENCODED_PATH")]
const ENCODED_PATH = ffi::G_URI_FLAGS_ENCODED_PATH as _;
#[doc(alias = "G_URI_FLAGS_ENCODED_FRAGMENT")]
const ENCODED_FRAGMENT = ffi::G_URI_FLAGS_ENCODED_FRAGMENT as _;
#[doc(alias = "G_URI_FLAGS_SCHEME_NORMALIZE")]
const SCHEME_NORMALIZE = ffi::G_URI_FLAGS_SCHEME_NORMALIZE as _;
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriFlags {
type GlibType = ffi::GUriFlags;
#[inline]
fn into_glib(self) -> ffi::GUriFlags {
self.bits()
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriFlags> for UriFlags {
#[inline]
unsafe fn from_glib(value: ffi::GUriFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(feature = "v2_66")]
bitflags! {
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GUriHideFlags")]
pub struct UriHideFlags: u32 {
#[doc(alias = "G_URI_HIDE_NONE")]
const NONE = ffi::G_URI_HIDE_NONE as _;
#[doc(alias = "G_URI_HIDE_USERINFO")]
const USERINFO = ffi::G_URI_HIDE_USERINFO as _;
#[doc(alias = "G_URI_HIDE_PASSWORD")]
const PASSWORD = ffi::G_URI_HIDE_PASSWORD as _;
#[doc(alias = "G_URI_HIDE_AUTH_PARAMS")]
const AUTH_PARAMS = ffi::G_URI_HIDE_AUTH_PARAMS as _;
#[doc(alias = "G_URI_HIDE_QUERY")]
const QUERY = ffi::G_URI_HIDE_QUERY as _;
#[doc(alias = "G_URI_HIDE_FRAGMENT")]
const FRAGMENT = ffi::G_URI_HIDE_FRAGMENT as _;
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriHideFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriHideFlags {
type GlibType = ffi::GUriHideFlags;
#[inline]
fn into_glib(self) -> ffi::GUriHideFlags {
self.bits()
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriHideFlags> for UriHideFlags {
#[inline]
unsafe fn from_glib(value: ffi::GUriHideFlags) -> Self {
Self::from_bits_truncate(value)
}
}
#[cfg(feature = "v2_66")]
bitflags! {
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[doc(alias = "GUriParamsFlags")]
pub struct UriParamsFlags: u32 {
#[doc(alias = "G_URI_PARAMS_NONE")]
const NONE = ffi::G_URI_PARAMS_NONE as _;
#[doc(alias = "G_URI_PARAMS_CASE_INSENSITIVE")]
const CASE_INSENSITIVE = ffi::G_URI_PARAMS_CASE_INSENSITIVE as _;
#[doc(alias = "G_URI_PARAMS_WWW_FORM")]
const WWW_FORM = ffi::G_URI_PARAMS_WWW_FORM as _;
#[doc(alias = "G_URI_PARAMS_PARSE_RELAXED")]
const PARSE_RELAXED = ffi::G_URI_PARAMS_PARSE_RELAXED as _;
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
impl fmt::Display for UriParamsFlags {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<Self as fmt::Debug>::fmt(self, f)
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl IntoGlib for UriParamsFlags {
type GlibType = ffi::GUriParamsFlags;
#[inline]
fn into_glib(self) -> ffi::GUriParamsFlags {
self.bits()
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(hidden)]
impl FromGlib<ffi::GUriParamsFlags> for UriParamsFlags {
#[inline]
unsafe fn from_glib(value: ffi::GUriParamsFlags) -> Self {
Self::from_bits_truncate(value)
}
}
+863
View File
@@ -0,0 +1,863 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
use crate::FileSetContentsFlags;
use crate::{
translate::*, Bytes, ChecksumType, Error, FileTest, FormatSizeFlags, Pid, Source, SpawnFlags,
UnicodeScript, UserDirectory,
};
use std::{boxed::Box as Box_, mem, ptr};
#[doc(alias = "g_access")]
pub fn access(filename: impl AsRef<std::path::Path>, mode: i32) -> i32 {
unsafe { ffi::g_access(filename.as_ref().to_glib_none().0, mode) }
}
#[doc(alias = "g_base64_decode")]
pub fn base64_decode(text: &str) -> Vec<u8> {
unsafe {
let mut out_len = mem::MaybeUninit::uninit();
let ret = FromGlibContainer::from_glib_full_num(
ffi::g_base64_decode(text.to_glib_none().0, out_len.as_mut_ptr()),
out_len.assume_init() as _,
);
ret
}
}
//#[doc(alias = "g_base64_decode_inplace")]
//pub fn base64_decode_inplace(text: /*Unimplemented*/Vec<u8>) -> u8 {
// unsafe { TODO: call ffi:g_base64_decode_inplace() }
//}
//#[doc(alias = "g_base64_decode_step")]
//pub fn base64_decode_step(in_: &[u8], out: Vec<u8>, state: &mut i32, save: &mut u32) -> usize {
// unsafe { TODO: call ffi:g_base64_decode_step() }
//}
#[doc(alias = "g_base64_encode")]
pub fn base64_encode(data: &[u8]) -> crate::GString {
let len = data.len() as _;
unsafe { from_glib_full(ffi::g_base64_encode(data.to_glib_none().0, len)) }
}
//#[doc(alias = "g_base64_encode_close")]
//pub fn base64_encode_close(break_lines: bool, out: Vec<u8>, state: &mut i32, save: &mut i32) -> usize {
// unsafe { TODO: call ffi:g_base64_encode_close() }
//}
//#[doc(alias = "g_base64_encode_step")]
//pub fn base64_encode_step(in_: &[u8], break_lines: bool, out: Vec<u8>, state: &mut i32, save: &mut i32) -> usize {
// unsafe { TODO: call ffi:g_base64_encode_step() }
//}
#[doc(alias = "glib_check_version")]
pub fn check_version(
required_major: u32,
required_minor: u32,
required_micro: u32,
) -> Option<crate::GString> {
unsafe {
from_glib_none(ffi::glib_check_version(
required_major,
required_minor,
required_micro,
))
}
}
#[doc(alias = "g_compute_checksum_for_bytes")]
pub fn compute_checksum_for_bytes(
checksum_type: ChecksumType,
data: &Bytes,
) -> Option<crate::GString> {
unsafe {
from_glib_full(ffi::g_compute_checksum_for_bytes(
checksum_type.into_glib(),
data.to_glib_none().0,
))
}
}
#[doc(alias = "g_compute_checksum_for_data")]
pub fn compute_checksum_for_data(
checksum_type: ChecksumType,
data: &[u8],
) -> Option<crate::GString> {
let length = data.len() as _;
unsafe {
from_glib_full(ffi::g_compute_checksum_for_data(
checksum_type.into_glib(),
data.to_glib_none().0,
length,
))
}
}
#[doc(alias = "g_compute_hmac_for_bytes")]
pub fn compute_hmac_for_bytes(
digest_type: ChecksumType,
key: &Bytes,
data: &Bytes,
) -> crate::GString {
unsafe {
from_glib_full(ffi::g_compute_hmac_for_bytes(
digest_type.into_glib(),
key.to_glib_none().0,
data.to_glib_none().0,
))
}
}
#[doc(alias = "g_compute_hmac_for_data")]
pub fn compute_hmac_for_data(digest_type: ChecksumType, key: &[u8], data: &[u8]) -> crate::GString {
let key_len = key.len() as _;
let length = data.len() as _;
unsafe {
from_glib_full(ffi::g_compute_hmac_for_data(
digest_type.into_glib(),
key.to_glib_none().0,
key_len,
data.to_glib_none().0,
length,
))
}
}
#[doc(alias = "g_dcgettext")]
pub fn dcgettext(domain: Option<&str>, msgid: &str, category: i32) -> crate::GString {
unsafe {
from_glib_none(ffi::g_dcgettext(
domain.to_glib_none().0,
msgid.to_glib_none().0,
category,
))
}
}
#[doc(alias = "g_dgettext")]
pub fn dgettext(domain: Option<&str>, msgid: &str) -> crate::GString {
unsafe {
from_glib_none(ffi::g_dgettext(
domain.to_glib_none().0,
msgid.to_glib_none().0,
))
}
}
#[doc(alias = "g_dngettext")]
pub fn dngettext(
domain: Option<&str>,
msgid: &str,
msgid_plural: &str,
n: libc::c_ulong,
) -> crate::GString {
unsafe {
from_glib_none(ffi::g_dngettext(
domain.to_glib_none().0,
msgid.to_glib_none().0,
msgid_plural.to_glib_none().0,
n,
))
}
}
#[doc(alias = "g_dpgettext")]
pub fn dpgettext(domain: Option<&str>, msgctxtid: &str, msgidoffset: usize) -> crate::GString {
unsafe {
from_glib_none(ffi::g_dpgettext(
domain.to_glib_none().0,
msgctxtid.to_glib_none().0,
msgidoffset,
))
}
}
#[doc(alias = "g_dpgettext2")]
pub fn dpgettext2(domain: Option<&str>, context: &str, msgid: &str) -> crate::GString {
unsafe {
from_glib_none(ffi::g_dpgettext2(
domain.to_glib_none().0,
context.to_glib_none().0,
msgid.to_glib_none().0,
))
}
}
#[doc(alias = "g_file_set_contents")]
pub fn file_set_contents(
filename: impl AsRef<std::path::Path>,
contents: &[u8],
) -> Result<(), crate::Error> {
let length = contents.len() as _;
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_file_set_contents(
filename.as_ref().to_glib_none().0,
contents.to_glib_none().0,
length,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
#[doc(alias = "g_file_set_contents_full")]
pub fn file_set_contents_full(
filename: impl AsRef<std::path::Path>,
contents: &[u8],
flags: FileSetContentsFlags,
mode: i32,
) -> Result<(), crate::Error> {
let length = contents.len() as _;
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_file_set_contents_full(
filename.as_ref().to_glib_none().0,
contents.to_glib_none().0,
length,
flags.into_glib(),
mode,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_file_test")]
#[allow(dead_code)]
pub(crate) fn file_test(filename: impl AsRef<std::path::Path>, test: FileTest) -> bool {
unsafe {
from_glib(ffi::g_file_test(
filename.as_ref().to_glib_none().0,
test.into_glib(),
))
}
}
#[doc(alias = "g_filename_display_basename")]
pub fn filename_display_basename(filename: impl AsRef<std::path::Path>) -> crate::GString {
unsafe {
from_glib_full(ffi::g_filename_display_basename(
filename.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "g_filename_display_name")]
pub fn filename_display_name(filename: impl AsRef<std::path::Path>) -> crate::GString {
unsafe {
from_glib_full(ffi::g_filename_display_name(
filename.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "g_filename_from_uri")]
pub fn filename_from_uri(
uri: &str,
) -> Result<(std::path::PathBuf, Option<crate::GString>), crate::Error> {
unsafe {
let mut hostname = ptr::null_mut();
let mut error = ptr::null_mut();
let ret = ffi::g_filename_from_uri(uri.to_glib_none().0, &mut hostname, &mut error);
if error.is_null() {
Ok((from_glib_full(ret), from_glib_full(hostname)))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_filename_to_uri")]
pub fn filename_to_uri(
filename: impl AsRef<std::path::Path>,
hostname: Option<&str>,
) -> Result<crate::GString, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_filename_to_uri(
filename.as_ref().to_glib_none().0,
hostname.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_find_program_in_path")]
pub fn find_program_in_path(program: impl AsRef<std::path::Path>) -> Option<std::path::PathBuf> {
unsafe {
from_glib_full(ffi::g_find_program_in_path(
program.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "g_format_size")]
pub fn format_size(size: u64) -> crate::GString {
unsafe { from_glib_full(ffi::g_format_size(size)) }
}
#[doc(alias = "g_format_size_full")]
pub fn format_size_full(size: u64, flags: FormatSizeFlags) -> crate::GString {
unsafe { from_glib_full(ffi::g_format_size_full(size, flags.into_glib())) }
}
#[doc(alias = "g_get_application_name")]
#[doc(alias = "get_application_name")]
pub fn application_name() -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_get_application_name()) }
}
#[doc(alias = "g_get_codeset")]
#[doc(alias = "get_codeset")]
pub fn codeset() -> crate::GString {
unsafe { from_glib_full(ffi::g_get_codeset()) }
}
#[cfg(feature = "v2_62")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))]
#[doc(alias = "g_get_console_charset")]
#[doc(alias = "get_console_charset")]
pub fn console_charset() -> Option<crate::GString> {
unsafe {
let mut charset = ptr::null();
let ret = from_glib(ffi::g_get_console_charset(&mut charset));
if ret {
Some(from_glib_none(charset))
} else {
None
}
}
}
#[doc(alias = "g_get_current_dir")]
#[doc(alias = "get_current_dir")]
pub fn current_dir() -> std::path::PathBuf {
unsafe { from_glib_full(ffi::g_get_current_dir()) }
}
#[doc(alias = "g_get_environ")]
#[doc(alias = "get_environ")]
pub fn environ() -> Vec<std::ffi::OsString> {
unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_get_environ()) }
}
#[doc(alias = "g_get_home_dir")]
#[doc(alias = "get_home_dir")]
pub fn home_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_home_dir()) }
}
#[doc(alias = "g_get_host_name")]
#[doc(alias = "get_host_name")]
pub fn host_name() -> crate::GString {
unsafe { from_glib_none(ffi::g_get_host_name()) }
}
#[doc(alias = "g_get_language_names")]
#[doc(alias = "get_language_names")]
pub fn language_names() -> Vec<crate::GString> {
unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_language_names()) }
}
#[cfg(feature = "v2_58")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
#[doc(alias = "g_get_language_names_with_category")]
#[doc(alias = "get_language_names_with_category")]
pub fn language_names_with_category(category_name: &str) -> Vec<crate::GString> {
unsafe {
FromGlibPtrContainer::from_glib_none(ffi::g_get_language_names_with_category(
category_name.to_glib_none().0,
))
}
}
#[doc(alias = "g_get_locale_variants")]
#[doc(alias = "get_locale_variants")]
pub fn locale_variants(locale: &str) -> Vec<crate::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_get_locale_variants(locale.to_glib_none().0))
}
}
#[doc(alias = "g_get_monotonic_time")]
#[doc(alias = "get_monotonic_time")]
pub fn monotonic_time() -> i64 {
unsafe { ffi::g_get_monotonic_time() }
}
#[doc(alias = "g_get_num_processors")]
#[doc(alias = "get_num_processors")]
pub fn num_processors() -> u32 {
unsafe { ffi::g_get_num_processors() }
}
#[cfg(feature = "v2_64")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))]
#[doc(alias = "g_get_os_info")]
#[doc(alias = "get_os_info")]
pub fn os_info(key_name: &str) -> Option<crate::GString> {
unsafe { from_glib_full(ffi::g_get_os_info(key_name.to_glib_none().0)) }
}
#[doc(alias = "g_get_real_name")]
#[doc(alias = "get_real_name")]
pub fn real_name() -> std::ffi::OsString {
unsafe { from_glib_none(ffi::g_get_real_name()) }
}
#[doc(alias = "g_get_real_time")]
#[doc(alias = "get_real_time")]
pub fn real_time() -> i64 {
unsafe { ffi::g_get_real_time() }
}
#[doc(alias = "g_get_system_config_dirs")]
#[doc(alias = "get_system_config_dirs")]
pub fn system_config_dirs() -> Vec<std::path::PathBuf> {
unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_system_config_dirs()) }
}
#[doc(alias = "g_get_system_data_dirs")]
#[doc(alias = "get_system_data_dirs")]
pub fn system_data_dirs() -> Vec<std::path::PathBuf> {
unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_get_system_data_dirs()) }
}
#[doc(alias = "g_get_tmp_dir")]
#[doc(alias = "get_tmp_dir")]
pub fn tmp_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_tmp_dir()) }
}
#[doc(alias = "g_get_user_cache_dir")]
#[doc(alias = "get_user_cache_dir")]
pub fn user_cache_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_user_cache_dir()) }
}
#[doc(alias = "g_get_user_config_dir")]
#[doc(alias = "get_user_config_dir")]
pub fn user_config_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_user_config_dir()) }
}
#[doc(alias = "g_get_user_data_dir")]
#[doc(alias = "get_user_data_dir")]
pub fn user_data_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_user_data_dir()) }
}
#[doc(alias = "g_get_user_name")]
#[doc(alias = "get_user_name")]
pub fn user_name() -> std::ffi::OsString {
unsafe { from_glib_none(ffi::g_get_user_name()) }
}
#[doc(alias = "g_get_user_runtime_dir")]
#[doc(alias = "get_user_runtime_dir")]
pub fn user_runtime_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_user_runtime_dir()) }
}
#[doc(alias = "g_get_user_special_dir")]
#[doc(alias = "get_user_special_dir")]
pub fn user_special_dir(directory: UserDirectory) -> Option<std::path::PathBuf> {
unsafe { from_glib_none(ffi::g_get_user_special_dir(directory.into_glib())) }
}
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
#[doc(alias = "g_get_user_state_dir")]
#[doc(alias = "get_user_state_dir")]
pub fn user_state_dir() -> std::path::PathBuf {
unsafe { from_glib_none(ffi::g_get_user_state_dir()) }
}
#[doc(alias = "g_getenv")]
pub fn getenv(variable: impl AsRef<std::ffi::OsStr>) -> Option<std::ffi::OsString> {
unsafe { from_glib_none(ffi::g_getenv(variable.as_ref().to_glib_none().0)) }
}
#[doc(alias = "g_hostname_is_ascii_encoded")]
pub fn hostname_is_ascii_encoded(hostname: &str) -> bool {
unsafe { from_glib(ffi::g_hostname_is_ascii_encoded(hostname.to_glib_none().0)) }
}
#[doc(alias = "g_hostname_is_ip_address")]
pub fn hostname_is_ip_address(hostname: &str) -> bool {
unsafe { from_glib(ffi::g_hostname_is_ip_address(hostname.to_glib_none().0)) }
}
#[doc(alias = "g_hostname_is_non_ascii")]
pub fn hostname_is_non_ascii(hostname: &str) -> bool {
unsafe { from_glib(ffi::g_hostname_is_non_ascii(hostname.to_glib_none().0)) }
}
#[doc(alias = "g_hostname_to_ascii")]
pub fn hostname_to_ascii(hostname: &str) -> Option<crate::GString> {
unsafe { from_glib_full(ffi::g_hostname_to_ascii(hostname.to_glib_none().0)) }
}
#[doc(alias = "g_hostname_to_unicode")]
pub fn hostname_to_unicode(hostname: &str) -> Option<crate::GString> {
unsafe { from_glib_full(ffi::g_hostname_to_unicode(hostname.to_glib_none().0)) }
}
#[doc(alias = "g_listenv")]
pub fn listenv() -> Vec<std::ffi::OsString> {
unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_listenv()) }
}
#[doc(alias = "g_main_current_source")]
pub fn main_current_source() -> Option<Source> {
unsafe { from_glib_none(ffi::g_main_current_source()) }
}
#[doc(alias = "g_main_depth")]
pub fn main_depth() -> i32 {
unsafe { ffi::g_main_depth() }
}
#[doc(alias = "g_markup_escape_text")]
pub fn markup_escape_text(text: &str) -> crate::GString {
let length = text.len() as _;
unsafe { from_glib_full(ffi::g_markup_escape_text(text.to_glib_none().0, length)) }
}
#[doc(alias = "g_mkdir_with_parents")]
pub fn mkdir_with_parents(pathname: impl AsRef<std::path::Path>, mode: i32) -> i32 {
unsafe { ffi::g_mkdir_with_parents(pathname.as_ref().to_glib_none().0, mode) }
}
#[doc(alias = "g_on_error_query")]
pub fn on_error_query(prg_name: &str) {
unsafe {
ffi::g_on_error_query(prg_name.to_glib_none().0);
}
}
#[doc(alias = "g_on_error_stack_trace")]
pub fn on_error_stack_trace(prg_name: &str) {
unsafe {
ffi::g_on_error_stack_trace(prg_name.to_glib_none().0);
}
}
#[doc(alias = "g_path_get_basename")]
#[allow(dead_code)]
pub(crate) fn path_get_basename(file_name: impl AsRef<std::path::Path>) -> std::path::PathBuf {
unsafe {
from_glib_full(ffi::g_path_get_basename(
file_name.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "g_path_get_dirname")]
#[allow(dead_code)]
pub(crate) fn path_get_dirname(file_name: impl AsRef<std::path::Path>) -> std::path::PathBuf {
unsafe { from_glib_full(ffi::g_path_get_dirname(file_name.as_ref().to_glib_none().0)) }
}
//#[doc(alias = "g_poll")]
//pub fn poll(fds: /*Ignored*/&mut PollFD, nfds: u32, timeout: i32) -> i32 {
// unsafe { TODO: call ffi:g_poll() }
//}
#[doc(alias = "g_random_double")]
pub fn random_double() -> f64 {
unsafe { ffi::g_random_double() }
}
#[doc(alias = "g_random_double_range")]
pub fn random_double_range(begin: f64, end: f64) -> f64 {
unsafe { ffi::g_random_double_range(begin, end) }
}
#[doc(alias = "g_random_int")]
pub fn random_int() -> u32 {
unsafe { ffi::g_random_int() }
}
#[doc(alias = "g_random_int_range")]
pub fn random_int_range(begin: i32, end: i32) -> i32 {
unsafe { ffi::g_random_int_range(begin, end) }
}
#[doc(alias = "g_random_set_seed")]
pub fn random_set_seed(seed: u32) {
unsafe {
ffi::g_random_set_seed(seed);
}
}
#[doc(alias = "g_reload_user_special_dirs_cache")]
pub fn reload_user_special_dirs_cache() {
unsafe {
ffi::g_reload_user_special_dirs_cache();
}
}
#[doc(alias = "g_set_application_name")]
pub fn set_application_name(application_name: &str) {
unsafe {
ffi::g_set_application_name(application_name.to_glib_none().0);
}
}
#[doc(alias = "g_setenv")]
pub fn setenv(
variable: impl AsRef<std::ffi::OsStr>,
value: impl AsRef<std::ffi::OsStr>,
overwrite: bool,
) -> Result<(), crate::error::BoolError> {
unsafe {
crate::result_from_gboolean!(
ffi::g_setenv(
variable.as_ref().to_glib_none().0,
value.as_ref().to_glib_none().0,
overwrite.into_glib()
),
"Failed to set environment variable"
)
}
}
#[doc(alias = "g_shell_parse_argv")]
pub fn shell_parse_argv(
command_line: impl AsRef<std::ffi::OsStr>,
) -> Result<Vec<std::ffi::OsString>, crate::Error> {
unsafe {
let mut argcp = mem::MaybeUninit::uninit();
let mut argvp = ptr::null_mut();
let mut error = ptr::null_mut();
let is_ok = ffi::g_shell_parse_argv(
command_line.as_ref().to_glib_none().0,
argcp.as_mut_ptr(),
&mut argvp,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(FromGlibContainer::from_glib_full_num(
argvp,
argcp.assume_init() as _,
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_shell_quote")]
pub fn shell_quote(unquoted_string: impl AsRef<std::ffi::OsStr>) -> std::ffi::OsString {
unsafe {
from_glib_full(ffi::g_shell_quote(
unquoted_string.as_ref().to_glib_none().0,
))
}
}
#[doc(alias = "g_shell_unquote")]
pub fn shell_unquote(
quoted_string: impl AsRef<std::ffi::OsStr>,
) -> Result<std::ffi::OsString, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_shell_unquote(quoted_string.as_ref().to_glib_none().0, &mut error);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_spaced_primes_closest")]
pub fn spaced_primes_closest(num: u32) -> u32 {
unsafe { ffi::g_spaced_primes_closest(num) }
}
#[doc(alias = "g_spawn_async")]
pub fn spawn_async(
working_directory: Option<impl AsRef<std::path::Path>>,
argv: &[&std::path::Path],
envp: &[&std::path::Path],
flags: SpawnFlags,
child_setup: Option<Box_<dyn FnOnce() + 'static>>,
) -> Result<Pid, crate::Error> {
let child_setup_data: Box_<Option<Box_<dyn FnOnce() + 'static>>> = Box_::new(child_setup);
unsafe extern "C" fn child_setup_func(data: ffi::gpointer) {
let callback: Box_<Option<Box_<dyn FnOnce() + 'static>>> = Box_::from_raw(data as *mut _);
let callback = (*callback).expect("cannot get closure...");
callback()
}
let child_setup = if child_setup_data.is_some() {
Some(child_setup_func as _)
} else {
None
};
let super_callback0: Box_<Option<Box_<dyn FnOnce() + 'static>>> = child_setup_data;
unsafe {
let mut child_pid = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let is_ok = ffi::g_spawn_async(
working_directory
.as_ref()
.map(|p| p.as_ref())
.to_glib_none()
.0,
argv.to_glib_none().0,
envp.to_glib_none().0,
flags.into_glib(),
child_setup,
Box_::into_raw(super_callback0) as *mut _,
child_pid.as_mut_ptr(),
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(from_glib(child_pid.assume_init()))
} else {
Err(from_glib_full(error))
}
}
}
//#[cfg(feature = "v2_68")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
//#[doc(alias = "g_spawn_async_with_pipes_and_fds")]
//pub fn spawn_async_with_pipes_and_fds(working_directory: Option<impl AsRef<std::path::Path>>, argv: &[&std::path::Path], envp: &[&std::path::Path], flags: SpawnFlags, child_setup: Option<Box_<dyn FnOnce() + 'static>>, stdin_fd: i32, stdout_fd: i32, stderr_fd: i32, source_fds: &[i32], target_fds: &[i32], n_fds: usize) -> Result<(Pid, i32, i32, i32), crate::Error> {
// unsafe { TODO: call ffi:g_spawn_async_with_pipes_and_fds() }
//}
#[cfg_attr(feature = "v2_70", deprecated = "Since 2.70")]
#[allow(deprecated)]
#[doc(alias = "g_spawn_check_exit_status")]
pub fn spawn_check_exit_status(wait_status: i32) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_spawn_check_exit_status(wait_status, &mut error);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[cfg(feature = "v2_70")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))]
#[doc(alias = "g_spawn_check_wait_status")]
pub fn spawn_check_wait_status(wait_status: i32) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_spawn_check_wait_status(wait_status, &mut error);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[cfg(unix)]
#[cfg_attr(docsrs, doc(cfg(unix)))]
#[doc(alias = "g_spawn_command_line_async")]
pub fn spawn_command_line_async(
command_line: impl AsRef<std::ffi::OsStr>,
) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok =
ffi::g_spawn_command_line_async(command_line.as_ref().to_glib_none().0, &mut error);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
//#[doc(alias = "g_spawn_command_line_sync")]
//pub fn spawn_command_line_sync(command_line: impl AsRef<std::path::Path>, standard_output: Vec<u8>, standard_error: Vec<u8>) -> Result<i32, crate::Error> {
// unsafe { TODO: call ffi:g_spawn_command_line_sync() }
//}
//#[doc(alias = "g_spawn_sync")]
//pub fn spawn_sync(working_directory: Option<impl AsRef<std::path::Path>>, argv: &[&std::path::Path], envp: &[&std::path::Path], flags: SpawnFlags, child_setup: Option<&mut dyn (FnMut())>, standard_output: Vec<u8>, standard_error: Vec<u8>) -> Result<i32, crate::Error> {
// unsafe { TODO: call ffi:g_spawn_sync() }
//}
#[doc(alias = "g_unicode_script_from_iso15924")]
pub fn unicode_script_from_iso15924(iso15924: u32) -> UnicodeScript {
unsafe { from_glib(ffi::g_unicode_script_from_iso15924(iso15924)) }
}
#[doc(alias = "g_unicode_script_to_iso15924")]
pub fn unicode_script_to_iso15924(script: UnicodeScript) -> u32 {
unsafe { ffi::g_unicode_script_to_iso15924(script.into_glib()) }
}
//#[cfg(unix)]
//#[cfg_attr(docsrs, doc(cfg(unix)))]
//#[cfg(feature = "v2_64")]
//#[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))]
//#[doc(alias = "g_unix_get_passwd_entry")]
//pub fn unix_get_passwd_entry(user_name: &str) -> Result</*Unimplemented*/Option<Basic: Pointer>, crate::Error> {
// unsafe { TODO: call ffi:g_unix_get_passwd_entry() }
//}
#[doc(alias = "g_unlink")]
pub fn unlink(filename: impl AsRef<std::path::Path>) -> i32 {
unsafe { ffi::g_unlink(filename.as_ref().to_glib_none().0) }
}
#[doc(alias = "g_unsetenv")]
pub fn unsetenv(variable: impl AsRef<std::ffi::OsStr>) {
unsafe {
ffi::g_unsetenv(variable.as_ref().to_glib_none().0);
}
}
#[doc(alias = "g_usleep")]
pub fn usleep(microseconds: libc::c_ulong) {
unsafe {
ffi::g_usleep(microseconds);
}
}
#[doc(alias = "g_uuid_string_is_valid")]
pub fn uuid_string_is_valid(str: &str) -> bool {
unsafe { from_glib(ffi::g_uuid_string_is_valid(str.to_glib_none().0)) }
}
#[doc(alias = "g_uuid_string_random")]
pub fn uuid_string_random() -> crate::GString {
unsafe { from_glib_full(ffi::g_uuid_string_random()) }
}
+487
View File
@@ -0,0 +1,487 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, Bytes, Error, KeyFileFlags};
use std::{mem, ptr};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KeyFile(Shared<ffi::GKeyFile>);
match fn {
ref => |ptr| ffi::g_key_file_ref(ptr),
unref => |ptr| ffi::g_key_file_unref(ptr),
type_ => || ffi::g_key_file_get_type(),
}
}
impl KeyFile {
#[doc(alias = "g_key_file_new")]
pub fn new() -> KeyFile {
unsafe { from_glib_full(ffi::g_key_file_new()) }
}
#[doc(alias = "g_key_file_get_comment")]
#[doc(alias = "get_comment")]
pub fn comment(
&self,
group_name: Option<&str>,
key: Option<&str>,
) -> Result<crate::GString, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_comment(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_double")]
#[doc(alias = "get_double")]
pub fn double(&self, group_name: &str, key: &str) -> Result<f64, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_double(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_double_list")]
#[doc(alias = "get_double_list")]
pub fn double_list(&self, group_name: &str, key: &str) -> Result<Vec<f64>, crate::Error> {
unsafe {
let mut length = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_double_list(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
length.as_mut_ptr(),
&mut error,
);
if error.is_null() {
Ok(FromGlibContainer::from_glib_container_num(
ret,
length.assume_init() as _,
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_int64")]
#[doc(alias = "get_int64")]
pub fn int64(&self, group_name: &str, key: &str) -> Result<i64, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_int64(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_integer")]
#[doc(alias = "get_integer")]
pub fn integer(&self, group_name: &str, key: &str) -> Result<i32, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_integer(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_integer_list")]
#[doc(alias = "get_integer_list")]
pub fn integer_list(&self, group_name: &str, key: &str) -> Result<Vec<i32>, crate::Error> {
unsafe {
let mut length = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_integer_list(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
length.as_mut_ptr(),
&mut error,
);
if error.is_null() {
Ok(FromGlibContainer::from_glib_container_num(
ret,
length.assume_init() as _,
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_locale_for_key")]
#[doc(alias = "get_locale_for_key")]
pub fn locale_for_key(
&self,
group_name: &str,
key: &str,
locale: Option<&str>,
) -> Option<crate::GString> {
unsafe {
from_glib_full(ffi::g_key_file_get_locale_for_key(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
locale.to_glib_none().0,
))
}
}
#[doc(alias = "g_key_file_get_start_group")]
#[doc(alias = "get_start_group")]
pub fn start_group(&self) -> Option<crate::GString> {
unsafe { from_glib_full(ffi::g_key_file_get_start_group(self.to_glib_none().0)) }
}
#[doc(alias = "g_key_file_get_uint64")]
#[doc(alias = "get_uint64")]
pub fn uint64(&self, group_name: &str, key: &str) -> Result<u64, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_uint64(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(ret)
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_get_value")]
#[doc(alias = "get_value")]
pub fn value(&self, group_name: &str, key: &str) -> Result<crate::GString, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_key_file_get_value(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_has_group")]
pub fn has_group(&self, group_name: &str) -> bool {
unsafe {
from_glib(ffi::g_key_file_has_group(
self.to_glib_none().0,
group_name.to_glib_none().0,
))
}
}
#[doc(alias = "g_key_file_load_from_bytes")]
pub fn load_from_bytes(&self, bytes: &Bytes, flags: KeyFileFlags) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_load_from_bytes(
self.to_glib_none().0,
bytes.to_glib_none().0,
flags.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_load_from_data")]
pub fn load_from_data(&self, data: &str, flags: KeyFileFlags) -> Result<(), crate::Error> {
let length = data.len() as _;
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_load_from_data(
self.to_glib_none().0,
data.to_glib_none().0,
length,
flags.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_load_from_file")]
pub fn load_from_file(
&self,
file: impl AsRef<std::path::Path>,
flags: KeyFileFlags,
) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_load_from_file(
self.to_glib_none().0,
file.as_ref().to_glib_none().0,
flags.into_glib(),
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_remove_comment")]
pub fn remove_comment(
&self,
group_name: Option<&str>,
key: Option<&str>,
) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_remove_comment(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_remove_group")]
pub fn remove_group(&self, group_name: &str) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_remove_group(
self.to_glib_none().0,
group_name.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_remove_key")]
pub fn remove_key(&self, group_name: &str, key: &str) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_remove_key(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_set_boolean")]
pub fn set_boolean(&self, group_name: &str, key: &str, value: bool) {
unsafe {
ffi::g_key_file_set_boolean(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value.into_glib(),
);
}
}
//#[doc(alias = "g_key_file_set_boolean_list")]
//pub fn set_boolean_list(&self, group_name: &str, key: &str, list: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 1 }) {
// unsafe { TODO: call ffi:g_key_file_set_boolean_list() }
//}
#[doc(alias = "g_key_file_set_comment")]
pub fn set_comment(
&self,
group_name: Option<&str>,
key: Option<&str>,
comment: &str,
) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_key_file_set_comment(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
comment.to_glib_none().0,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_key_file_set_double")]
pub fn set_double(&self, group_name: &str, key: &str, value: f64) {
unsafe {
ffi::g_key_file_set_double(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value,
);
}
}
#[doc(alias = "g_key_file_set_int64")]
pub fn set_int64(&self, group_name: &str, key: &str, value: i64) {
unsafe {
ffi::g_key_file_set_int64(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value,
);
}
}
#[doc(alias = "g_key_file_set_integer")]
pub fn set_integer(&self, group_name: &str, key: &str, value: i32) {
unsafe {
ffi::g_key_file_set_integer(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value,
);
}
}
#[doc(alias = "g_key_file_set_list_separator")]
pub fn set_list_separator(&self, separator: crate::Char) {
unsafe {
ffi::g_key_file_set_list_separator(self.to_glib_none().0, separator.into_glib());
}
}
#[doc(alias = "g_key_file_set_locale_string")]
pub fn set_locale_string(&self, group_name: &str, key: &str, locale: &str, string: &str) {
unsafe {
ffi::g_key_file_set_locale_string(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
locale.to_glib_none().0,
string.to_glib_none().0,
);
}
}
#[doc(alias = "g_key_file_set_string")]
pub fn set_string(&self, group_name: &str, key: &str, string: &str) {
unsafe {
ffi::g_key_file_set_string(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
string.to_glib_none().0,
);
}
}
#[doc(alias = "g_key_file_set_uint64")]
pub fn set_uint64(&self, group_name: &str, key: &str, value: u64) {
unsafe {
ffi::g_key_file_set_uint64(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value,
);
}
}
#[doc(alias = "g_key_file_set_value")]
pub fn set_value(&self, group_name: &str, key: &str, value: &str) {
unsafe {
ffi::g_key_file_set_value(
self.to_glib_none().0,
group_name.to_glib_none().0,
key.to_glib_none().0,
value.to_glib_none().0,
);
}
}
}
impl Default for KeyFile {
fn default() -> Self {
Self::new()
}
}
@@ -0,0 +1,142 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::translate::*;
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
use crate::MainContextFlags;
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MainContext(Shared<ffi::GMainContext>);
match fn {
ref => |ptr| ffi::g_main_context_ref(ptr),
unref => |ptr| ffi::g_main_context_unref(ptr),
type_ => || ffi::g_main_context_get_type(),
}
}
impl MainContext {
#[doc(alias = "g_main_context_new")]
pub fn new() -> MainContext {
unsafe { from_glib_full(ffi::g_main_context_new()) }
}
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
#[doc(alias = "g_main_context_new_with_flags")]
#[doc(alias = "new_with_flags")]
pub fn with_flags(flags: MainContextFlags) -> MainContext {
unsafe { from_glib_full(ffi::g_main_context_new_with_flags(flags.into_glib())) }
}
//#[doc(alias = "g_main_context_add_poll")]
//pub fn add_poll(&self, fd: /*Ignored*/&mut PollFD, priority: i32) {
// unsafe { TODO: call ffi:g_main_context_add_poll() }
//}
//#[doc(alias = "g_main_context_check")]
//pub fn check(&self, max_priority: i32, fds: /*Ignored*/&[PollFD]) -> bool {
// unsafe { TODO: call ffi:g_main_context_check() }
//}
#[doc(alias = "g_main_context_dispatch")]
pub fn dispatch(&self) {
unsafe {
ffi::g_main_context_dispatch(self.to_glib_none().0);
}
}
//#[doc(alias = "g_main_context_find_source_by_funcs_user_data")]
//pub fn find_source_by_funcs_user_data(&self, funcs: /*Ignored*/&mut SourceFuncs, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> Source {
// unsafe { TODO: call ffi:g_main_context_find_source_by_funcs_user_data() }
//}
//#[doc(alias = "g_main_context_find_source_by_user_data")]
//pub fn find_source_by_user_data(&self, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> Source {
// unsafe { TODO: call ffi:g_main_context_find_source_by_user_data() }
//}
//#[doc(alias = "g_main_context_get_poll_func")]
//#[doc(alias = "get_poll_func")]
//pub fn poll_func(&self) -> /*Unimplemented*/Fn(/*Ignored*/PollFD, u32) -> i32 {
// unsafe { TODO: call ffi:g_main_context_get_poll_func() }
//}
#[doc(alias = "g_main_context_is_owner")]
pub fn is_owner(&self) -> bool {
unsafe { from_glib(ffi::g_main_context_is_owner(self.to_glib_none().0)) }
}
#[doc(alias = "g_main_context_iteration")]
pub fn iteration(&self, may_block: bool) -> bool {
unsafe {
from_glib(ffi::g_main_context_iteration(
self.to_glib_none().0,
may_block.into_glib(),
))
}
}
#[doc(alias = "g_main_context_pending")]
pub fn pending(&self) -> bool {
unsafe { from_glib(ffi::g_main_context_pending(self.to_glib_none().0)) }
}
//#[doc(alias = "g_main_context_query")]
//pub fn query(&self, max_priority: i32, fds: /*Ignored*/Vec<PollFD>) -> (i32, i32) {
// unsafe { TODO: call ffi:g_main_context_query() }
//}
//#[doc(alias = "g_main_context_remove_poll")]
//pub fn remove_poll(&self, fd: /*Ignored*/&mut PollFD) {
// unsafe { TODO: call ffi:g_main_context_remove_poll() }
//}
//#[doc(alias = "g_main_context_set_poll_func")]
//pub fn set_poll_func(&self, func: /*Unimplemented*/Fn(/*Ignored*/PollFD, u32) -> i32) {
// unsafe { TODO: call ffi:g_main_context_set_poll_func() }
//}
//#[cfg_attr(feature = "v2_58", deprecated = "Since 2.58")]
//#[allow(deprecated)]
//#[doc(alias = "g_main_context_wait")]
//pub fn wait(&self, cond: /*Ignored*/&mut Cond, mutex: /*Ignored*/&mut Mutex) -> bool {
// unsafe { TODO: call ffi:g_main_context_wait() }
//}
#[doc(alias = "g_main_context_wakeup")]
pub fn wakeup(&self) {
unsafe {
ffi::g_main_context_wakeup(self.to_glib_none().0);
}
}
#[doc(alias = "g_main_context_default")]
#[allow(clippy::should_implement_trait)]
pub fn default() -> MainContext {
unsafe { from_glib_none(ffi::g_main_context_default()) }
}
#[doc(alias = "g_main_context_get_thread_default")]
#[doc(alias = "get_thread_default")]
pub fn thread_default() -> Option<MainContext> {
unsafe { from_glib_none(ffi::g_main_context_get_thread_default()) }
}
#[doc(alias = "g_main_context_ref_thread_default")]
pub fn ref_thread_default() -> MainContext {
unsafe { from_glib_full(ffi::g_main_context_ref_thread_default()) }
}
}
impl Default for MainContext {
fn default() -> Self {
Self::new()
}
}
unsafe impl Send for MainContext {}
unsafe impl Sync for MainContext {}
@@ -0,0 +1,56 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, MainContext};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MainLoop(Shared<ffi::GMainLoop>);
match fn {
ref => |ptr| ffi::g_main_loop_ref(ptr),
unref => |ptr| ffi::g_main_loop_unref(ptr),
type_ => || ffi::g_main_loop_get_type(),
}
}
impl MainLoop {
#[doc(alias = "g_main_loop_new")]
pub fn new(context: Option<&MainContext>, is_running: bool) -> MainLoop {
unsafe {
from_glib_full(ffi::g_main_loop_new(
context.to_glib_none().0,
is_running.into_glib(),
))
}
}
#[doc(alias = "g_main_loop_get_context")]
#[doc(alias = "get_context")]
pub fn context(&self) -> MainContext {
unsafe { from_glib_none(ffi::g_main_loop_get_context(self.to_glib_none().0)) }
}
#[doc(alias = "g_main_loop_is_running")]
pub fn is_running(&self) -> bool {
unsafe { from_glib(ffi::g_main_loop_is_running(self.to_glib_none().0)) }
}
#[doc(alias = "g_main_loop_quit")]
pub fn quit(&self) {
unsafe {
ffi::g_main_loop_quit(self.to_glib_none().0);
}
}
#[doc(alias = "g_main_loop_run")]
pub fn run(&self) {
unsafe {
ffi::g_main_loop_run(self.to_glib_none().0);
}
}
}
unsafe impl Send for MainLoop {}
unsafe impl Sync for MainLoop {}
@@ -0,0 +1,99 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, Error};
use std::{mem, ptr};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct MarkupParseContext(Shared<ffi::GMarkupParseContext>);
match fn {
ref => |ptr| ffi::g_markup_parse_context_ref(ptr),
unref => |ptr| ffi::g_markup_parse_context_unref(ptr),
type_ => || ffi::g_markup_parse_context_get_type(),
}
}
impl MarkupParseContext {
//#[doc(alias = "g_markup_parse_context_new")]
//pub fn new(parser: /*Ignored*/&MarkupParser, flags: /*Ignored*/MarkupParseFlags, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> MarkupParseContext {
// unsafe { TODO: call ffi:g_markup_parse_context_new() }
//}
#[doc(alias = "g_markup_parse_context_end_parse")]
pub fn end_parse(&self) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_markup_parse_context_end_parse(self.to_glib_none().0, &mut error);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_markup_parse_context_get_element")]
#[doc(alias = "get_element")]
pub fn element(&self) -> crate::GString {
unsafe {
from_glib_none(ffi::g_markup_parse_context_get_element(
self.to_glib_none().0,
))
}
}
//#[doc(alias = "g_markup_parse_context_get_element_stack")]
//#[doc(alias = "get_element_stack")]
//pub fn element_stack(&self) -> /*Unimplemented*/Vec<Basic: Pointer> {
// unsafe { TODO: call ffi:g_markup_parse_context_get_element_stack() }
//}
#[doc(alias = "g_markup_parse_context_get_position")]
#[doc(alias = "get_position")]
pub fn position(&self) -> (i32, i32) {
unsafe {
let mut line_number = mem::MaybeUninit::uninit();
let mut char_number = mem::MaybeUninit::uninit();
ffi::g_markup_parse_context_get_position(
self.to_glib_none().0,
line_number.as_mut_ptr(),
char_number.as_mut_ptr(),
);
(line_number.assume_init(), char_number.assume_init())
}
}
#[doc(alias = "g_markup_parse_context_parse")]
pub fn parse(&self, text: &str) -> Result<(), crate::Error> {
let text_len = text.len() as _;
unsafe {
let mut error = ptr::null_mut();
let is_ok = ffi::g_markup_parse_context_parse(
self.to_glib_none().0,
text.to_glib_none().0,
text_len,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
//#[doc(alias = "g_markup_parse_context_pop")]
//pub fn pop(&self) -> /*Unimplemented*/Option<Basic: Pointer> {
// unsafe { TODO: call ffi:g_markup_parse_context_pop() }
//}
//#[doc(alias = "g_markup_parse_context_push")]
//pub fn push(&self, parser: /*Ignored*/&MarkupParser, user_data: /*Unimplemented*/Option<Basic: Pointer>) {
// unsafe { TODO: call ffi:g_markup_parse_context_push() }
//}
}
+123
View File
@@ -0,0 +1,123 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
mod checksum;
pub use self::checksum::Checksum;
mod date_time;
pub use self::date_time::DateTime;
mod key_file;
pub use self::key_file::KeyFile;
mod main_context;
pub use self::main_context::MainContext;
mod main_loop;
pub use self::main_loop::MainLoop;
mod markup_parse_context;
pub use self::markup_parse_context::MarkupParseContext;
mod source;
pub use self::source::Source;
mod time_zone;
pub use self::time_zone::TimeZone;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
mod uri;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::uri::Uri;
mod enums;
pub use self::enums::ChecksumType;
pub use self::enums::ConvertError;
pub use self::enums::DateMonth;
pub use self::enums::DateWeekday;
pub use self::enums::FileError;
pub use self::enums::KeyFileError;
pub use self::enums::LogWriterOutput;
pub use self::enums::MarkupError;
pub use self::enums::NormalizeMode;
pub use self::enums::OptionArg;
pub use self::enums::SeekType;
pub use self::enums::TimeType;
pub use self::enums::UnicodeBreakType;
pub use self::enums::UnicodeScript;
pub use self::enums::UnicodeType;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::enums::UriError;
pub use self::enums::VariantClass;
mod flags;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::flags::FileSetContentsFlags;
pub(crate) use self::flags::FileTest;
pub use self::flags::FormatSizeFlags;
pub use self::flags::IOCondition;
pub use self::flags::KeyFileFlags;
pub use self::flags::LogLevelFlags;
#[cfg(feature = "v2_72")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))]
pub use self::flags::MainContextFlags;
pub use self::flags::OptionFlags;
pub use self::flags::SpawnFlags;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::flags::UriFlags;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::flags::UriHideFlags;
#[cfg(feature = "v2_66")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))]
pub use self::flags::UriParamsFlags;
mod alias;
pub use self::alias::DateDay;
pub use self::alias::DateYear;
pub use self::alias::Time;
pub mod functions;
mod constants;
pub use self::constants::CSET_a_2_z;
pub use self::constants::CSET_A_2_Z;
pub use self::constants::CSET_DIGITS;
pub use self::constants::KEY_FILE_DESKTOP_GROUP;
pub use self::constants::KEY_FILE_DESKTOP_KEY_ACTIONS;
pub use self::constants::KEY_FILE_DESKTOP_KEY_CATEGORIES;
pub use self::constants::KEY_FILE_DESKTOP_KEY_COMMENT;
pub use self::constants::KEY_FILE_DESKTOP_KEY_DBUS_ACTIVATABLE;
pub use self::constants::KEY_FILE_DESKTOP_KEY_EXEC;
pub use self::constants::KEY_FILE_DESKTOP_KEY_GENERIC_NAME;
pub use self::constants::KEY_FILE_DESKTOP_KEY_HIDDEN;
pub use self::constants::KEY_FILE_DESKTOP_KEY_ICON;
pub use self::constants::KEY_FILE_DESKTOP_KEY_MIME_TYPE;
pub use self::constants::KEY_FILE_DESKTOP_KEY_NAME;
pub use self::constants::KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN;
pub use self::constants::KEY_FILE_DESKTOP_KEY_NO_DISPLAY;
pub use self::constants::KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN;
pub use self::constants::KEY_FILE_DESKTOP_KEY_PATH;
pub use self::constants::KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY;
pub use self::constants::KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS;
pub use self::constants::KEY_FILE_DESKTOP_KEY_TERMINAL;
pub use self::constants::KEY_FILE_DESKTOP_KEY_TRY_EXEC;
pub use self::constants::KEY_FILE_DESKTOP_KEY_TYPE;
pub use self::constants::KEY_FILE_DESKTOP_KEY_URL;
pub use self::constants::KEY_FILE_DESKTOP_KEY_VERSION;
pub use self::constants::KEY_FILE_DESKTOP_TYPE_APPLICATION;
pub use self::constants::KEY_FILE_DESKTOP_TYPE_DIRECTORY;
pub use self::constants::KEY_FILE_DESKTOP_TYPE_LINK;
pub use self::constants::OPTION_REMAINING;
pub use self::constants::STR_DELIMITERS;
#[cfg(feature = "v2_60")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))]
pub use self::constants::TEST_OPTION_ISOLATE_DIRS;
pub use self::constants::URI_RESERVED_CHARS_GENERIC_DELIMITERS;
pub use self::constants::URI_RESERVED_CHARS_SUBCOMPONENT_DELIMITERS;
+128
View File
@@ -0,0 +1,128 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, MainContext};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Source(Shared<ffi::GSource>);
match fn {
ref => |ptr| ffi::g_source_ref(ptr),
unref => |ptr| ffi::g_source_unref(ptr),
type_ => || ffi::g_source_get_type(),
}
}
impl Source {
//#[doc(alias = "g_source_new")]
//pub fn new(source_funcs: /*Ignored*/&mut SourceFuncs, struct_size: u32) -> Source {
// unsafe { TODO: call ffi:g_source_new() }
//}
#[doc(alias = "g_source_add_child_source")]
pub fn add_child_source(&self, child_source: &Source) {
unsafe {
ffi::g_source_add_child_source(self.to_glib_none().0, child_source.to_glib_none().0);
}
}
//#[doc(alias = "g_source_add_poll")]
//pub fn add_poll(&self, fd: /*Ignored*/&mut PollFD) {
// unsafe { TODO: call ffi:g_source_add_poll() }
//}
//#[doc(alias = "g_source_add_unix_fd")]
//pub fn add_unix_fd(&self, fd: i32, events: IOCondition) -> /*Unimplemented*/Basic: Pointer {
// unsafe { TODO: call ffi:g_source_add_unix_fd() }
//}
#[doc(alias = "g_source_destroy")]
pub fn destroy(&self) {
unsafe {
ffi::g_source_destroy(self.to_glib_none().0);
}
}
#[doc(alias = "g_source_get_can_recurse")]
#[doc(alias = "get_can_recurse")]
pub fn can_recurse(&self) -> bool {
unsafe { from_glib(ffi::g_source_get_can_recurse(self.to_glib_none().0)) }
}
#[doc(alias = "g_source_get_context")]
#[doc(alias = "get_context")]
pub fn context(&self) -> Option<MainContext> {
unsafe { from_glib_none(ffi::g_source_get_context(self.to_glib_none().0)) }
}
#[doc(alias = "g_source_get_name")]
#[doc(alias = "get_name")]
pub fn name(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_source_get_name(self.to_glib_none().0)) }
}
#[doc(alias = "g_source_get_priority")]
#[doc(alias = "get_priority")]
pub fn priority(&self) -> i32 {
unsafe { ffi::g_source_get_priority(self.to_glib_none().0) }
}
#[doc(alias = "g_source_get_ready_time")]
#[doc(alias = "get_ready_time")]
pub fn ready_time(&self) -> i64 {
unsafe { ffi::g_source_get_ready_time(self.to_glib_none().0) }
}
#[doc(alias = "g_source_get_time")]
#[doc(alias = "get_time")]
pub fn time(&self) -> i64 {
unsafe { ffi::g_source_get_time(self.to_glib_none().0) }
}
#[doc(alias = "g_source_is_destroyed")]
pub fn is_destroyed(&self) -> bool {
unsafe { from_glib(ffi::g_source_is_destroyed(self.to_glib_none().0)) }
}
//#[doc(alias = "g_source_modify_unix_fd")]
//pub fn modify_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer, new_events: IOCondition) {
// unsafe { TODO: call ffi:g_source_modify_unix_fd() }
//}
//#[doc(alias = "g_source_query_unix_fd")]
//pub fn query_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer) -> IOCondition {
// unsafe { TODO: call ffi:g_source_query_unix_fd() }
//}
#[doc(alias = "g_source_remove_child_source")]
pub fn remove_child_source(&self, child_source: &Source) {
unsafe {
ffi::g_source_remove_child_source(self.to_glib_none().0, child_source.to_glib_none().0);
}
}
//#[doc(alias = "g_source_remove_poll")]
//pub fn remove_poll(&self, fd: /*Ignored*/&mut PollFD) {
// unsafe { TODO: call ffi:g_source_remove_poll() }
//}
//#[doc(alias = "g_source_remove_unix_fd")]
//pub fn remove_unix_fd(&self, tag: /*Unimplemented*/Basic: Pointer) {
// unsafe { TODO: call ffi:g_source_remove_unix_fd() }
//}
//#[doc(alias = "g_source_remove_by_funcs_user_data")]
//pub fn remove_by_funcs_user_data(funcs: /*Ignored*/&mut SourceFuncs, user_data: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
// unsafe { TODO: call ffi:g_source_remove_by_funcs_user_data() }
//}
//#[doc(alias = "g_source_remove_by_user_data")]
//pub fn remove_by_user_data(user_data: /*Unimplemented*/Option<Basic: Pointer>) -> bool {
// unsafe { TODO: call ffi:g_source_remove_by_user_data() }
//}
}
unsafe impl Send for Source {}
unsafe impl Sync for Source {}
@@ -0,0 +1,91 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, TimeType};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct TimeZone(Shared<ffi::GTimeZone>);
match fn {
ref => |ptr| ffi::g_time_zone_ref(ptr),
unref => |ptr| ffi::g_time_zone_unref(ptr),
type_ => || ffi::g_time_zone_get_type(),
}
}
impl TimeZone {
#[cfg_attr(feature = "v2_68", deprecated = "Since 2.68")]
#[allow(deprecated)]
#[doc(alias = "g_time_zone_new")]
pub fn new(identifier: Option<&str>) -> TimeZone {
unsafe { from_glib_full(ffi::g_time_zone_new(identifier.to_glib_none().0)) }
}
#[cfg(feature = "v2_68")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))]
#[doc(alias = "g_time_zone_new_identifier")]
#[doc(alias = "new_identifier")]
pub fn from_identifier(identifier: Option<&str>) -> Option<TimeZone> {
unsafe { from_glib_full(ffi::g_time_zone_new_identifier(identifier.to_glib_none().0)) }
}
#[doc(alias = "g_time_zone_new_local")]
#[doc(alias = "new_local")]
pub fn local() -> TimeZone {
unsafe { from_glib_full(ffi::g_time_zone_new_local()) }
}
#[cfg(feature = "v2_58")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
#[doc(alias = "g_time_zone_new_offset")]
#[doc(alias = "new_offset")]
pub fn from_offset(seconds: i32) -> TimeZone {
unsafe { from_glib_full(ffi::g_time_zone_new_offset(seconds)) }
}
#[doc(alias = "g_time_zone_new_utc")]
#[doc(alias = "new_utc")]
pub fn utc() -> TimeZone {
unsafe { from_glib_full(ffi::g_time_zone_new_utc()) }
}
#[doc(alias = "g_time_zone_find_interval")]
pub fn find_interval(&self, type_: TimeType, time_: i64) -> i32 {
unsafe { ffi::g_time_zone_find_interval(self.to_glib_none().0, type_.into_glib(), time_) }
}
#[doc(alias = "g_time_zone_get_abbreviation")]
#[doc(alias = "get_abbreviation")]
pub fn abbreviation(&self, interval: i32) -> crate::GString {
unsafe {
from_glib_none(ffi::g_time_zone_get_abbreviation(
self.to_glib_none().0,
interval,
))
}
}
#[cfg(feature = "v2_58")]
#[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))]
#[doc(alias = "g_time_zone_get_identifier")]
#[doc(alias = "get_identifier")]
pub fn identifier(&self) -> crate::GString {
unsafe { from_glib_none(ffi::g_time_zone_get_identifier(self.to_glib_none().0)) }
}
#[doc(alias = "g_time_zone_get_offset")]
#[doc(alias = "get_offset")]
pub fn offset(&self, interval: i32) -> i32 {
unsafe { ffi::g_time_zone_get_offset(self.to_glib_none().0, interval) }
}
#[doc(alias = "g_time_zone_is_dst")]
pub fn is_dst(&self, interval: i32) -> bool {
unsafe { from_glib(ffi::g_time_zone_is_dst(self.to_glib_none().0, interval)) }
}
}
unsafe impl Send for TimeZone {}
unsafe impl Sync for TimeZone {}
+535
View File
@@ -0,0 +1,535 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{translate::*, Bytes, Error, UriFlags, UriHideFlags};
use std::{fmt, mem, ptr};
crate::wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Uri(Shared<ffi::GUri>);
match fn {
ref => |ptr| ffi::g_uri_ref(ptr),
unref => |ptr| ffi::g_uri_unref(ptr),
type_ => || ffi::g_uri_get_type(),
}
}
impl Uri {
#[doc(alias = "g_uri_get_auth_params")]
#[doc(alias = "get_auth_params")]
pub fn auth_params(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_auth_params(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_flags")]
#[doc(alias = "get_flags")]
pub fn flags(&self) -> UriFlags {
unsafe { from_glib(ffi::g_uri_get_flags(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_fragment")]
#[doc(alias = "get_fragment")]
pub fn fragment(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_fragment(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_host")]
#[doc(alias = "get_host")]
pub fn host(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_host(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_password")]
#[doc(alias = "get_password")]
pub fn password(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_password(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_path")]
#[doc(alias = "get_path")]
pub fn path(&self) -> crate::GString {
unsafe { from_glib_none(ffi::g_uri_get_path(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_port")]
#[doc(alias = "get_port")]
pub fn port(&self) -> i32 {
unsafe { ffi::g_uri_get_port(self.to_glib_none().0) }
}
#[doc(alias = "g_uri_get_query")]
#[doc(alias = "get_query")]
pub fn query(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_query(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_scheme")]
#[doc(alias = "get_scheme")]
pub fn scheme(&self) -> crate::GString {
unsafe { from_glib_none(ffi::g_uri_get_scheme(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_user")]
#[doc(alias = "get_user")]
pub fn user(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_user(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_get_userinfo")]
#[doc(alias = "get_userinfo")]
pub fn userinfo(&self) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_get_userinfo(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_parse_relative")]
pub fn parse_relative(&self, uri_ref: &str, flags: UriFlags) -> Result<Uri, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_uri_parse_relative(
self.to_glib_none().0,
uri_ref.to_glib_none().0,
flags.into_glib(),
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_to_string")]
#[doc(alias = "to_string")]
pub fn to_str(&self) -> crate::GString {
unsafe { from_glib_full(ffi::g_uri_to_string(self.to_glib_none().0)) }
}
#[doc(alias = "g_uri_to_string_partial")]
pub fn to_string_partial(&self, flags: UriHideFlags) -> crate::GString {
unsafe {
from_glib_full(ffi::g_uri_to_string_partial(
self.to_glib_none().0,
flags.into_glib(),
))
}
}
#[doc(alias = "g_uri_build")]
pub fn build(
flags: UriFlags,
scheme: &str,
userinfo: Option<&str>,
host: Option<&str>,
port: i32,
path: &str,
query: Option<&str>,
fragment: Option<&str>,
) -> Uri {
unsafe {
from_glib_full(ffi::g_uri_build(
flags.into_glib(),
scheme.to_glib_none().0,
userinfo.to_glib_none().0,
host.to_glib_none().0,
port,
path.to_glib_none().0,
query.to_glib_none().0,
fragment.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_build_with_user")]
pub fn build_with_user(
flags: UriFlags,
scheme: &str,
user: Option<&str>,
password: Option<&str>,
auth_params: Option<&str>,
host: Option<&str>,
port: i32,
path: &str,
query: Option<&str>,
fragment: Option<&str>,
) -> Uri {
unsafe {
from_glib_full(ffi::g_uri_build_with_user(
flags.into_glib(),
scheme.to_glib_none().0,
user.to_glib_none().0,
password.to_glib_none().0,
auth_params.to_glib_none().0,
host.to_glib_none().0,
port,
path.to_glib_none().0,
query.to_glib_none().0,
fragment.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_escape_bytes")]
pub fn escape_bytes(unescaped: &[u8], reserved_chars_allowed: Option<&str>) -> crate::GString {
let length = unescaped.len() as _;
unsafe {
from_glib_full(ffi::g_uri_escape_bytes(
unescaped.to_glib_none().0,
length,
reserved_chars_allowed.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_escape_string")]
pub fn escape_string(
unescaped: &str,
reserved_chars_allowed: Option<&str>,
allow_utf8: bool,
) -> crate::GString {
unsafe {
from_glib_full(ffi::g_uri_escape_string(
unescaped.to_glib_none().0,
reserved_chars_allowed.to_glib_none().0,
allow_utf8.into_glib(),
))
}
}
#[doc(alias = "g_uri_is_valid")]
pub fn is_valid(uri_string: &str, flags: UriFlags) -> Result<(), crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let is_ok =
ffi::g_uri_is_valid(uri_string.to_glib_none().0, flags.into_glib(), &mut error);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok(())
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_join")]
pub fn join(
flags: UriFlags,
scheme: Option<&str>,
userinfo: Option<&str>,
host: Option<&str>,
port: i32,
path: &str,
query: Option<&str>,
fragment: Option<&str>,
) -> crate::GString {
unsafe {
from_glib_full(ffi::g_uri_join(
flags.into_glib(),
scheme.to_glib_none().0,
userinfo.to_glib_none().0,
host.to_glib_none().0,
port,
path.to_glib_none().0,
query.to_glib_none().0,
fragment.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_join_with_user")]
pub fn join_with_user(
flags: UriFlags,
scheme: Option<&str>,
user: Option<&str>,
password: Option<&str>,
auth_params: Option<&str>,
host: Option<&str>,
port: i32,
path: &str,
query: Option<&str>,
fragment: Option<&str>,
) -> crate::GString {
unsafe {
from_glib_full(ffi::g_uri_join_with_user(
flags.into_glib(),
scheme.to_glib_none().0,
user.to_glib_none().0,
password.to_glib_none().0,
auth_params.to_glib_none().0,
host.to_glib_none().0,
port,
path.to_glib_none().0,
query.to_glib_none().0,
fragment.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_list_extract_uris")]
pub fn list_extract_uris(uri_list: &str) -> Vec<crate::GString> {
unsafe {
FromGlibPtrContainer::from_glib_full(ffi::g_uri_list_extract_uris(
uri_list.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_parse")]
pub fn parse(uri_string: &str, flags: UriFlags) -> Result<Uri, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_uri_parse(uri_string.to_glib_none().0, flags.into_glib(), &mut error);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
//#[doc(alias = "g_uri_parse_params")]
//pub fn parse_params(params: &str, separators: &str, flags: UriParamsFlags) -> Result</*Unknown conversion*//*Unimplemented*/HashTable TypeId { ns_id: 0, id: 28 }/TypeId { ns_id: 0, id: 28 }, crate::Error> {
// unsafe { TODO: call ffi:g_uri_parse_params() }
//}
#[doc(alias = "g_uri_parse_scheme")]
pub fn parse_scheme(uri: &str) -> Option<crate::GString> {
unsafe { from_glib_full(ffi::g_uri_parse_scheme(uri.to_glib_none().0)) }
}
#[doc(alias = "g_uri_peek_scheme")]
pub fn peek_scheme(uri: &str) -> Option<crate::GString> {
unsafe { from_glib_none(ffi::g_uri_peek_scheme(uri.to_glib_none().0)) }
}
#[doc(alias = "g_uri_resolve_relative")]
pub fn resolve_relative(
base_uri_string: Option<&str>,
uri_ref: &str,
flags: UriFlags,
) -> Result<crate::GString, crate::Error> {
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_uri_resolve_relative(
base_uri_string.to_glib_none().0,
uri_ref.to_glib_none().0,
flags.into_glib(),
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_split")]
pub fn split(
uri_ref: &str,
flags: UriFlags,
) -> Result<
(
Option<crate::GString>,
Option<crate::GString>,
Option<crate::GString>,
i32,
crate::GString,
Option<crate::GString>,
Option<crate::GString>,
),
crate::Error,
> {
unsafe {
let mut scheme = ptr::null_mut();
let mut userinfo = ptr::null_mut();
let mut host = ptr::null_mut();
let mut port = mem::MaybeUninit::uninit();
let mut path = ptr::null_mut();
let mut query = ptr::null_mut();
let mut fragment = ptr::null_mut();
let mut error = ptr::null_mut();
let is_ok = ffi::g_uri_split(
uri_ref.to_glib_none().0,
flags.into_glib(),
&mut scheme,
&mut userinfo,
&mut host,
port.as_mut_ptr(),
&mut path,
&mut query,
&mut fragment,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok((
from_glib_full(scheme),
from_glib_full(userinfo),
from_glib_full(host),
port.assume_init(),
from_glib_full(path),
from_glib_full(query),
from_glib_full(fragment),
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_split_network")]
pub fn split_network(
uri_string: &str,
flags: UriFlags,
) -> Result<(Option<crate::GString>, Option<crate::GString>, i32), crate::Error> {
unsafe {
let mut scheme = ptr::null_mut();
let mut host = ptr::null_mut();
let mut port = mem::MaybeUninit::uninit();
let mut error = ptr::null_mut();
let is_ok = ffi::g_uri_split_network(
uri_string.to_glib_none().0,
flags.into_glib(),
&mut scheme,
&mut host,
port.as_mut_ptr(),
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok((
from_glib_full(scheme),
from_glib_full(host),
port.assume_init(),
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_split_with_user")]
pub fn split_with_user(
uri_ref: &str,
flags: UriFlags,
) -> Result<
(
Option<crate::GString>,
Option<crate::GString>,
Option<crate::GString>,
Option<crate::GString>,
Option<crate::GString>,
i32,
crate::GString,
Option<crate::GString>,
Option<crate::GString>,
),
crate::Error,
> {
unsafe {
let mut scheme = ptr::null_mut();
let mut user = ptr::null_mut();
let mut password = ptr::null_mut();
let mut auth_params = ptr::null_mut();
let mut host = ptr::null_mut();
let mut port = mem::MaybeUninit::uninit();
let mut path = ptr::null_mut();
let mut query = ptr::null_mut();
let mut fragment = ptr::null_mut();
let mut error = ptr::null_mut();
let is_ok = ffi::g_uri_split_with_user(
uri_ref.to_glib_none().0,
flags.into_glib(),
&mut scheme,
&mut user,
&mut password,
&mut auth_params,
&mut host,
port.as_mut_ptr(),
&mut path,
&mut query,
&mut fragment,
&mut error,
);
debug_assert_eq!(is_ok == crate::ffi::GFALSE, !error.is_null());
if error.is_null() {
Ok((
from_glib_full(scheme),
from_glib_full(user),
from_glib_full(password),
from_glib_full(auth_params),
from_glib_full(host),
port.assume_init(),
from_glib_full(path),
from_glib_full(query),
from_glib_full(fragment),
))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_unescape_bytes")]
pub fn unescape_bytes(
escaped_string: &str,
illegal_characters: Option<&str>,
) -> Result<Bytes, crate::Error> {
let length = escaped_string.len() as _;
unsafe {
let mut error = ptr::null_mut();
let ret = ffi::g_uri_unescape_bytes(
escaped_string.to_glib_none().0,
length,
illegal_characters.to_glib_none().0,
&mut error,
);
if error.is_null() {
Ok(from_glib_full(ret))
} else {
Err(from_glib_full(error))
}
}
}
#[doc(alias = "g_uri_unescape_segment")]
pub fn unescape_segment(
escaped_string: Option<&str>,
escaped_string_end: Option<&str>,
illegal_characters: Option<&str>,
) -> Option<crate::GString> {
unsafe {
from_glib_full(ffi::g_uri_unescape_segment(
escaped_string.to_glib_none().0,
escaped_string_end.to_glib_none().0,
illegal_characters.to_glib_none().0,
))
}
}
#[doc(alias = "g_uri_unescape_string")]
pub fn unescape_string(
escaped_string: &str,
illegal_characters: Option<&str>,
) -> Option<crate::GString> {
unsafe {
from_glib_full(ffi::g_uri_unescape_string(
escaped_string.to_glib_none().0,
illegal_characters.to_glib_none().0,
))
}
}
}
impl fmt::Display for Uri {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(&self.to_str())
}
}
unsafe impl Send for Uri {}
unsafe impl Sync for Uri {}
@@ -0,0 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ 23d7c100187c)
from gir-files (https://github.com/gtk-rs/gir-files @ 6415239ef435)