gio-0.20.1/.cargo_vcs_info.json0000644000000001410000000000100116660ustar { "git": { "sha1": "6f481a26fd6ba257e3af7acb83d1c090630de969" }, "path_in_vcs": "gio" }gio-0.20.1/COPYRIGHT000064400000000000000000000012131046102023000117520ustar 00000000000000The gtk-rs Project is licensed under the MIT license, see the LICENSE file or . Copyrights in the gtk-rs Project project are retained by their contributors. No copyright assignment is required to contribute to the gtk-rs Project project. For full authorship information, see the version control history. This project provides interoperability with various GNOME libraries but doesn't distribute any parts of them. Distributing compiled libraries and executables that link to those libraries may be subject to terms of the GNU LGPL or other licenses. For more information check the license of each GNOME library. gio-0.20.1/Cargo.toml0000644000000054220000000000100076730ustar # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies. # # If you are reading this file be aware that the original Cargo.toml # will likely look very different (and much more reasonable). # See Cargo.toml.orig for the original contents. [package] edition = "2021" rust-version = "1.70" name = "gio" version = "0.20.1" authors = ["The gtk-rs Project Developers"] build = "build.rs" exclude = ["gir-files/*"] autobins = false autoexamples = false autotests = false autobenches = false description = "Rust bindings for the Gio library" homepage = "https://gtk-rs.org/" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/" readme = "README.md" keywords = [ "glib", "gio", "gtk-rs", "gnome", ] license = "MIT" repository = "https://github.com/gtk-rs/gtk-rs-core" [package.metadata.docs.rs] all-features = true rustc-args = [ "--cfg", "docsrs", ] rustdoc-args = [ "--cfg", "docsrs", "--generate-link-to-definition", ] [lib] name = "gio" path = "src/lib.rs" [[test]] name = "check_gir" path = "tests/check_gir.rs" [[test]] name = "std_io_copy" path = "tests/std_io_copy.rs" [dependencies.futures-channel] version = "0.3" [dependencies.futures-core] version = "0.3" default-features = false [dependencies.futures-io] version = "0.3" [dependencies.futures-util] version = "0.3" default-features = false [dependencies.gio-sys] version = "0.20" [dependencies.glib] version = "0.20" [dependencies.libc] version = "0.2" [dependencies.pin-project-lite] version = "0.2" [dependencies.smallvec] version = "1" [dev-dependencies.futures] version = "0.3" [dev-dependencies.futures-util] version = "0.3" features = ["io"] [dev-dependencies.gir-format-check] version = "^0.1" [dev-dependencies.serial_test] version = "3" [features] v2_58 = [ "gio-sys/v2_58", "glib/v2_58", ] v2_60 = [ "v2_58", "gio-sys/v2_60", "glib/v2_60", ] v2_62 = [ "v2_60", "gio-sys/v2_62", "glib/v2_62", ] v2_64 = [ "v2_62", "gio-sys/v2_64", "glib/v2_64", ] v2_66 = [ "v2_64", "gio-sys/v2_66", "glib/v2_66", ] v2_68 = [ "v2_66", "gio-sys/v2_68", "glib/v2_68", ] v2_70 = [ "v2_68", "gio-sys/v2_70", "glib/v2_70", ] v2_72 = [ "v2_70", "gio-sys/v2_72", "glib/v2_72", ] v2_74 = [ "v2_72", "gio-sys/v2_74", "glib/v2_74", ] v2_76 = [ "v2_74", "gio-sys/v2_76", "glib/v2_76", ] v2_78 = [ "v2_76", "gio-sys/v2_78", "glib/v2_78", ] v2_80 = [ "v2_78", "gio-sys/v2_80", "glib/v2_80", ] v2_82 = [ "v2_80", "gio-sys/v2_82", "glib/v2_82", ] gio-0.20.1/Cargo.toml.orig000064400000000000000000000032221046102023000133500ustar 00000000000000[package] name = "gio" keywords = ["glib", "gio", "gtk-rs", "gnome"] readme = "README.md" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/" description = "Rust bindings for the Gio library" build = "build.rs" authors.workspace = true edition.workspace = true exclude.workspace = true homepage.workspace = true license.workspace = true repository.workspace = true rust-version.workspace = true version.workspace = true [lib] name = "gio" [features] v2_58 = ["gio-sys/v2_58", "glib/v2_58"] v2_60 = ["v2_58", "gio-sys/v2_60", "glib/v2_60"] v2_62 = ["v2_60", "gio-sys/v2_62", "glib/v2_62"] v2_64 = ["v2_62", "gio-sys/v2_64", "glib/v2_64"] v2_66 = ["v2_64", "gio-sys/v2_66", "glib/v2_66"] v2_68 = ["v2_66", "gio-sys/v2_68", "glib/v2_68"] v2_70 = ["v2_68", "gio-sys/v2_70", "glib/v2_70"] v2_72 = ["v2_70", "gio-sys/v2_72", "glib/v2_72"] v2_74 = ["v2_72", "gio-sys/v2_74", "glib/v2_74"] v2_76 = ["v2_74", "gio-sys/v2_76", "glib/v2_76"] v2_78 = ["v2_76", "gio-sys/v2_78", "glib/v2_78"] v2_80 = ["v2_78", "gio-sys/v2_80", "glib/v2_80"] v2_82 = ["v2_80", "gio-sys/v2_82", "glib/v2_82"] [dependencies] libc.workspace = true futures-core = { version = "0.3", default-features = false } futures-channel = "0.3" futures-io = "0.3" futures-util = { version = "0.3", default-features = false } gio-sys.workspace = true glib.workspace = true pin-project-lite = "0.2" smallvec = "1" [dev-dependencies] futures = "0.3" futures-util = { version = "0.3", features = ["io"] } gir-format-check.workspace = true serial_test = "3" [package.metadata.docs.rs] all-features = true rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] gio-0.20.1/Gir.toml000064400000000000000000001205311046102023000121020ustar 00000000000000[options] girs_directories = ["../gir-files"] library = "Gio" version = "2.0" min_cfg_version = "2.56" use_gi_docgen = true target_path = "." work_mode = "normal" single_version_file = true deprecate_by_min_version = true trust_return_value_nullability = true generate = [ "Gio.Action", "Gio.AppInfoCreateFlags", "Gio.AppInfoMonitor", "Gio.AskPasswordFlags", "Gio.AsyncResult", "Gio.BusNameOwnerFlags", "Gio.BusNameWatcherFlags", "Gio.BusType", "Gio.BytesIcon", "Gio.ConverterFlags", "Gio.ConverterResult", "Gio.DataStreamByteOrder", "Gio.DataStreamNewlineType", "Gio.DBusActionGroup", "Gio.DBusArgInfo", "Gio.DBusAuthObserver", "Gio.DBusCallFlags", "Gio.DBusCapabilityFlags", "Gio.DBusInterfaceGetPropertyFunc", "Gio.DBusInterfaceMethodCallFunc", "Gio.DBusInterfaceSetPropertyFunc", "Gio.DBusInterfaceSkeleton", "Gio.DBusInterfaceSkeletonFlags", "Gio.DBusMenuModel", "Gio.DBusMessageByteOrder", "Gio.DBusMessageFilterFunction", "Gio.DBusMessageFlags", "Gio.DBusMessageHeaderField", "Gio.DBusMessageType", "Gio.DBusMethodInfo", "Gio.DBusNodeInfo", "Gio.DBusObject", "Gio.DBusObjectManager", "Gio.DBusObjectManagerClientFlags", "Gio.DBusPropertyInfo", "Gio.DBusSendMessageFlags", "Gio.DBusServer", "Gio.DBusServerFlags", "Gio.DBusSignalFlags", "Gio.DBusSignalInfo", "Gio.DebugController", "Gio.Drive", "Gio.DriveStartFlags", "Gio.DriveStartStopType", "Gio.Emblem", "Gio.EmblemedIcon", "Gio.EmblemOrigin", "Gio.FileAttributeInfoFlags", "Gio.FileAttributeStatus", "Gio.FileAttributeType", "Gio.FileCreateFlags", "Gio.FileIcon", "Gio.FileInputStream", "Gio.FileIOStream", "Gio.FileMeasureFlags", "Gio.FileMonitor", "Gio.FileMonitorEvent", "Gio.FileMonitorFlags", "Gio.FilenameCompleter", "Gio.FileOutputStream", "Gio.FileQueryInfoFlags", "Gio.FileType", "Gio.FilterInputStream", "Gio.IOStreamSpliceFlags", "Gio.LoadableIcon", "Gio.MemoryMonitor", "Gio.MemoryMonitorWarningLevel", "Gio.Menu", "Gio.MenuItem", "Gio.MenuModel", "Gio.MountMountFlags", "Gio.MountOperation", "Gio.MountOperationResult", "Gio.MountUnmountFlags", "Gio.NetworkConnectivity", "Gio.NetworkMonitor", "Gio.NetworkService", "Gio.Notification", "Gio.NotificationPriority", "Gio.OutputStreamSpliceFlags", "Gio.PasswordSave", "Gio.Permission", "Gio.PollableReturn", "Gio.PropertyAction", "Gio.Proxy", "Gio.ProxyResolver", "Gio.RemoteActionGroup", "Gio.ResolverError", "Gio.ResolverNameLookupFlags", "Gio.ResourceError", "Gio.ResourceLookupFlags", "Gio.Seekable", "Gio.SettingsBackend", "Gio.SettingsBindFlags", "Gio.SettingsBindGetMapping", "Gio.SettingsBindSetMapping", "Gio.SettingsGetMapping", "Gio.SettingsSchema", "Gio.SettingsSchemaKey", "Gio.SettingsSchemaSource", "Gio.SimpleActionGroup", "Gio.SimplePermission", "Gio.SocketClient", "Gio.SocketClientEvent", "Gio.SocketConnectable", "Gio.SocketConnection", "Gio.SocketFamily", "Gio.SocketListenerEvent", "Gio.SocketProtocol", "Gio.SocketService", "Gio.SocketType", "Gio.SrvTarget", "Gio.TcpConnection", "Gio.TlsAuthenticationMode", "Gio.TlsBackend", "Gio.TlsCertificate", "Gio.TlsCertificateRequestFlags", "Gio.TlsClientConnection", "Gio.TlsDatabase", "Gio.TlsDatabaseLookupFlags", "Gio.TlsDatabaseVerifyFlags", "Gio.TlsFileDatabase", "Gio.TlsInteraction", "Gio.TlsInteractionResult", "Gio.TlsPasswordFlags", "Gio.TlsProtocolVersion", "Gio.TlsRehandshakeMode", "Gio.TlsServerConnection", "Gio.VolumeMonitor", "Gio.ZlibCompressor", "Gio.ZlibCompressorFormat", "Gio.ZlibDecompressor", ] ignore = [ ] manual = [ "Gio.ActionEntry", "Gio.FileAttributeInfo", "Gio.InputMessage", "Gio.IOExtension", "Gio.IOExtensionPoint", "Gio.OutputMessage", "Gio.Task", "GLib.ByteArray", "GLib.Bytes", "GLib.DateTime", "GLib.Error", "GLib.IOCondition", "GLib.KeyFile", "GLib.MainContext", "GLib.OptionArg", "GLib.OptionFlags", "GLib.Pid", "GLib.Priority", "GLib.Quark", "GLib.SeekType", "GLib.Source", "GLib.SpawnFlags", "GLib.Variant", "GLib.VariantDict", "GLib.VariantType", "GObject.Closure", "GObject.Object", "GObject.Value", ] [[object]] name = "Gio.*" status = "generate" [[object.function]] name = "networking_init" ignore = true # useless, std does that already [[object.function]] pattern = "io_scheduler_.*" ignore = true # Deprecated & dangerous [[object.function]] name = "io_error_from_file_error" # manually implemented against IOErrorEnum manual = true [[object.function]] pattern = "unix_.+" cfg_condition = "unix" [[object.function]] pattern = "pollable_stream_.+" #belong to Stream, works only with PollableStream, need mutable buffer reference ignore = true [[object.function]] pattern = "pollable_source_.+" #belong to Stream, works only with PollableStream, need mutable buffer reference ignore = true [[object.function]] name = "unix_is_system_device_path" [[object.function.parameter]] name = "device_path" string_type = "filename" [[object.function]] pattern = "unix_mount.+" #impl UnixMountEntry ignore = true [[object.function]] pattern = ".+_with_closures" #wrapped with proper types manually ignore = true [[object.function]] name = "bus_unown_name" #wrapped with newtype manually ignore = true [[object.function]] name = "bus_unwatch_name" #wrapped with newtype manually ignore = true [[object.function]] name = "dbus_unescape_object_path" # zero-terminated byte array that is not a string ignore = true [[object.function]] name = "content_type_guess" [[object.function.parameter]] name = "filename" string_type = "filename" [[object]] name = "Gio.ActionGroup" status = "generate" [[object.function]] name = "query_action" ignore = true [[object]] name = "Gio.ActionMap" status = "generate" manual_traits = ["ActionMapExtManual"] [[object.function]] name = "add_action_entries" manual = true # GActionEntry is manually implemented [[object.function]] name = "remove_action_entries" ignore = true # TODO: Needs manual implementation [[object]] name = "Gio.AppInfo" status = "generate" manual_traits = ["AppInfoExtManual"] [[object.function]] name = "create_from_commandline" [[object.function.parameter]] name = "commandline" string_type = "os_string" [[object.function]] name = "launch_uris_async" #in array of strings manual = true [[object]] name = "Gio.AppLaunchContext" status = "generate" [[object.function]] name = "get_environment" [object.function.return] string_type = "os_string" [[object.function]] pattern = "(un)?setenv" [[object.function.parameter]] name = "variable" string_type = "os_string" [[object.function.parameter]] name = "value" string_type = "os_string" [[object]] name = "Gio.Application" status = "generate" manual_traits = ["ApplicationExtManual"] generate_builder = true [[object.signal]] name = "open" manual = true doc_trait_name = "ApplicationExtManual" [[object.function]] name = "run" manual = true doc_trait_name = "ApplicationExtManual" [[object.function]] name = "hold" # Returns a value that releases on Drop. manual = true doc_trait_name = "ApplicationExtManual" [[object.function]] name = "release" # Implemented via Drop on ApplicationHoldGuard. manual = true doc_trait_name = "ApplicationExtManual" [[object.function]] name = "mark_busy" manual = true # Returns a value that unmarks-busy on Drop. doc_trait_name = "ApplicationExtManual" [[object.function]] name = "unmark_busy" # Implemented via Drop on ApplicationBusyGuard. manual = true doc_trait_name = "ApplicationExtManual" [[object]] name = "Gio.ApplicationCommandLine" status = "generate" [[object.function]] name = "create_file_for_arg" [[object.function.parameter]] name = "arg" string_type = "os_string" [[object.function]] name = "get_arguments" [object.function.return] string_type = "os_string" [[object.function]] name = "get_environ" [object.function.return] string_type = "os_string" [[object.function]] name = "getenv" [[object.function.parameter]] name = "name" string_type = "os_string" [[object]] name = "Gio.ApplicationFlags" status = "generate" [[object.member]] name = "default_flags" ignore = true [[object]] name = "Gio.AsyncInitable" status = "generate" [[object.function]] name = "init_async" # Can be called only once unsafe = true [[object.function]] name = "new_async" manual = true [[object.function]] name = "new_valist_async" ignore = true [[object.function]] name = "newv_async" ignore = true [[object]] name = "Gio.BufferedInputStream" status = "generate" generate_builder = true [[object.function]] name = "peek" #have almost same peek_buffer ignore = true [[object]] name = "Gio.BufferedOutputStream" status = "generate" generate_builder = true [[object.function]] name = "get_auto_grow" rename = "auto_grows" [[object]] name = "Gio.Cancellable" status = "generate" concurrency = "send+sync" manual_traits = ["CancellableExtManual"] [[object.function]] name = "connect" # Needs manual bindings for closures ignore = true [[object.function]] name = "disconnect" # Needs manual bindings for CancelledHandlerId ignore = true [[object.function]] name = "reset" #undefined behaviour ignore = true [[object.function]] name = "source_new" # Only for use with other source implementations ignore = true [[object.signal]] name = "cancelled" # Racy, use 'connect' and 'disconnect' instead ignore = true [[object.function]] name = "set_error_if_cancelled" manual = true [[object]] name = "Gio.CharsetConverter" status = "generate" generate_builder = true [[object]] name = "Gio.Converter" status = "generate" manual_traits = ["ConverterExtManual"] [[object.function]] name = "convert" manual = true doc_trait_name = "ConverterExtManual" [[object]] name = "Gio.ConverterInputStream" status = "generate" generate_builder = true [[object]] name = "Gio.ConverterOutputStream" status = "generate" generate_builder = true [[object]] name = "Gio.Credentials" status = "generate" [[object.function]] name = "get_unix_pid" cfg_condition = "unix" # Use correct libc type # https://gitlab.gnome.org/GNOME/glib/-/issues/3311 manual = true [[object.function]] name = "get_unix_user" cfg_condition = "unix" # Use correct libc type # https://gitlab.gnome.org/GNOME/glib/-/issues/3311 manual = true [object.function.return] use_return_for_result = true [[object.function]] name = "set_unix_user" cfg_condition = "unix" # Use correct libc type # https://gitlab.gnome.org/GNOME/glib/-/issues/3311 manual = true [[object.function]] pattern = "[gs]et_native" # Unsafe and using raw pointers manual = true [[object]] name = "Gio.CredentialsType" status = "generate" [[object.member]] name = "win32_pid" version = "2.72" [[object]] name = "Gio.DatagramBased" status = "generate" manual_traits = ["DatagramBasedExtManual"] [[object.function]] name = "condition_wait" # needs Duration manual = true doc_trait_name = "DatagramBasedExtManual" [[object.function]] name = "create_source" # manual source implementation manual = true doc_trait_name = "DatagramBasedExtManual" [[object.function]] name = "receive_messages" # InputMessage is not a gtype manual = true doc_trait_name = "DatagramBasedExtManual" [[object.function]] name = "send_messages" # OutputMessage is not a gtype manual = true doc_trait_name = "DatagramBasedExtManual" [[object]] name = "Gio.DataInputStream" manual_traits = ["DataInputStreamExtManual"] status = "generate" generate_builder = true [[object.function]] name = "read_line" #return vec of u8 manual = true [[object.function]] name = "read_line_utf8" #redundant length returned manual = true [[object.function]] name = "read_line_async" #return vec of u8 manual = true [[object.function]] name = "read_until" #nullable return value and redundant length #return vec of u8 manual = true [[object.function]] name = "read_until_async" #nullable return value and redundant length #return vec of u8 manual = true [[object.function]] name = "read_upto" #nullable return value and redundant length #return vec of u8 manual = true [[object.function]] name = "read_upto_async" #nullable return value and redundant length #return vec of u8 manual = true [[object.function]] name = "read_line_finish_utf8" #finish functions not needed manual = true [[object]] name = "Gio.DataOutputStream" status = "generate" generate_builder = true [[object]] name = "Gio.DBusConnection" concurrency = "send+sync" status = "generate" [[object.function]] name = "new_for_address" constructor = true [[object.function]] pattern = ".+_unix_fd.+" cfg_condition = "unix" [[object.function]] pattern = ".*subtree.*" # no closure based way to create subtrees ignore = true [[object.function]] pattern = "register_object" #wrapped with proper types manually manual = true [[object.function]] pattern = "register_object_with_closures" #wrapped with proper types manually manual = true [[object.function]] name = "unregister_object" #wrapped with newtype manually manual = true [[object.function]] pattern = ".*action_group.*" #wrapped with newtype manually manual = true [[object.function]] pattern = ".*menu_model.*" #wrapped with newtype manually manual = true [[object.function]] pattern = ".*filter.*" #wrapped with newtype manually manual = true [[object.function]] pattern = "signal_.*subscribe" #wrapped with newtype manually manual = true [[object]] name = "Gio.DBusConnectionFlags" status = "generate" [[object.member]] name = "cross_namespace" version = "2.74" [[object]] name = "Gio.DBusInterface" status = "generate" [[object.function]] name = "get_object" # returns non-thread-safe reference ignore = true [[object.function]] name = "dup_object" rename = "get" [[object]] name = "Gio.DBusInterfaceInfo" status = "generate" [[object.function]] pattern = "cache_.+" # should have a Drop wrapper ignore = true [[object]] name = "Gio.DBusMessage" status = "generate" generate_display_trait = false [[object.function]] name = "get_header_fields" #return vec of u8 ignore = true [[object.function]] pattern = ".+_unix_fd.+" cfg_condition = "unix" [[object]] name = "Gio.DBusMethodInvocation" status = "generate" [[object.function]] name = "take_error" # wrong mutability ignore = true [[object.function]] pattern = ".+_unix_fd.+" cfg_condition = "unix" [[object.function]] name = "return_gerror" # no need to borrow manual = true [[object.function]] name = "return_error_literal" # glib::ErrorDomain manual = true [[object]] name = "Gio.DBusProxy" status = "generate" concurrency = "send+sync" manual_traits = ["DBusProxyExtManual"] [[object.signal]] name = "g-properties-changed" # libc::c_char vs str ignore = true [[object.function]] pattern = ".+_unix_fd.+" cfg_condition = "unix" [[object.function]] name = "new_for_bus" constructor = true [[object.signal]] name = "g-signal" ignore = true # manually provide a variant with the details [[object]] name = "Gio.DBusProxyFlags" status = "generate" [[object.member]] name = "no_match_rule" version = "2.70" [[object]] name = "Gio.DebugControllerDBus" status = "generate" manual_traits = ["DebugControllerDBusExtManual"] [[object.property]] name = "connection" manual = true doc_trait_name = "DebugControllerDBusExtManual" [[object]] name = "Gio.DesktopAppInfo" status = "generate" manual_traits = ["DesktopAppInfoExtManual"] cfg_condition = "all(not(windows),not(target_os = \"macos\"))" [[object.function]] name = "get_boolean" # Retrieves the boolean value of a key rename = "boolean" [[object.function]] name = "search" # returns vec of string manual = true [[object.function]] name = "launch_uris_as_manager_with_fds" # has to use RawFd / SOCKET manual = true [[object]] name = "Gio.File" status = "generate" concurrency = "send+sync" manual_traits = ["FileExtManual"] [[object.function]] name = "new_for_commandline_arg" # Not annotated as constructor in Gir => force it to apply naming convention constructor = true [[object.function.parameter]] name = "arg" string_type = "os_string" [[object.function]] name = "new_for_commandline_arg_and_cwd" # Not annotated as constructor in Gir => force it to apply naming convention constructor = true [[object.function.parameter]] name = "arg" string_type = "os_string" [[object.function]] name = "new_for_path" # Not annotated as constructor in Gir => force it to apply naming convention constructor = true [[object.function]] name = "new_for_uri" # Not annotated as constructor in Gir => force it to apply naming convention constructor = true [[object.function]] name = "parse_name" # Constructor based on a String that can be obtained from method `parse_name` rename = "for_parse_name" [[object.function]] name = "hash" ignore = true [[object.function]] name = "enumerate_children_async" # FileEnumerator ignore = true [[object.function]] name = "find_enclosing_mount_async" # Mount ignore = true [[object.function]] name = "replace_contents_async" # AsRef manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "copy_async" # Multiple callbacks manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "copy_async_with_closures" # Manually implemented above ignore = true [[object.function]] name = "move_async" # Multiple callbacks manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "move_async_with_closures" # Manually implemented above ignore = true [[object.function]] name = "load_partial_contents_async" # Multiple callbacks manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "measure_disk_usage" # FnMut callback manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "measure_disk_usage_async" # Multiple callbacks manual = true doc_trait_name = "FileExtManual" # bugged gen https://github.com/gtk-rs/gtk-rs-core/issues/731 [[object.function]] name = "make_symbolic_link_async" manual = true doc_trait_name = "FileExtManual" # bugged gen https://github.com/gtk-rs/gtk-rs-core/issues/731 [[object.function]] name = "new_tmp_async" manual = true doc_trait_name = "FileExtManual" # bugged gen https://github.com/gtk-rs/gtk-rs-core/issues/731 [[object.function]] name = "new_tmp_dir_async" manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "load_contents" # Use `Slice` manual = true doc_trait_name = "FileExtManual" [[object.function]] name = "load_contents_async" # Use `Slice` manual = true doc_trait_name = "FileExtManual" [[object]] name = "Gio.FileAttributeInfoList" status = "generate" [[object.function]] name = "lookup" # FileAttributeInfo has strange API manual = true [[object]] name = "Gio.FileAttributeMatcher" status = "generate" [[object.function]] name = "enumerate_next" # Better API with `IntoIter` ignore = true [[object]] name = "Gio.FileCopyFlags" status = "generate" [[object.member]] name = "target_default_modified_time" version = "2.80" [[object]] name = "Gio.FileDescriptorBased" status = "manual" cfg_condition = "unix" manual_traits = ["FileDescriptorBasedExtManual"] [[object]] name = "Gio.FileEnumerator" status = "generate" manual_traits = ["FileEnumeratorExtManual"] [[object.function]] name = "iterate" # better with rust iterators ignore = true [[object]] name = "Gio.FileInfo" status = "generate" [[object.function]] name = "get_attribute_boolean" # Retrieves the boolean value of an attribute rename = "boolean" [[object.function]] name = "get_modification_time" # use SystemTime manual = true [[object.function]] name = "set_modification_time" # use SystemTime manual = true [[object.function]] name = "get_attribute_stringv" # use strv manual = true [[object.function]] name = "set_attribute_stringv" # use strv manual = true [[object]] name = "Gio.FilterOutputStream" status = "generate" [[object.property]] name = "close-base-stream" #has get/set function, ConstructOnly generate = ["notify"] [[object]] name = "Gio.Icon" status = "generate" [[object.function]] name = "new_for_string" constructor = true [[object]] name = "Gio.InetAddressMask" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.InetAddress" status = "generate" manual_traits = ["InetAddressExtManual"] concurrency = "send+sync" [[object.function]] name = "new_from_bytes" # broken and needs some closer integration with the corresponding std types manual = true [[object.function]] name = "to_bytes" # broken and needs some closer integration with the corresponding std types manual = true [[object]] name = "Gio.InetSocketAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.Initable" status = "generate" [[object.function]] name = "init" unsafe = true [[object.function]] name = "new" manual = true [[object.function]] name = "new_valist" ignore = true [[object.function]] name = "newv" ignore = true [[object]] name = "Gio.InputStream" status = "generate" manual_traits = ["InputStreamExtManual"] [[object.function]] pattern = "read(_all)?(_async)?" #mutable buffer manual = true doc_trait_name = "InputStreamExtManual" [[object]] name = "Gio.IOErrorEnum" status = "generate" [[object.member]] name = "no_such_device" version = "2.72" [[object.member]] name = "destination_unset" version = "2.80" [[object]] name = "Gio.IOStream" status = "generate" manual_traits = ["IOStreamExtManual"] [[object.function]] name = "splice_async" #g_io_stream_splice_finish accept only 2 parameters instead normal 3 (no source_object) ignore = true [[object.property]] name = "input-stream" #readonly manual = true [[object.property]] name = "output-stream" #readonly manual = true [[object]] name = "Gio.ListModel" status = "generate" manual_traits = ["ListModelExtManual"] # Can get removed when gir shadow annotations are implemented (gtk-rs/gir#1112) [[object.function]] name = "get_item" ignore = true [[object.function]] name = "get_object" rename = "item" [[object]] name = "Gio.ListStore" status = "generate" generate_builder = true [[object.function]] name = "new" manual = true # Disable the generated constructors so we can use ones with type parameters [[object.function]] name = "insert_sorted" manual = true [[object.function]] name = "sort" manual = true [[object.function]] name = "splice" # More generic arguments manual = true [[object.function]] name = "find_with_equal_func" # calls find_with_equal_func_full manual = true [[object.function]] name = "find_with_equal_func_full" # see above ignore = true [[object.property]] name = "n-items" generate = [] # disable generated getter/notify, use the ones from GListModel iface [[object]] name = "Gio.MemoryInputStream" status = "generate" [[object.function]] name = "new_from_data" #destroy function will called on passed data, so boxing free as in glib::Bytes impossible ignore = true [[object.function]] name = "add_data" #destroy function will called on passed data, so boxing free as in glib::Bytes impossible ignore = true [[object]] name = "Gio.MemoryOutputStream" status = "generate" [[object.function]] name = "new" #unsupported memory allocators ignore = true [[object.function]] name = "get_data" #uncontrolled lifetime ignore = true [[object.function]] name = "get_size" #not usable ignore = true [[object.function]] name = "steal_data" #unsupported memory allocators ignore = true [[object.property]] name = "data" #uncontrolled lifetime ignore = true [[object.property]] name = "size" #not usable ignore = true [[object.property]] name = "destroy-function" #unsupported memory allocators ignore = true [[object.property]] name = "realloc-function" #unsupported memory allocators ignore = true [[object]] name = "Gio.MenuAttributeIter" status = "generate" [[object.function]] name = "get_name" # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "next" # this one advances the iter and returns a boolean # `get_next` (which will be automatically renamed as `next`) # matches what we expect from an iterator in Rust. ignore= true [[object]] name = "Gio.MenuLinkIter" status = "generate" [[object.function]] name = "get_name" # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" # Users should use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "next" # this one advances the iter and returns a boolean # `get_next` (which will be automatically renamed as `next`) # matches what we expect from an iterator in Rust. ignore= true [[object]] name = "Gio.Mount" status = "generate" [[object]] name = "Gio.NetworkAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.OutputStream" status = "generate" manual_traits = ["OutputStreamExtManual"] [[object.function]] name = "write_async" #AsRef manual = true doc_trait_name = "OutputStreamExtManual" [[object.function]] name = "write_all_async" #AsRef manual = true doc_trait_name = "OutputStreamExtManual" [[object.function]] name = "write_all" # special return value manual = true doc_trait_name = "OutputStreamExtManual" [[object.function]] pattern = "writev.*" # OutputVector manual = true doc_trait_name = "OutputStreamExtManual" [[object]] name = "Gio.PollableInputStream" status = "generate" manual_traits = ["PollableInputStreamExtManual"] [[object.function]] name = "create_source" # manual source implementation manual = true doc_trait_name = "PollableInputStreamExtManual" [[object.function]] name = "read_nonblocking" # wrong mutability manual = true doc_trait_name = "PollableInputStreamExtManual" [[object]] name = "Gio.PollableOutputStream" status = "generate" manual_traits = ["PollableOutputStreamExtManual"] [[object.function]] name = "create_source" # manual source implementation manual = true doc_trait_name = "PollableOutputStreamExtManual" [[object.function]] name = "writev_nonblocking" # OutputVector manual = true doc_trait_name = "PollableOutputStreamExtManual" [[object]] name = "Gio.PowerProfileMonitor" status = "generate" [[object.function]] name = "dup_default" rename = "get_default" [[object]] name = "Gio.ProxyAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.Resolver" status = "generate" [[object.function]] # see https://gitlab.gnome.org/GNOME/glib/-/issues/3231 name = "records_from_res_query" ignore = true [[object]] name = "Gio.ResolverRecordType" status = "generate" [[object.function]] # see https://gitlab.gnome.org/GNOME/glib/-/issues/3231 name = "to_rrtype" ignore = true [[object]] name = "Gio.Resource" status = "generate" [[object.function]] name = "new_from_data" # Requires special alignment, see # https://bugzilla.gnome.org/show_bug.cgi?id=790030 manual = true [[object]] name = "Gio.Settings" status = "generate" manual_traits = ["SettingsExtManual"] [[object.signal]] name = "writable-change-event" inhibit = true [[object.function]] pattern="set_.*" [object.function.return] bool_return_is_error = "Can't set readonly key" [[object.function]] name = "get_strv" # Use strv manual = true [[object.function]] name = "set_strv" # Use strv manual = true [[object.function]] name = "bind" manual = true [[object.function]] name = "bind_with_mapping" manual = true [[object.function]] name = "get_boolean" # Retrieves the boolean value of a setting rename = "boolean" [[object]] name = "Gio.SimpleAction" status = "generate" [[object.property]] name = "parameter-type" #value glib::VariantTy ignore = true [[object.property]] name = "state" #value glib::VariantTy ignore = true [[object]] name = "Gio.SimpleIOStream" status = "generate" [[object.property]] name = "input-stream" #readonly ignore = true [[object.property]] name = "output-stream" #readonly ignore = true [[object]] name = "Gio.SimpleProxyResolver" status = "generate" manual_traits = ["SimpleProxyResolverExtManual"] [[object.function]] name = "new" # takes vec of strings manual = true [[object.function]] name = "set_ignore_hosts" # takes vec of strings manual = true doc_trait_name = "SimpleProxyResolverExtManual" [[object]] name = "Gio.Socket" status = "generate" manual_traits = ["SocketExtManual"] [[object.function]] name = "new_from_fd" # has to use RawFd / SOCKET manual = true doc_trait_name = "SocketExtManual" [[object.function]] name = "get_fd" # has to use RawFd / SOCKET manual = true doc_trait_name = "SocketExtManual" [[object.property]] name = "fd" # has to use RawFd / SOCKET ignore = true [[object.function]] name = "create_source" # needs custom impl for Source callback ignore = true doc_trait_name = "SocketExtManual" [[object.function]] pattern = "receive.*" # &[u8] manual = true doc_trait_name = "SocketExtManual" [[object.function]] pattern = "send.*" # &[u8] manual = true doc_trait_name = "SocketExtManual" [[object]] name = "Gio.SocketAddress" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.SocketAddressEnumerator" status = "generate" [[object.function]] name = "next" # enforce nullable return value, since a NULL # return value is used to indicate the end of stream. # Glib MR: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2701 [object.function.return] nullable = true [[object.function]] name = "next_async" # enforce nullable return value, since a NULL # return value is used to indicate the end of stream. # Glib MR: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2701 [object.function.return] nullable = true [[object]] name = "Gio.SocketControlMessage" status = "generate" manual_traits = ["SocketControlMessageExtManual"] [[object.function]] name = "deserialize" # NULL indicates deserialization failure # Glib MR: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3099 [object.function.return] nullable = true [[object.function]] name = "serialize" # writes to a void pointer manual = true doc_trait_name = "SocketControlMessageExtManual" [[object]] name = "Gio.SocketListener" status = "generate" manual_traits = ["SocketListenerExtManual"] [[object]] name = "Gio.Subprocess" status = "generate" [[object.function]] name = "newv" [[object.function.parameter]] name = "argv" string_type = "os_string" [[object.function]] name = "communicate_utf8_async" manual = true [[object.function]] name = "get_if_exited" # NOTE: this might be controversial: # the C fct is named after the WIFEXITED macro # but this seems like a nicer name to use in Rust: # if suprocess.has_exited() ... rename = "has_exited" [[object.function]] name = "get_if_signaled" # NOTE: this might be controversial: # the C fct is named after the WIFSIGNALED macro # but this seems like a nicer name to use in Rust: # if suprocess.has_signaled() ... rename = "has_signaled" [[object.function]] name = "send_signal" cfg_condition = "not(windows)" [[object]] name = "Gio.SubprocessFlags" status = "generate" [[object.member]] name = "search_path_from_envp" version = "2.72" [[object]] name = "Gio.SubprocessLauncher" status = "generate" [[object.function]] name = "spawnv" rename = "spawn" [[object.function.parameter]] name = "argv" string_type = "os_string" [[object.function]] name = "setenv" [[object.function.parameter]] name = "variable" string_type = "os_string" [[object.function.parameter]] name = "value" string_type = "os_string" [[object.function]] name = "unsetenv" [[object.function.parameter]] name = "variable" string_type = "os_string" [[object.function]] pattern = "take_.*" manual = true [[object.function]] pattern = "set_std.*file_path" cfg_condition = "unix" [[object.function]] name = "set_child_setup" cfg_condition = "unix" [[object.function]] name = "close" cfg_condition = "unix" [[object]] name = "Gio.ThemedIcon" status = "generate" [[object.property]] name = "names" # ConstructOnly generate = ["notify"] [[object]] name = "Gio.ThreadedSocketService" status = "generate" [[object.function]] name = "new" # Better to provide None than -1 when you don't want to specify the number of threads manual = true [[object]] name = "Gio.TlsCertificateFlags" status = "generate" [[object.member]] name = "no_flags" ignore = true [[object]] name = "Gio.TlsChannelBindingType" status = "generate" [[object.member]] name = "exporter" version = "2.74" [[object]] name = "Gio.TlsConnection" status = "generate" manual_traits = ["TlsConnectionExtManual"] [[object.function]] name = "get_channel_binding_data" # Gir confuses the mutability of the data manual = true [[object.function]] name = "set_advertised_protocols" # Use strv manual = true [[object]] name = "Gio.TlsError" status = "generate" [[object.member]] name = "bad_certificate_password" version = "2.72" [[object]] name = "Gio.TlsPassword" status = "generate" [[object.function]] name = "get_value" # missing inout annotation ignore = true [[object.function]] # missing (element-type guint8) annotation name = "set_value" ignore = true [[object]] name = "Gio.UnixCredentialsMessage" status = "generate" cfg_condition = "unix" [[object]] name = "Gio.UnixFDList" status = "generate" cfg_condition = "unix" manual_traits = ["UnixFDListExtManual"] [[object.function]] name = "new_from_array" # has to use RawFd manual = true [[object.function]] name = "append" # has to use RawFd manual = true doc_trait_name = "UnixFDListExtManual" [[object.function]] name = "get" # has to use RawFd manual = true doc_trait_name = "UnixFDListExtManual" [[object.function]] name = "peek_fds" # has to use RawFd manual = true doc_trait_name = "UnixFDListExtManual" [[object.function]] name = "steal_fds" # has to use RawFd manual = true doc_trait_name = "UnixFDListExtManual" [[object]] name = "Gio.UnixFDMessage" status = "generate" cfg_condition = "unix" manual_traits = ["UnixFDMessageExtManual"] [[object.function]] name = "append_fd" # has to use RawFd manual = true doc_trait_name = "UnixFDMessageExtManual" [[object.function]] name = "steal_fds" # has to use RawFd manual = true doc_trait_name = "UnixFDMessageExtManual" [[object]] name = "Gio.UnixInputStream" status = "generate" cfg_condition = "unix" manual_traits = ["UnixInputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd manual = true generate_doc = false [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks manual = true doc_trait_name = "UnixInputStreamExtManual" generate_doc = false [[object.function]] name = "get_fd" # conflicts with as FileDescriptorBased::fd ignore = true [[object.property]] name = "fd" # has to use RawFd ignore = true [[object.property]] name = "close-fd" ignore = true [[object]] name = "Gio.UnixMountEntry" status = "generate" concurrency = "send+sync" cfg_condition = "unix" [[object.derive]] name = "Debug" [[object]] name = "Gio.UnixMountPoint" status = "generate" concurrency = "send+sync" cfg_condition = "unix" [[object.derive]] name = "Debug" [[object.function]] name = "compare" [[object.function.parameter]] pattern = ".+" const = true [[object.function]] pattern = "get_.*" [[object.function.parameter]] pattern = ".+" const = true [[object.function]] pattern = "guess_.*" [[object.function.parameter]] pattern = ".+" const = true [[object.function]] pattern = "is_.*" [[object.function.parameter]] pattern = ".+" const = true [[object]] name = "Gio.UnixOutputStream" status = "generate" cfg_condition = "unix" manual_traits = ["UnixOutputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd manual = true generate_doc = false [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks manual = true doc_trait_name = "UnixOutputStreamExtManual" generate_doc = false [[object.function]] name = "get_fd" # conflicts with as FileDescriptorBased::fd ignore = true [[object.property]] name = "fd" # has to use RawFd ignore = true [[object.property]] name = "close-fd" ignore = true [[object]] name = "Gio.UnixSocketAddress" status = "generate" concurrency = "send+sync" cfg_condition = "unix" manual_traits = ["UnixSocketAddressExtManual"] [[object.function]] name = "new" manual = true [[object.function]] name = "get_path" manual = true doc_trait_name = "UnixSocketAddressExtManual" [[object.property]] name = "path" ignore = true [[object]] name = "Gio.UnixSocketAddressType" status = "generate" cfg_condition = "unix" [[object]] name = "Gio.Vfs" status = "generate" concurrency = "send+sync" [[object]] name = "Gio.Volume" status = "generate" [[object.function]] name = "get_mount" # Avoid clash with the `mount` operation. bypass_auto_rename = true [[object]] name = "Gio.Win32InputStream" status = "manual" cfg_condition = "windows" manual_traits = ["Win32InputStreamExt"] [[object]] name = "Gio.Win32OutputStream" status = "manual" cfg_condition = "windows" manual_traits = ["Win32OutputStreamExt"] gio-0.20.1/LICENSE000064400000000000000000000020001046102023000114570ustar 00000000000000Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gio-0.20.1/README.md000064400000000000000000000023421046102023000117420ustar 00000000000000# Rust GIO bindings __Rust__ bindings and wrappers for [GIO](https://docs.gtk.org/gio/), part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). GIO __2.56__ is the lowest supported version for the underlying library. ## Minimum supported Rust version Currently, the minimum supported Rust version is `1.70.0`. ## Documentation * [Rust API - Stable](https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/) * [Rust API - Development](https://gtk-rs.org/gtk-rs-core/git/docs/gio) * [C API](https://docs.gtk.org/gio/) * [GTK Installation instructions](https://www.gtk.org/docs/installations/) ## Using We recommend using [crates from crates.io](https://crates.io/keywords/gtk-rs), as [demonstrated here](https://gtk-rs.org/#using). If you want to track the bleeding edge, use the git dependency instead: ```toml [dependencies] gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } ``` Avoid mixing versioned and git crates like this: ```toml # This will not compile [dependencies] gio = "0.13" gio = { git = "https://github.com/gtk-rs/gtk-rs-core.git", package = "gio" } ``` ### See Also * [glib](https://crates.io/crates/glib) ## License __gio__ is available under the MIT License, please refer to it. gio-0.20.1/build.rs000064400000000000000000000002261046102023000121270ustar 00000000000000// This whole build.rs file is required because of the `OUT_DIR` environment variable // provided by cargo when a build file is present. fn main() {} gio-0.20.1/src/action_entry.rs000064400000000000000000000063741046102023000143270ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, Variant, VariantTy, VariantType}; use crate::{ActionMap, SimpleAction}; #[doc(alias = "GActionEntry")] pub struct ActionEntry where O: IsA, { name: String, parameter_type: Option, state: Option, #[allow(clippy::type_complexity)] pub(crate) activate: Option) + 'static>>, #[allow(clippy::type_complexity)] pub(crate) change_state: Option) + 'static>>, } impl ActionEntry where O: IsA, { pub fn name(&self) -> &str { &self.name } pub fn parameter_type(&self) -> Option<&VariantTy> { self.parameter_type.as_deref() } pub fn state(&self) -> Option<&Variant> { self.state.as_ref() } pub fn builder(name: &str) -> ActionEntryBuilder { ActionEntryBuilder::new(name) } } impl std::fmt::Debug for ActionEntry where O: IsA, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("ActionEntry") .field("name", &self.name()) .field("parameter_type", &self.parameter_type()) .field("state", &self.state()) .finish() } } #[derive(Debug)] pub struct ActionEntryBuilder(ActionEntry) where O: IsA; impl ActionEntryBuilder where O: IsA, { pub fn new(name: &str) -> Self { Self(ActionEntry { name: name.to_owned(), parameter_type: Default::default(), state: Default::default(), activate: Default::default(), change_state: Default::default(), }) } pub fn parameter_type(mut self, parameter_type: Option<&VariantTy>) -> Self { self.0.parameter_type = parameter_type.map(|vt| vt.to_owned()); self } pub fn state(mut self, state: Variant) -> Self { self.0.state = Some(state); self } pub fn activate) + 'static>( mut self, callback: F, ) -> Self { self.0.activate = Some(Box::new(callback)); self } pub fn change_state) + 'static>( mut self, callback: F, ) -> Self { self.0.change_state = Some(Box::new(callback)); self } pub fn build(self) -> ActionEntry { self.0 } } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; #[test] fn action_entry() { let app = crate::Application::new(None, Default::default()); app.add_action_entries(vec![ ActionEntry::builder("close") .activate(move |_app, _, _| { //Do something }) .build(), ActionEntry::builder("enable") .state(true.to_variant()) .change_state(move |_app, _, _| { //Do something }) .build(), ]); assert!(app.lookup_action("close").is_some()); assert!(app.lookup_action("enable").is_some()); } } gio-0.20.1/src/action_map.rs000064400000000000000000000033711046102023000137350ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{clone, prelude::*}; use crate::{prelude::*, ActionEntry, ActionMap, SimpleAction}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ActionMapExtManual: sealed::Sealed + IsA { #[doc(alias = "g_action_map_add_action_entries")] fn add_action_entries(&self, entries: impl IntoIterator>) { for entry in entries.into_iter() { let action = if let Some(state) = entry.state() { SimpleAction::new_stateful(entry.name(), entry.parameter_type(), state) } else { SimpleAction::new(entry.name(), entry.parameter_type()) }; let action_map = self.as_ref(); if let Some(callback) = entry.activate { action.connect_activate(clone!( #[weak] action_map, move |action, state| { // safe to unwrap as O: IsA callback(action_map.downcast_ref::().unwrap(), action, state); } )); } if let Some(callback) = entry.change_state { action.connect_change_state(clone!( #[weak] action_map, move |action, state| { // safe to unwrap as O: IsA callback(action_map.downcast_ref::().unwrap(), action, state); } )); } self.as_ref().add_action(&action); } } } impl> ActionMapExtManual for O {} gio-0.20.1/src/app_info.rs000064400000000000000000000075021046102023000134160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::boxed::Box as Box_; use std::pin::Pin; use std::ptr; use glib::prelude::*; use glib::translate::*; use crate::{ffi, AppInfo, AppLaunchContext, Cancellable}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait AppInfoExtManual: sealed::Sealed + IsA + 'static { #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_app_info_launch_uris_async")] fn launch_uris_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + 'static, >( &self, uris: &[&str], context: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_<(glib::thread_guard::ThreadGuard, *mut *mut libc::c_char)> = Box_::new(( glib::thread_guard::ThreadGuard::new(callback), uris.to_glib_full(), )); unsafe extern "C" fn launch_uris_async_trampoline< R: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let _ = ffi::g_app_info_launch_uris_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_<(glib::thread_guard::ThreadGuard, *mut *mut libc::c_char)> = Box_::from_raw(user_data as *mut _); let (callback, uris) = *callback; let callback = callback.into_inner(); callback(result); glib::ffi::g_strfreev(uris); } let callback = launch_uris_async_trampoline::; unsafe { ffi::g_app_info_launch_uris_async( self.as_ref().to_glib_none().0, uris.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn launch_uris_future + Clone + 'static>( &self, uris: &[&str], context: Option<&P>, ) -> Pin> + 'static>> { let uris = uris.iter().copied().map(String::from).collect::>(); let context = context.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { let uris = uris .iter() .map(::std::borrow::Borrow::borrow) .collect::>(); obj.launch_uris_async( uris.as_ref(), context.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } } impl> AppInfoExtManual for O {} gio-0.20.1/src/application.rs000064400000000000000000000067111046102023000141270ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, mem::transmute}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, ExitCode, GString, }; use crate::{ffi, Application, File}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ApplicationExtManual: sealed::Sealed + IsA { #[doc(alias = "g_application_run")] fn run(&self) -> ExitCode { self.run_with_args(&std::env::args().collect::>()) } #[doc(alias = "g_application_run")] fn run_with_args>(&self, args: &[S]) -> ExitCode { let argv: Vec<&str> = args.iter().map(|a| a.as_ref()).collect(); let argc = argv.len() as i32; let exit_code = unsafe { ffi::g_application_run(self.as_ref().to_glib_none().0, argc, argv.to_glib_none().0) }; ExitCode::from(exit_code) } fn connect_open(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn open_trampoline( this: *mut ffi::GApplication, files: *const *mut ffi::GFile, n_files: libc::c_int, hint: *mut libc::c_char, f: glib::ffi::gpointer, ) where P: IsA, { let f: &F = &*(f as *const F); let files: Vec = FromGlibContainer::from_glib_none_num(files, n_files as usize); f( Application::from_glib_borrow(this).unsafe_cast_ref(), &files, &GString::from_glib_borrow(hint), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"open\0".as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( open_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "g_application_hold")] fn hold(&self) -> ApplicationHoldGuard { unsafe { ffi::g_application_hold(self.as_ref().to_glib_none().0); } ApplicationHoldGuard(self.as_ref().downgrade()) } #[doc(alias = "g_application_mark_busy")] fn mark_busy(&self) -> ApplicationBusyGuard { unsafe { ffi::g_application_mark_busy(self.as_ref().to_glib_none().0); } ApplicationBusyGuard(self.as_ref().downgrade()) } } impl> ApplicationExtManual for O {} #[derive(Debug)] #[must_use = "if unused the Application will immediately be released"] pub struct ApplicationHoldGuard(glib::WeakRef); impl Drop for ApplicationHoldGuard { #[inline] fn drop(&mut self) { if let Some(application) = self.0.upgrade() { unsafe { ffi::g_application_release(application.to_glib_none().0); } } } } #[derive(Debug)] #[must_use = "if unused the Application will immediately be unmarked busy"] pub struct ApplicationBusyGuard(glib::WeakRef); impl Drop for ApplicationBusyGuard { #[inline] fn drop(&mut self) { if let Some(application) = self.0.upgrade() { unsafe { ffi::g_application_unmark_busy(application.to_glib_none().0); } } } } gio-0.20.1/src/async_initable.rs000064400000000000000000000235711046102023000146130ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, marker::PhantomData, pin::Pin}; use futures_util::TryFutureExt; use glib::{object::IsClass, prelude::*, Object, Type}; use crate::{prelude::*, AsyncInitable, Cancellable}; impl AsyncInitable { // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object with the default property values. /// /// Similar to [`Object::new`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] #[allow(clippy::new_ret_no_self)] pub fn new< O: IsClass + IsA + IsA, Q: FnOnce(Result) + 'static, >( io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: Q, ) { Self::with_type(O::static_type(), io_priority, cancellable, move |res| { callback(res.map(|o| unsafe { o.unsafe_cast() })) }) } // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object with the default property values as future. /// /// Similar to [`Object::new`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] pub fn new_future + IsA>( io_priority: glib::Priority, ) -> Pin> + 'static>> { Box::pin( Self::with_type_future(O::static_type(), io_priority) .map_ok(|o| unsafe { o.unsafe_cast() }), ) } // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object of the given type with the default /// property values. /// /// Similar to [`Object::with_type`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] pub fn with_type) + 'static>( type_: Type, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: Q, ) { if !type_.is_a(AsyncInitable::static_type()) { panic!("Type '{type_}' is not async initable"); } unsafe { let obj = Object::new_internal(type_, &mut []); obj.unsafe_cast_ref::().init_async( io_priority, cancellable, glib::clone!( #[strong] obj, move |res| { callback(res.map(|_| obj)); } ), ) }; } // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object of the given type with the default property values as future. /// /// Similar to [`Object::with_type`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] pub fn with_type_future( type_: Type, io_priority: glib::Priority, ) -> Pin> + 'static>> { if !type_.is_a(AsyncInitable::static_type()) { panic!("Type '{type_}' is not async initable"); } unsafe { Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { let obj = Object::new_internal(type_, &mut []); obj.unsafe_cast_ref::().init_async( io_priority, Some(cancellable), glib::clone!( #[strong] obj, move |res| { send.resolve(res.map(|_| obj)); } ), ); }, )) } } // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object of the given type with the given properties as mutable values. /// /// Similar to [`Object::with_mut_values`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] pub fn with_mut_values) + 'static>( type_: Type, properties: &mut [(&str, glib::Value)], io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: Q, ) { if !type_.is_a(AsyncInitable::static_type()) { panic!("Type '{type_}' is not async initable"); } unsafe { let obj = Object::new_internal(type_, properties); obj.unsafe_cast_ref::().init_async( io_priority, cancellable, glib::clone!( #[strong] obj, move |res| { callback(res.map(|_| obj)); } ), ) }; } // rustdoc-stripper-ignore-next /// Create a new instance of an async initable object of the given type with the given properties as mutable values as a future. /// /// Similar to [`Object::with_mut_values`] but can fail because the object initialization in /// `AsyncInitable::init` failed. #[doc(alias = "g_async_initable_new_async")] #[track_caller] pub fn with_mut_values_future( type_: Type, properties: &mut [(&str, glib::Value)], io_priority: glib::Priority, ) -> Pin> + 'static>> { if !type_.is_a(AsyncInitable::static_type()) { panic!("Type '{type_}' is not async initable"); } unsafe { // FIXME: object construction should ideally happen as part of the future let obj = Object::new_internal(type_, properties); Box_::pin(crate::GioFuture::new( &obj, move |obj, cancellable, send| { obj.unsafe_cast_ref::().init_async( io_priority, Some(cancellable), glib::clone!( #[strong] obj, move |res| { send.resolve(res.map(|_| obj)); } ), ); }, )) } } // rustdoc-stripper-ignore-next /// Create a new object builder for a specific type. pub fn builder<'a, O: IsA + IsClass + IsA>( ) -> AsyncInitableBuilder<'a, O> { AsyncInitableBuilder::new(O::static_type()) } // rustdoc-stripper-ignore-next /// Create a new object builder for a specific type. pub fn builder_with_type<'a>(type_: Type) -> AsyncInitableBuilder<'a, Object> { if !type_.is_a(AsyncInitable::static_type()) { panic!("Type '{type_}' is not async initable"); } AsyncInitableBuilder::new(type_) } } #[must_use = "builder doesn't do anything unless built"] pub struct AsyncInitableBuilder<'a, O> { type_: Type, properties: smallvec::SmallVec<[(&'a str, glib::Value); 16]>, phantom: PhantomData, } impl<'a, O: IsA + IsClass> AsyncInitableBuilder<'a, O> { #[inline] fn new(type_: Type) -> Self { AsyncInitableBuilder { type_, properties: smallvec::SmallVec::new(), phantom: PhantomData, } } // rustdoc-stripper-ignore-next /// Gets the type of this builder. #[inline] pub fn type_(&self) -> Type { self.type_ } // rustdoc-stripper-ignore-next /// Set property `name` to the given value `value`. #[inline] pub fn property(self, name: &'a str, value: impl Into) -> Self { let AsyncInitableBuilder { type_, mut properties, .. } = self; properties.push((name, value.into())); AsyncInitableBuilder { type_, properties, phantom: PhantomData, } } // rustdoc-stripper-ignore-next /// Build the object with the provided properties. /// /// # Panics /// /// This panics if the object is not instantiable, doesn't have all the given properties or /// property values of the wrong type are provided. #[track_caller] #[inline] pub fn build) + 'static>( mut self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: Q, ) { AsyncInitable::with_mut_values( self.type_, &mut self.properties, io_priority, cancellable, move |res| callback(res.map(|o| unsafe { o.unsafe_cast() })), ); } // rustdoc-stripper-ignore-next /// Build the object with the provided properties. /// /// # Panics /// /// This panics if the object is not instantiable, doesn't have all the given properties or /// property values of the wrong type are provided. #[track_caller] #[inline] pub fn build_future( mut self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box::pin( AsyncInitable::with_mut_values_future(self.type_, &mut self.properties, io_priority) .map_ok(|o| unsafe { o.unsafe_cast() }), ) } } gio-0.20.1/src/auto/action.rs000064400000000000000000000206471046102023000140550ustar 00000000000000// 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::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GAction")] pub struct Action(Interface); match fn { type_ => || ffi::g_action_get_type(), } } impl Action { pub const NONE: Option<&'static Action> = None; #[doc(alias = "g_action_name_is_valid")] pub fn name_is_valid(action_name: &str) -> bool { unsafe { from_glib(ffi::g_action_name_is_valid(action_name.to_glib_none().0)) } } #[doc(alias = "g_action_parse_detailed_name")] pub fn parse_detailed_name( detailed_name: &str, ) -> Result<(glib::GString, Option), glib::Error> { unsafe { let mut action_name = std::ptr::null_mut(); let mut target_value = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_action_parse_detailed_name( detailed_name.to_glib_none().0, &mut action_name, &mut target_value, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok((from_glib_full(action_name), from_glib_full(target_value))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_action_print_detailed_name")] pub fn print_detailed_name( action_name: &str, target_value: Option<&glib::Variant>, ) -> glib::GString { unsafe { from_glib_full(ffi::g_action_print_detailed_name( action_name.to_glib_none().0, target_value.to_glib_none().0, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ActionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_action_activate")] fn activate(&self, parameter: Option<&glib::Variant>) { unsafe { ffi::g_action_activate(self.as_ref().to_glib_none().0, parameter.to_glib_none().0); } } #[doc(alias = "g_action_change_state")] fn change_state(&self, value: &glib::Variant) { unsafe { ffi::g_action_change_state(self.as_ref().to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_action_get_enabled")] #[doc(alias = "get_enabled")] #[doc(alias = "enabled")] fn is_enabled(&self) -> bool { unsafe { from_glib(ffi::g_action_get_enabled(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_action_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_action_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_action_get_parameter_type")] #[doc(alias = "get_parameter_type")] #[doc(alias = "parameter-type")] fn parameter_type(&self) -> Option { unsafe { from_glib_none(ffi::g_action_get_parameter_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_action_get_state")] #[doc(alias = "get_state")] fn state(&self) -> Option { unsafe { from_glib_full(ffi::g_action_get_state(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_action_get_state_hint")] #[doc(alias = "get_state_hint")] fn state_hint(&self) -> Option { unsafe { from_glib_full(ffi::g_action_get_state_hint(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_action_get_state_type")] #[doc(alias = "get_state_type")] #[doc(alias = "state-type")] fn state_type(&self) -> Option { unsafe { from_glib_none(ffi::g_action_get_state_type(self.as_ref().to_glib_none().0)) } } #[doc(alias = "enabled")] fn connect_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Action::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enabled\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "name")] fn connect_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_name_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Action::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "parameter-type")] fn connect_parameter_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_parameter_type_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Action::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::parameter-type\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_parameter_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state")] fn connect_state_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Action::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state-type")] fn connect_state_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GAction, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Action::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::state-type\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_state_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ActionExt for O {} gio-0.20.1/src/auto/action_group.rs000064400000000000000000000254101046102023000152620ustar 00000000000000// 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::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GActionGroup")] pub struct ActionGroup(Interface); match fn { type_ => || ffi::g_action_group_get_type(), } } impl ActionGroup { pub const NONE: Option<&'static ActionGroup> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ActionGroupExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_action_group_action_added")] fn action_added(&self, action_name: &str) { unsafe { ffi::g_action_group_action_added( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } #[doc(alias = "g_action_group_action_enabled_changed")] fn action_enabled_changed(&self, action_name: &str, enabled: bool) { unsafe { ffi::g_action_group_action_enabled_changed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, enabled.into_glib(), ); } } #[doc(alias = "g_action_group_action_removed")] fn action_removed(&self, action_name: &str) { unsafe { ffi::g_action_group_action_removed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } #[doc(alias = "g_action_group_action_state_changed")] fn action_state_changed(&self, action_name: &str, state: &glib::Variant) { unsafe { ffi::g_action_group_action_state_changed( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, state.to_glib_none().0, ); } } #[doc(alias = "g_action_group_activate_action")] fn activate_action(&self, action_name: &str, parameter: Option<&glib::Variant>) { unsafe { ffi::g_action_group_activate_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, parameter.to_glib_none().0, ); } } #[doc(alias = "g_action_group_change_action_state")] fn change_action_state(&self, action_name: &str, value: &glib::Variant) { unsafe { ffi::g_action_group_change_action_state( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, value.to_glib_none().0, ); } } #[doc(alias = "g_action_group_get_action_enabled")] #[doc(alias = "get_action_enabled")] fn is_action_enabled(&self, action_name: &str) -> bool { unsafe { from_glib(ffi::g_action_group_get_action_enabled( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_get_action_parameter_type")] #[doc(alias = "get_action_parameter_type")] fn action_parameter_type(&self, action_name: &str) -> Option { unsafe { from_glib_none(ffi::g_action_group_get_action_parameter_type( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_get_action_state")] #[doc(alias = "get_action_state")] fn action_state(&self, action_name: &str) -> Option { unsafe { from_glib_full(ffi::g_action_group_get_action_state( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_get_action_state_hint")] #[doc(alias = "get_action_state_hint")] fn action_state_hint(&self, action_name: &str) -> Option { unsafe { from_glib_full(ffi::g_action_group_get_action_state_hint( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_get_action_state_type")] #[doc(alias = "get_action_state_type")] fn action_state_type(&self, action_name: &str) -> Option { unsafe { from_glib_none(ffi::g_action_group_get_action_state_type( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_has_action")] fn has_action(&self, action_name: &str) -> bool { unsafe { from_glib(ffi::g_action_group_has_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_group_list_actions")] fn list_actions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_action_group_list_actions( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "action-added")] fn connect_action_added( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_added_trampoline< P: IsA, F: Fn(&P, &str) + 'static, >( this: *mut ffi::GActionGroup, action_name: *mut libc::c_char, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( ActionGroup::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(action_name), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("action-added::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"action-added\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( action_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "action-enabled-changed")] fn connect_action_enabled_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_enabled_changed_trampoline< P: IsA, F: Fn(&P, &str, bool) + 'static, >( this: *mut ffi::GActionGroup, action_name: *mut libc::c_char, enabled: glib::ffi::gboolean, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( ActionGroup::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(action_name), from_glib(enabled), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("action-enabled-changed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"action-enabled-changed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( action_enabled_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "action-removed")] fn connect_action_removed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_removed_trampoline< P: IsA, F: Fn(&P, &str) + 'static, >( this: *mut ffi::GActionGroup, action_name: *mut libc::c_char, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( ActionGroup::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(action_name), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("action-removed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"action-removed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( action_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "action-state-changed")] fn connect_action_state_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn action_state_changed_trampoline< P: IsA, F: Fn(&P, &str, &glib::Variant) + 'static, >( this: *mut ffi::GActionGroup, action_name: *mut libc::c_char, value: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( ActionGroup::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(action_name), &from_glib_borrow(value), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("action-state-changed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"action-state-changed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( action_state_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ActionGroupExt for O {} gio-0.20.1/src/auto/action_map.rs000064400000000000000000000030671046102023000147070ustar 00000000000000// 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::{ffi, Action}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GActionMap")] pub struct ActionMap(Interface); match fn { type_ => || ffi::g_action_map_get_type(), } } impl ActionMap { pub const NONE: Option<&'static ActionMap> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ActionMapExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_action_map_add_action")] fn add_action(&self, action: &impl IsA) { unsafe { ffi::g_action_map_add_action( self.as_ref().to_glib_none().0, action.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_action_map_lookup_action")] fn lookup_action(&self, action_name: &str) -> Option { unsafe { from_glib_none(ffi::g_action_map_lookup_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_action_map_remove_action")] fn remove_action(&self, action_name: &str) { unsafe { ffi::g_action_map_remove_action( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, ); } } } impl> ActionMapExt for O {} gio-0.20.1/src/auto/app_info.rs000064400000000000000000000522351046102023000143710ustar 00000000000000// 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::{ffi, AppInfoCreateFlags, AppLaunchContext, AsyncResult, Cancellable, File, Icon}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GAppInfo")] pub struct AppInfo(Interface); match fn { type_ => || ffi::g_app_info_get_type(), } } impl AppInfo { pub const NONE: Option<&'static AppInfo> = None; #[doc(alias = "g_app_info_create_from_commandline")] pub fn create_from_commandline( commandline: impl AsRef, application_name: Option<&str>, flags: AppInfoCreateFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_app_info_create_from_commandline( commandline.as_ref().to_glib_none().0, application_name.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_app_info_get_all")] #[doc(alias = "get_all")] pub fn all() -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_info_get_all()) } } #[doc(alias = "g_app_info_get_all_for_type")] #[doc(alias = "get_all_for_type")] pub fn all_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_info_get_all_for_type( content_type.to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_default_for_type")] #[doc(alias = "get_default_for_type")] pub fn default_for_type(content_type: &str, must_support_uris: bool) -> Option { unsafe { from_glib_full(ffi::g_app_info_get_default_for_type( content_type.to_glib_none().0, must_support_uris.into_glib(), )) } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_app_info_get_default_for_type_async")] #[doc(alias = "get_default_for_type_async")] pub fn default_for_type_async) + 'static>( content_type: &str, must_support_uris: bool, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn default_for_type_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_app_info_get_default_for_type_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = default_for_type_async_trampoline::

; unsafe { ffi::g_app_info_get_default_for_type_async( content_type.to_glib_none().0, must_support_uris.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub fn default_for_type_future( content_type: &str, must_support_uris: bool, ) -> Pin> + 'static>> { let content_type = String::from(content_type); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::default_for_type_async( &content_type, must_support_uris, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_app_info_get_default_for_uri_scheme")] #[doc(alias = "get_default_for_uri_scheme")] pub fn default_for_uri_scheme(uri_scheme: &str) -> Option { unsafe { from_glib_full(ffi::g_app_info_get_default_for_uri_scheme( uri_scheme.to_glib_none().0, )) } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_app_info_get_default_for_uri_scheme_async")] #[doc(alias = "get_default_for_uri_scheme_async")] pub fn default_for_uri_scheme_async) + 'static>( uri_scheme: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn default_for_uri_scheme_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_app_info_get_default_for_uri_scheme_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = default_for_uri_scheme_async_trampoline::

; unsafe { ffi::g_app_info_get_default_for_uri_scheme_async( uri_scheme.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub fn default_for_uri_scheme_future( uri_scheme: &str, ) -> Pin> + 'static>> { let uri_scheme = String::from(uri_scheme); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::default_for_uri_scheme_async(&uri_scheme, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_app_info_get_fallback_for_type")] #[doc(alias = "get_fallback_for_type")] pub fn fallback_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_info_get_fallback_for_type( content_type.to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_recommended_for_type")] #[doc(alias = "get_recommended_for_type")] pub fn recommended_for_type(content_type: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_info_get_recommended_for_type( content_type.to_glib_none().0, )) } } #[doc(alias = "g_app_info_launch_default_for_uri")] pub fn launch_default_for_uri( uri: &str, context: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_launch_default_for_uri( uri.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_launch_default_for_uri_async")] pub fn launch_default_for_uri_async) + 'static>( uri: &str, context: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn launch_default_for_uri_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_app_info_launch_default_for_uri_finish(res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = launch_default_for_uri_async_trampoline::

; unsafe { ffi::g_app_info_launch_default_for_uri_async( uri.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn launch_default_for_uri_future( uri: &str, context: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let uri = String::from(uri); let context = context.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::launch_default_for_uri_async( &uri, context.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_app_info_reset_type_associations")] pub fn reset_type_associations(content_type: &str) { unsafe { ffi::g_app_info_reset_type_associations(content_type.to_glib_none().0); } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait AppInfoExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_app_info_add_supports_type")] fn add_supports_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_add_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_can_delete")] fn can_delete(&self) -> bool { unsafe { from_glib(ffi::g_app_info_can_delete(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_can_remove_supports_type")] fn can_remove_supports_type(&self) -> bool { unsafe { from_glib(ffi::g_app_info_can_remove_supports_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_delete")] fn delete(&self) -> bool { unsafe { from_glib(ffi::g_app_info_delete(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_dup")] #[must_use] fn dup(&self) -> AppInfo { unsafe { from_glib_full(ffi::g_app_info_dup(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_equal")] fn equal(&self, appinfo2: &impl IsA) -> bool { unsafe { from_glib(ffi::g_app_info_equal( self.as_ref().to_glib_none().0, appinfo2.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_commandline")] #[doc(alias = "get_commandline")] fn commandline(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_commandline( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_description")] #[doc(alias = "get_description")] fn description(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_description( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_display_name")] #[doc(alias = "get_display_name")] fn display_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_app_info_get_display_name( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_executable")] #[doc(alias = "get_executable")] fn executable(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_app_info_get_executable( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_icon(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_get_id")] #[doc(alias = "get_id")] fn id(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_id(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_app_info_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_get_supported_types")] #[doc(alias = "get_supported_types")] fn supported_types(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_app_info_get_supported_types( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_launch")] fn launch( &self, files: &[File], context: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_launch( self.as_ref().to_glib_none().0, files.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_launch_uris")] fn launch_uris( &self, uris: &[&str], context: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_launch_uris( self.as_ref().to_glib_none().0, uris.to_glib_none().0, context.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_remove_supports_type")] fn remove_supports_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_remove_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_set_as_default_for_extension")] fn set_as_default_for_extension( &self, extension: impl AsRef, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_set_as_default_for_extension( self.as_ref().to_glib_none().0, extension.as_ref().to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_set_as_default_for_type")] fn set_as_default_for_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_set_as_default_for_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_set_as_last_used_for_type")] fn set_as_last_used_for_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_app_info_set_as_last_used_for_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_app_info_should_show")] fn should_show(&self) -> bool { unsafe { from_glib(ffi::g_app_info_should_show(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_app_info_supports_files")] fn supports_files(&self) -> bool { unsafe { from_glib(ffi::g_app_info_supports_files( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_info_supports_uris")] fn supports_uris(&self) -> bool { unsafe { from_glib(ffi::g_app_info_supports_uris( self.as_ref().to_glib_none().0, )) } } } impl> AppInfoExt for O {} gio-0.20.1/src/auto/app_info_monitor.rs000064400000000000000000000026321046102023000161340ustar 00000000000000// 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::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GAppInfoMonitor")] pub struct AppInfoMonitor(Object); match fn { type_ => || ffi::g_app_info_monitor_get_type(), } } impl AppInfoMonitor { #[doc(alias = "g_app_info_monitor_get")] pub fn get() -> AppInfoMonitor { unsafe { from_glib_full(ffi::g_app_info_monitor_get()) } } #[doc(alias = "changed")] pub fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline( this: *mut ffi::GAppInfoMonitor, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/auto/app_launch_context.rs000064400000000000000000000155051046102023000164530ustar 00000000000000// 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::{ffi, AppInfo, File}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GAppLaunchContext")] pub struct AppLaunchContext(Object); match fn { type_ => || ffi::g_app_launch_context_get_type(), } } impl AppLaunchContext { pub const NONE: Option<&'static AppLaunchContext> = None; #[doc(alias = "g_app_launch_context_new")] pub fn new() -> AppLaunchContext { unsafe { from_glib_full(ffi::g_app_launch_context_new()) } } } impl Default for AppLaunchContext { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait AppLaunchContextExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_app_launch_context_get_display")] #[doc(alias = "get_display")] fn display(&self, info: &impl IsA, files: &[File]) -> Option { unsafe { from_glib_full(ffi::g_app_launch_context_get_display( self.as_ref().to_glib_none().0, info.as_ref().to_glib_none().0, files.to_glib_none().0, )) } } #[doc(alias = "g_app_launch_context_get_environment")] #[doc(alias = "get_environment")] fn environment(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_launch_context_get_environment( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_app_launch_context_get_startup_notify_id")] #[doc(alias = "get_startup_notify_id")] fn startup_notify_id(&self, info: &impl IsA, files: &[File]) -> Option { unsafe { from_glib_full(ffi::g_app_launch_context_get_startup_notify_id( self.as_ref().to_glib_none().0, info.as_ref().to_glib_none().0, files.to_glib_none().0, )) } } #[doc(alias = "g_app_launch_context_launch_failed")] fn launch_failed(&self, startup_notify_id: &str) { unsafe { ffi::g_app_launch_context_launch_failed( self.as_ref().to_glib_none().0, startup_notify_id.to_glib_none().0, ); } } #[doc(alias = "g_app_launch_context_setenv")] fn setenv(&self, variable: impl AsRef, value: impl AsRef) { unsafe { ffi::g_app_launch_context_setenv( self.as_ref().to_glib_none().0, variable.as_ref().to_glib_none().0, value.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_app_launch_context_unsetenv")] fn unsetenv(&self, variable: impl AsRef) { unsafe { ffi::g_app_launch_context_unsetenv( self.as_ref().to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } #[doc(alias = "launch-failed")] fn connect_launch_failed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn launch_failed_trampoline< P: IsA, F: Fn(&P, &str) + 'static, >( this: *mut ffi::GAppLaunchContext, startup_notify_id: *mut libc::c_char, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( AppLaunchContext::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(startup_notify_id), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"launch-failed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( launch_failed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "launch-started")] fn connect_launch_started) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn launch_started_trampoline< P: IsA, F: Fn(&P, &AppInfo, Option<&glib::Variant>) + 'static, >( this: *mut ffi::GAppLaunchContext, info: *mut ffi::GAppInfo, platform_data: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( AppLaunchContext::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(info), Option::::from_glib_borrow(platform_data) .as_ref() .as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"launch-started\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( launch_started_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "launched")] fn connect_launched( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn launched_trampoline< P: IsA, F: Fn(&P, &AppInfo, &glib::Variant) + 'static, >( this: *mut ffi::GAppLaunchContext, info: *mut ffi::GAppInfo, platform_data: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( AppLaunchContext::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(info), &from_glib_borrow(platform_data), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"launched\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( launched_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> AppLaunchContextExt for O {} gio-0.20.1/src/auto/application.rs000064400000000000000000000654631046102023000151100ustar 00000000000000// 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::{ ffi, ActionGroup, ActionMap, ApplicationCommandLine, ApplicationFlags, Cancellable, DBusConnection, File, Notification, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GApplication")] pub struct Application(Object) @implements ActionGroup, ActionMap; match fn { type_ => || ffi::g_application_get_type(), } } impl Application { pub const NONE: Option<&'static Application> = None; #[doc(alias = "g_application_new")] pub fn new(application_id: Option<&str>, flags: ApplicationFlags) -> Application { unsafe { from_glib_full(ffi::g_application_new( application_id.to_glib_none().0, flags.into_glib(), )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`Application`] objects. /// /// This method returns an instance of [`ApplicationBuilder`](crate::builders::ApplicationBuilder) which can be used to create [`Application`] objects. pub fn builder() -> ApplicationBuilder { ApplicationBuilder::new() } #[doc(alias = "g_application_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> Option { unsafe { from_glib_none(ffi::g_application_get_default()) } } #[doc(alias = "g_application_id_is_valid")] pub fn id_is_valid(application_id: &str) -> bool { unsafe { from_glib(ffi::g_application_id_is_valid( application_id.to_glib_none().0, )) } } } impl Default for Application { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`Application`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ApplicationBuilder { builder: glib::object::ObjectBuilder<'static, Application>, } impl ApplicationBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn application_id(self, application_id: impl Into) -> Self { Self { builder: self .builder .property("application-id", application_id.into()), } } pub fn flags(self, flags: ApplicationFlags) -> Self { Self { builder: self.builder.property("flags", flags), } } pub fn inactivity_timeout(self, inactivity_timeout: u32) -> Self { Self { builder: self .builder .property("inactivity-timeout", inactivity_timeout), } } pub fn resource_base_path(self, resource_base_path: impl Into) -> Self { Self { builder: self .builder .property("resource-base-path", resource_base_path.into()), } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] pub fn version(self, version: impl Into) -> Self { Self { builder: self.builder.property("version", version.into()), } } // rustdoc-stripper-ignore-next /// Build the [`Application`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> Application { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ApplicationExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_application_activate")] fn activate(&self) { unsafe { ffi::g_application_activate(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_application_add_main_option")] fn add_main_option( &self, long_name: &str, short_name: glib::Char, flags: glib::OptionFlags, arg: glib::OptionArg, description: &str, arg_description: Option<&str>, ) { unsafe { ffi::g_application_add_main_option( self.as_ref().to_glib_none().0, long_name.to_glib_none().0, short_name.into_glib(), flags.into_glib(), arg.into_glib(), description.to_glib_none().0, arg_description.to_glib_none().0, ); } } //#[doc(alias = "g_application_add_main_option_entries")] //fn add_main_option_entries(&self, entries: /*Ignored*/&[glib::OptionEntry]) { // unsafe { TODO: call ffi:g_application_add_main_option_entries() } //} //#[doc(alias = "g_application_add_option_group")] //fn add_option_group(&self, group: /*Ignored*/glib::OptionGroup) { // unsafe { TODO: call ffi:g_application_add_option_group() } //} #[doc(alias = "g_application_bind_busy_property")] fn bind_busy_property(&self, object: &impl IsA, property: &str) { unsafe { ffi::g_application_bind_busy_property( self.as_ref().to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, ); } } #[doc(alias = "g_application_get_application_id")] #[doc(alias = "get_application_id")] #[doc(alias = "application-id")] fn application_id(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_application_id( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_dbus_connection")] #[doc(alias = "get_dbus_connection")] fn dbus_connection(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_dbus_connection( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_dbus_object_path")] #[doc(alias = "get_dbus_object_path")] fn dbus_object_path(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_dbus_object_path( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> ApplicationFlags { unsafe { from_glib(ffi::g_application_get_flags(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_application_get_inactivity_timeout")] #[doc(alias = "get_inactivity_timeout")] #[doc(alias = "inactivity-timeout")] fn inactivity_timeout(&self) -> u32 { unsafe { ffi::g_application_get_inactivity_timeout(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_application_get_is_busy")] #[doc(alias = "get_is_busy")] #[doc(alias = "is-busy")] fn is_busy(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_busy( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_is_registered")] #[doc(alias = "get_is_registered")] #[doc(alias = "is-registered")] fn is_registered(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_registered( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_is_remote")] #[doc(alias = "get_is_remote")] #[doc(alias = "is-remote")] fn is_remote(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_remote( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_get_resource_base_path")] #[doc(alias = "get_resource_base_path")] #[doc(alias = "resource-base-path")] fn resource_base_path(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_resource_base_path( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_application_get_version")] #[doc(alias = "get_version")] fn version(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_version( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_open")] fn open(&self, files: &[File], hint: &str) { let n_files = files.len() as _; unsafe { ffi::g_application_open( self.as_ref().to_glib_none().0, files.to_glib_none().0, n_files, hint.to_glib_none().0, ); } } #[doc(alias = "g_application_quit")] fn quit(&self) { unsafe { ffi::g_application_quit(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_application_register")] fn register(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_application_register( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_application_send_notification")] fn send_notification(&self, id: Option<&str>, notification: &Notification) { unsafe { ffi::g_application_send_notification( self.as_ref().to_glib_none().0, id.to_glib_none().0, notification.to_glib_none().0, ); } } #[doc(alias = "g_application_set_application_id")] #[doc(alias = "application-id")] fn set_application_id(&self, application_id: Option<&str>) { unsafe { ffi::g_application_set_application_id( self.as_ref().to_glib_none().0, application_id.to_glib_none().0, ); } } #[doc(alias = "g_application_set_default")] fn set_default(&self) { unsafe { ffi::g_application_set_default(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_application_set_flags")] #[doc(alias = "flags")] fn set_flags(&self, flags: ApplicationFlags) { unsafe { ffi::g_application_set_flags(self.as_ref().to_glib_none().0, flags.into_glib()); } } #[doc(alias = "g_application_set_inactivity_timeout")] #[doc(alias = "inactivity-timeout")] fn set_inactivity_timeout(&self, inactivity_timeout: u32) { unsafe { ffi::g_application_set_inactivity_timeout( self.as_ref().to_glib_none().0, inactivity_timeout, ); } } #[doc(alias = "g_application_set_option_context_description")] fn set_option_context_description(&self, description: Option<&str>) { unsafe { ffi::g_application_set_option_context_description( self.as_ref().to_glib_none().0, description.to_glib_none().0, ); } } #[doc(alias = "g_application_set_option_context_parameter_string")] fn set_option_context_parameter_string(&self, parameter_string: Option<&str>) { unsafe { ffi::g_application_set_option_context_parameter_string( self.as_ref().to_glib_none().0, parameter_string.to_glib_none().0, ); } } #[doc(alias = "g_application_set_option_context_summary")] fn set_option_context_summary(&self, summary: Option<&str>) { unsafe { ffi::g_application_set_option_context_summary( self.as_ref().to_glib_none().0, summary.to_glib_none().0, ); } } #[doc(alias = "g_application_set_resource_base_path")] #[doc(alias = "resource-base-path")] fn set_resource_base_path(&self, resource_path: Option<&str>) { unsafe { ffi::g_application_set_resource_base_path( self.as_ref().to_glib_none().0, resource_path.to_glib_none().0, ); } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_application_set_version")] #[doc(alias = "version")] fn set_version(&self, version: &str) { unsafe { ffi::g_application_set_version( self.as_ref().to_glib_none().0, version.to_glib_none().0, ); } } #[doc(alias = "g_application_unbind_busy_property")] fn unbind_busy_property(&self, object: &impl IsA, property: &str) { unsafe { ffi::g_application_unbind_busy_property( self.as_ref().to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, ); } } #[doc(alias = "g_application_withdraw_notification")] fn withdraw_notification(&self, id: &str) { unsafe { ffi::g_application_withdraw_notification( self.as_ref().to_glib_none().0, id.to_glib_none().0, ); } } #[doc(alias = "activate")] fn connect_activate(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn activate_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"activate\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( activate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "command-line")] fn connect_command_line i32 + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn command_line_trampoline< P: IsA, F: Fn(&P, &ApplicationCommandLine) -> i32 + 'static, >( this: *mut ffi::GApplication, command_line: *mut ffi::GApplicationCommandLine, f: glib::ffi::gpointer, ) -> libc::c_int { let f: &F = &*(f as *const F); f( Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(command_line), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"command-line\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( command_line_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "handle-local-options")] fn connect_handle_local_options i32 + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn handle_local_options_trampoline< P: IsA, F: Fn(&P, &glib::VariantDict) -> i32 + 'static, >( this: *mut ffi::GApplication, options: *mut glib::ffi::GVariantDict, f: glib::ffi::gpointer, ) -> libc::c_int { let f: &F = &*(f as *const F); f( Application::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(options), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"handle-local-options\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( handle_local_options_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "name-lost")] fn connect_name_lost bool + 'static>(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn name_lost_trampoline< P: IsA, F: Fn(&P) -> bool + 'static, >( this: *mut ffi::GApplication, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()).into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"name-lost\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( name_lost_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "shutdown")] fn connect_shutdown(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn shutdown_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"shutdown\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( shutdown_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "startup")] fn connect_startup(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn startup_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"startup\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( startup_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "application-id")] fn connect_application_id_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_application_id_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::application-id\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_application_id_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "flags")] fn connect_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_flags_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::flags\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "inactivity-timeout")] fn connect_inactivity_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_inactivity_timeout_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::inactivity-timeout\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_inactivity_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-busy")] fn connect_is_busy_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_busy_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-busy\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_busy_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-registered")] fn connect_is_registered_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_registered_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-registered\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_registered_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-remote")] fn connect_is_remote_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_remote_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-remote\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_remote_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "resource-base-path")] fn connect_resource_base_path_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_resource_base_path_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::resource-base-path\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_resource_base_path_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "version")] fn connect_version_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_version_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GApplication, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Application::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::version\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_version_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ApplicationExt for O {} gio-0.20.1/src/auto/application_command_line.rs000064400000000000000000000160541046102023000176050ustar 00000000000000// 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::{ffi, File, InputStream}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GApplicationCommandLine")] pub struct ApplicationCommandLine(Object); match fn { type_ => || ffi::g_application_command_line_get_type(), } } impl ApplicationCommandLine { pub const NONE: Option<&'static ApplicationCommandLine> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ApplicationCommandLineExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_application_command_line_create_file_for_arg")] fn create_file_for_arg(&self, arg: impl AsRef) -> File { unsafe { from_glib_full(ffi::g_application_command_line_create_file_for_arg( self.as_ref().to_glib_none().0, arg.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_application_command_line_done")] fn done(&self) { unsafe { ffi::g_application_command_line_done(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_application_command_line_get_arguments")] #[doc(alias = "get_arguments")] fn arguments(&self) -> Vec { unsafe { let mut argc = std::mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_full_num( ffi::g_application_command_line_get_arguments( self.as_ref().to_glib_none().0, argc.as_mut_ptr(), ), argc.assume_init() as _, ); ret } } #[doc(alias = "g_application_command_line_get_cwd")] #[doc(alias = "get_cwd")] fn cwd(&self) -> Option { unsafe { from_glib_none(ffi::g_application_command_line_get_cwd( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_get_environ")] #[doc(alias = "get_environ")] fn environ(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_application_command_line_get_environ( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_get_exit_status")] #[doc(alias = "get_exit_status")] fn exit_status(&self) -> i32 { unsafe { ffi::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_application_command_line_get_is_remote")] #[doc(alias = "get_is_remote")] #[doc(alias = "is-remote")] fn is_remote(&self) -> bool { unsafe { from_glib(ffi::g_application_command_line_get_is_remote( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_get_options_dict")] #[doc(alias = "get_options_dict")] fn options_dict(&self) -> glib::VariantDict { unsafe { from_glib_none(ffi::g_application_command_line_get_options_dict( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_get_platform_data")] #[doc(alias = "get_platform_data")] fn platform_data(&self) -> Option { unsafe { from_glib_full(ffi::g_application_command_line_get_platform_data( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_get_stdin")] #[doc(alias = "get_stdin")] fn stdin(&self) -> Option { unsafe { from_glib_full(ffi::g_application_command_line_get_stdin( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_application_command_line_getenv")] fn getenv(&self, name: impl AsRef) -> Option { unsafe { from_glib_none(ffi::g_application_command_line_getenv( self.as_ref().to_glib_none().0, name.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_application_command_line_print")] //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_application_command_line_print() } //} #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_application_command_line_print_literal")] fn print_literal(&self, message: &str) { unsafe { ffi::g_application_command_line_print_literal( self.as_ref().to_glib_none().0, message.to_glib_none().0, ); } } //#[doc(alias = "g_application_command_line_printerr")] //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_application_command_line_printerr() } //} #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_application_command_line_printerr_literal")] fn printerr_literal(&self, message: &str) { unsafe { ffi::g_application_command_line_printerr_literal( self.as_ref().to_glib_none().0, message.to_glib_none().0, ); } } #[doc(alias = "g_application_command_line_set_exit_status")] fn set_exit_status(&self, exit_status: i32) { unsafe { ffi::g_application_command_line_set_exit_status( self.as_ref().to_glib_none().0, exit_status, ); } } #[doc(alias = "is-remote")] fn connect_is_remote_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_remote_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GApplicationCommandLine, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(ApplicationCommandLine::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-remote\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_remote_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ApplicationCommandLineExt for O {} gio-0.20.1/src/auto/async_initable.rs000064400000000000000000000061711046102023000155600ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GAsyncInitable")] pub struct AsyncInitable(Interface); match fn { type_ => || ffi::g_async_initable_get_type(), } } impl AsyncInitable { pub const NONE: Option<&'static AsyncInitable> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait AsyncInitableExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_async_initable_init_async")] unsafe fn init_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn init_async_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_async_initable_init_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = init_async_trampoline::

; ffi::g_async_initable_init_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } unsafe fn init_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.init_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> AsyncInitableExt for O {} gio-0.20.1/src/auto/async_result.rs000064400000000000000000000037761046102023000153170ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GAsyncResult")] pub struct AsyncResult(Interface); match fn { type_ => || ffi::g_async_result_get_type(), } } impl AsyncResult { pub const NONE: Option<&'static AsyncResult> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait AsyncResultExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_async_result_get_source_object")] #[doc(alias = "get_source_object")] fn source_object(&self) -> Option { unsafe { from_glib_full(ffi::g_async_result_get_source_object( self.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_async_result_get_user_data")] //#[doc(alias = "get_user_data")] //fn user_data(&self) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_async_result_get_user_data() } //} //#[doc(alias = "g_async_result_is_tagged")] //fn is_tagged(&self, source_tag: /*Unimplemented*/Option) -> bool { // unsafe { TODO: call ffi:g_async_result_is_tagged() } //} #[doc(alias = "g_async_result_legacy_propagate_error")] fn legacy_propagate_error(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_async_result_legacy_propagate_error( self.as_ref().to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl> AsyncResultExt for O {} gio-0.20.1/src/auto/buffered_input_stream.rs000064400000000000000000000230411046102023000171430ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, FilterInputStream, InputStream, Seekable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GBufferedInputStream")] pub struct BufferedInputStream(Object) @extends FilterInputStream, InputStream, @implements Seekable; match fn { type_ => || ffi::g_buffered_input_stream_get_type(), } } impl BufferedInputStream { pub const NONE: Option<&'static BufferedInputStream> = None; #[doc(alias = "g_buffered_input_stream_new")] pub fn new(base_stream: &impl IsA) -> BufferedInputStream { unsafe { InputStream::from_glib_full(ffi::g_buffered_input_stream_new( base_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } #[doc(alias = "g_buffered_input_stream_new_sized")] pub fn new_sized(base_stream: &impl IsA, size: usize) -> BufferedInputStream { unsafe { InputStream::from_glib_full(ffi::g_buffered_input_stream_new_sized( base_stream.as_ref().to_glib_none().0, size, )) .unsafe_cast() } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`BufferedInputStream`] objects. /// /// This method returns an instance of [`BufferedInputStreamBuilder`](crate::builders::BufferedInputStreamBuilder) which can be used to create [`BufferedInputStream`] objects. pub fn builder() -> BufferedInputStreamBuilder { BufferedInputStreamBuilder::new() } } impl Default for BufferedInputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`BufferedInputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct BufferedInputStreamBuilder { builder: glib::object::ObjectBuilder<'static, BufferedInputStream>, } impl BufferedInputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn buffer_size(self, buffer_size: u32) -> Self { Self { builder: self.builder.property("buffer-size", buffer_size), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`BufferedInputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> BufferedInputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait BufferedInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_buffered_input_stream_fill")] fn fill( &self, count: isize, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_buffered_input_stream_fill( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_buffered_input_stream_fill_async")] fn fill_async) + 'static>( &self, count: isize, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn fill_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_buffered_input_stream_fill_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = fill_async_trampoline::

; unsafe { ffi::g_buffered_input_stream_fill_async( self.as_ref().to_glib_none().0, count, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn fill_future( &self, count: isize, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.fill_async(count, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_buffered_input_stream_get_available")] #[doc(alias = "get_available")] fn available(&self) -> usize { unsafe { ffi::g_buffered_input_stream_get_available(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_buffered_input_stream_get_buffer_size")] #[doc(alias = "get_buffer_size")] #[doc(alias = "buffer-size")] fn buffer_size(&self) -> usize { unsafe { ffi::g_buffered_input_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_buffered_input_stream_peek_buffer")] fn peek_buffer(&self) -> Vec { unsafe { let mut count = std::mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_none_num( ffi::g_buffered_input_stream_peek_buffer( self.as_ref().to_glib_none().0, count.as_mut_ptr(), ), count.assume_init() as _, ); ret } } #[doc(alias = "g_buffered_input_stream_read_byte")] fn read_byte(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_buffered_input_stream_read_byte( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_buffered_input_stream_set_buffer_size")] #[doc(alias = "buffer-size")] fn set_buffer_size(&self, size: usize) { unsafe { ffi::g_buffered_input_stream_set_buffer_size(self.as_ref().to_glib_none().0, size); } } #[doc(alias = "buffer-size")] fn connect_buffer_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_buffer_size_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GBufferedInputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BufferedInputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::buffer-size\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_buffer_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BufferedInputStreamExt for O {} gio-0.20.1/src/auto/buffered_output_stream.rs000064400000000000000000000155341046102023000173540ustar 00000000000000// 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::{ffi, FilterOutputStream, OutputStream, Seekable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GBufferedOutputStream")] pub struct BufferedOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements Seekable; match fn { type_ => || ffi::g_buffered_output_stream_get_type(), } } impl BufferedOutputStream { pub const NONE: Option<&'static BufferedOutputStream> = None; #[doc(alias = "g_buffered_output_stream_new")] pub fn new(base_stream: &impl IsA) -> BufferedOutputStream { unsafe { OutputStream::from_glib_full(ffi::g_buffered_output_stream_new( base_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } #[doc(alias = "g_buffered_output_stream_new_sized")] pub fn new_sized(base_stream: &impl IsA, size: usize) -> BufferedOutputStream { unsafe { OutputStream::from_glib_full(ffi::g_buffered_output_stream_new_sized( base_stream.as_ref().to_glib_none().0, size, )) .unsafe_cast() } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`BufferedOutputStream`] objects. /// /// This method returns an instance of [`BufferedOutputStreamBuilder`](crate::builders::BufferedOutputStreamBuilder) which can be used to create [`BufferedOutputStream`] objects. pub fn builder() -> BufferedOutputStreamBuilder { BufferedOutputStreamBuilder::new() } } impl Default for BufferedOutputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`BufferedOutputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct BufferedOutputStreamBuilder { builder: glib::object::ObjectBuilder<'static, BufferedOutputStream>, } impl BufferedOutputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn auto_grow(self, auto_grow: bool) -> Self { Self { builder: self.builder.property("auto-grow", auto_grow), } } pub fn buffer_size(self, buffer_size: u32) -> Self { Self { builder: self.builder.property("buffer-size", buffer_size), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`BufferedOutputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> BufferedOutputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait BufferedOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_buffered_output_stream_get_auto_grow")] #[doc(alias = "get_auto_grow")] #[doc(alias = "auto-grow")] fn auto_grows(&self) -> bool { unsafe { from_glib(ffi::g_buffered_output_stream_get_auto_grow( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_buffered_output_stream_get_buffer_size")] #[doc(alias = "get_buffer_size")] #[doc(alias = "buffer-size")] fn buffer_size(&self) -> usize { unsafe { ffi::g_buffered_output_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_buffered_output_stream_set_auto_grow")] #[doc(alias = "auto-grow")] fn set_auto_grow(&self, auto_grow: bool) { unsafe { ffi::g_buffered_output_stream_set_auto_grow( self.as_ref().to_glib_none().0, auto_grow.into_glib(), ); } } #[doc(alias = "g_buffered_output_stream_set_buffer_size")] #[doc(alias = "buffer-size")] fn set_buffer_size(&self, size: usize) { unsafe { ffi::g_buffered_output_stream_set_buffer_size(self.as_ref().to_glib_none().0, size); } } #[doc(alias = "auto-grow")] fn connect_auto_grow_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_auto_grow_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GBufferedOutputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BufferedOutputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::auto-grow\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_auto_grow_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "buffer-size")] fn connect_buffer_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_buffer_size_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GBufferedOutputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(BufferedOutputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::buffer-size\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_buffer_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> BufferedOutputStreamExt for O {} gio-0.20.1/src/auto/bytes_icon.rs000064400000000000000000000014571046102023000147340ustar 00000000000000// 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::{ffi, Icon, LoadableIcon}; use glib::translate::*; glib::wrapper! { #[doc(alias = "GBytesIcon")] pub struct BytesIcon(Object) @implements Icon, LoadableIcon; match fn { type_ => || ffi::g_bytes_icon_get_type(), } } impl BytesIcon { #[doc(alias = "g_bytes_icon_new")] pub fn new(bytes: &glib::Bytes) -> BytesIcon { unsafe { from_glib_full(ffi::g_bytes_icon_new(bytes.to_glib_none().0)) } } #[doc(alias = "g_bytes_icon_get_bytes")] #[doc(alias = "get_bytes")] pub fn bytes(&self) -> glib::Bytes { unsafe { from_glib_none(ffi::g_bytes_icon_get_bytes(self.to_glib_none().0)) } } } gio-0.20.1/src/auto/cancellable.rs000064400000000000000000000047731046102023000150270ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GCancellable")] pub struct Cancellable(Object); match fn { type_ => || ffi::g_cancellable_get_type(), } } impl Cancellable { pub const NONE: Option<&'static Cancellable> = None; #[doc(alias = "g_cancellable_new")] pub fn new() -> Cancellable { unsafe { from_glib_full(ffi::g_cancellable_new()) } } #[doc(alias = "g_cancellable_get_current")] #[doc(alias = "get_current")] pub fn current() -> Option { unsafe { from_glib_none(ffi::g_cancellable_get_current()) } } } impl Default for Cancellable { fn default() -> Self { Self::new() } } unsafe impl Send for Cancellable {} unsafe impl Sync for Cancellable {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait CancellableExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_cancellable_cancel")] fn cancel(&self) { unsafe { ffi::g_cancellable_cancel(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_cancellable_get_fd")] #[doc(alias = "get_fd")] fn fd(&self) -> i32 { unsafe { ffi::g_cancellable_get_fd(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_cancellable_is_cancelled")] fn is_cancelled(&self) -> bool { unsafe { from_glib(ffi::g_cancellable_is_cancelled( self.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_cancellable_make_pollfd")] //fn make_pollfd(&self, pollfd: /*Ignored*/&mut glib::PollFD) -> bool { // unsafe { TODO: call ffi:g_cancellable_make_pollfd() } //} #[doc(alias = "g_cancellable_pop_current")] fn pop_current(&self) { unsafe { ffi::g_cancellable_pop_current(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_cancellable_push_current")] fn push_current(&self) { unsafe { ffi::g_cancellable_push_current(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_cancellable_release_fd")] fn release_fd(&self) { unsafe { ffi::g_cancellable_release_fd(self.as_ref().to_glib_none().0); } } } impl> CancellableExt for O {} gio-0.20.1/src/auto/charset_converter.rs000064400000000000000000000117211046102023000163110ustar 00000000000000// 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::{ffi, Converter, Initable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GCharsetConverter")] pub struct CharsetConverter(Object) @implements Converter, Initable; match fn { type_ => || ffi::g_charset_converter_get_type(), } } impl CharsetConverter { #[doc(alias = "g_charset_converter_new")] pub fn new(to_charset: &str, from_charset: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_charset_converter_new( to_charset.to_glib_none().0, from_charset.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`CharsetConverter`] objects. /// /// This method returns an instance of [`CharsetConverterBuilder`](crate::builders::CharsetConverterBuilder) which can be used to create [`CharsetConverter`] objects. pub fn builder() -> CharsetConverterBuilder { CharsetConverterBuilder::new() } #[doc(alias = "g_charset_converter_get_num_fallbacks")] #[doc(alias = "get_num_fallbacks")] pub fn num_fallbacks(&self) -> u32 { unsafe { ffi::g_charset_converter_get_num_fallbacks(self.to_glib_none().0) } } #[doc(alias = "g_charset_converter_get_use_fallback")] #[doc(alias = "get_use_fallback")] #[doc(alias = "use-fallback")] pub fn uses_fallback(&self) -> bool { unsafe { from_glib(ffi::g_charset_converter_get_use_fallback( self.to_glib_none().0, )) } } #[doc(alias = "g_charset_converter_set_use_fallback")] #[doc(alias = "use-fallback")] pub fn set_use_fallback(&self, use_fallback: bool) { unsafe { ffi::g_charset_converter_set_use_fallback( self.to_glib_none().0, use_fallback.into_glib(), ); } } #[doc(alias = "from-charset")] pub fn from_charset(&self) -> Option { ObjectExt::property(self, "from-charset") } #[doc(alias = "to-charset")] pub fn to_charset(&self) -> Option { ObjectExt::property(self, "to-charset") } #[doc(alias = "use-fallback")] pub fn connect_use_fallback_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_use_fallback_trampoline( this: *mut ffi::GCharsetConverter, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::use-fallback\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_use_fallback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for CharsetConverter { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`CharsetConverter`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct CharsetConverterBuilder { builder: glib::object::ObjectBuilder<'static, CharsetConverter>, } impl CharsetConverterBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn from_charset(self, from_charset: impl Into) -> Self { Self { builder: self.builder.property("from-charset", from_charset.into()), } } pub fn to_charset(self, to_charset: impl Into) -> Self { Self { builder: self.builder.property("to-charset", to_charset.into()), } } pub fn use_fallback(self, use_fallback: bool) -> Self { Self { builder: self.builder.property("use-fallback", use_fallback), } } // rustdoc-stripper-ignore-next /// Build the [`CharsetConverter`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> CharsetConverter { self.builder.build() } } gio-0.20.1/src/auto/constants.rs000064400000000000000000000643021046102023000146100ustar 00000000000000// 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::ffi; use glib::GStr; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME")] pub static DEBUG_CONTROLLER_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_DEBUG_CONTROLLER_EXTENSION_POINT_NAME) }; #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE")] pub static DRIVE_IDENTIFIER_KIND_UNIX_DEVICE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_DELETE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_READ")] pub static FILE_ATTRIBUTE_ACCESS_CAN_READ: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_READ) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME")] pub static FILE_ATTRIBUTE_ACCESS_CAN_RENAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH")] pub static FILE_ATTRIBUTE_ACCESS_CAN_TRASH: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH) }; #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_WRITE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) }; #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE")] pub static FILE_ATTRIBUTE_DOS_IS_ARCHIVE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE) }; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT")] pub static FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT) }; #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_SYSTEM")] pub static FILE_ATTRIBUTE_DOS_IS_SYSTEM: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_DOS_IS_SYSTEM) }; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG")] pub static FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG) }; #[doc(alias = "G_FILE_ATTRIBUTE_ETAG_VALUE")] pub static FILE_ATTRIBUTE_ETAG_VALUE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ETAG_VALUE) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_FREE")] pub static FILE_ATTRIBUTE_FILESYSTEM_FREE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_FREE) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_READONLY")] pub static FILE_ATTRIBUTE_FILESYSTEM_READONLY: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_READONLY) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE")] pub static FILE_ATTRIBUTE_FILESYSTEM_REMOTE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_SIZE")] pub static FILE_ATTRIBUTE_FILESYSTEM_SIZE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_SIZE) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_TYPE")] pub static FILE_ATTRIBUTE_FILESYSTEM_TYPE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_TYPE) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_USED")] pub static FILE_ATTRIBUTE_FILESYSTEM_USED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_USED) }; #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW")] pub static FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW) }; #[doc(alias = "G_FILE_ATTRIBUTE_GVFS_BACKEND")] pub static FILE_ATTRIBUTE_GVFS_BACKEND: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_GVFS_BACKEND) }; #[doc(alias = "G_FILE_ATTRIBUTE_ID_FILE")] pub static FILE_ATTRIBUTE_ID_FILE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ID_FILE) }; #[doc(alias = "G_FILE_ATTRIBUTE_ID_FILESYSTEM")] pub static FILE_ATTRIBUTE_ID_FILESYSTEM: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_ID_FILESYSTEM) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_START: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI")] pub static FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC")] pub static FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE")] pub static FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE")] pub static FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE) }; #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE")] pub static FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE) }; #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_GROUP")] pub static FILE_ATTRIBUTE_OWNER_GROUP: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_OWNER_GROUP) }; #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_USER")] pub static FILE_ATTRIBUTE_OWNER_USER: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_OWNER_USER) }; #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_USER_REAL")] pub static FILE_ATTRIBUTE_OWNER_USER_REAL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_OWNER_USER_REAL) }; #[doc(alias = "G_FILE_ATTRIBUTE_PREVIEW_ICON")] pub static FILE_ATTRIBUTE_PREVIEW_ICON: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_PREVIEW_ICON) }; #[doc(alias = "G_FILE_ATTRIBUTE_RECENT_MODIFIED")] pub static FILE_ATTRIBUTE_RECENT_MODIFIED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_RECENT_MODIFIED) }; #[doc(alias = "G_FILE_ATTRIBUTE_SELINUX_CONTEXT")] pub static FILE_ATTRIBUTE_SELINUX_CONTEXT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_SELINUX_CONTEXT) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE")] pub static FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_COPY_NAME")] pub static FILE_ATTRIBUTE_STANDARD_COPY_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_COPY_NAME) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION")] pub static FILE_ATTRIBUTE_STANDARD_DESCRIPTION: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME")] pub static FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME")] pub static FILE_ATTRIBUTE_STANDARD_EDIT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_ICON")] pub static FILE_ATTRIBUTE_STANDARD_ICON: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_ICON) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP")] pub static FILE_ATTRIBUTE_STANDARD_IS_BACKUP: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN")] pub static FILE_ATTRIBUTE_STANDARD_IS_HIDDEN: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK")] pub static FILE_ATTRIBUTE_STANDARD_IS_SYMLINK: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL")] pub static FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE")] pub static FILE_ATTRIBUTE_STANDARD_IS_VOLATILE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_NAME")] pub static FILE_ATTRIBUTE_STANDARD_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_NAME) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SIZE")] pub static FILE_ATTRIBUTE_STANDARD_SIZE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_SIZE) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER")] pub static FILE_ATTRIBUTE_STANDARD_SORT_ORDER: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON")] pub static FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET")] pub static FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_TARGET_URI")] pub static FILE_ATTRIBUTE_STANDARD_TARGET_URI: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_TARGET_URI) }; #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_TYPE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_STANDARD_TYPE) }; #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE) }; #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE) }; #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE) }; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_ACCESS")] pub static FILE_ATTRIBUTE_TIME_ACCESS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_ACCESS) }; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC")] pub static FILE_ATTRIBUTE_TIME_ACCESS_NSEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_ACCESS_NSEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_ACCESS_USEC")] pub static FILE_ATTRIBUTE_TIME_ACCESS_USEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CHANGED")] pub static FILE_ATTRIBUTE_TIME_CHANGED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CHANGED) }; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CHANGED_NSEC")] pub static FILE_ATTRIBUTE_TIME_CHANGED_NSEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CHANGED_NSEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CHANGED_USEC")] pub static FILE_ATTRIBUTE_TIME_CHANGED_USEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CHANGED_USEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CREATED")] pub static FILE_ATTRIBUTE_TIME_CREATED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CREATED) }; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CREATED_NSEC")] pub static FILE_ATTRIBUTE_TIME_CREATED_NSEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CREATED_NSEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CREATED_USEC")] pub static FILE_ATTRIBUTE_TIME_CREATED_USEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_CREATED_USEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_MODIFIED")] pub static FILE_ATTRIBUTE_TIME_MODIFIED: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_MODIFIED) }; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC")] pub static FILE_ATTRIBUTE_TIME_MODIFIED_NSEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_MODIFIED_NSEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC")] pub static FILE_ATTRIBUTE_TIME_MODIFIED_USEC: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) }; #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_DELETION_DATE")] pub static FILE_ATTRIBUTE_TRASH_DELETION_DATE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TRASH_DELETION_DATE) }; #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT")] pub static FILE_ATTRIBUTE_TRASH_ITEM_COUNT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT) }; #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_ORIG_PATH")] pub static FILE_ATTRIBUTE_TRASH_ORIG_PATH: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_TRASH_ORIG_PATH) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_BLOCKS")] pub static FILE_ATTRIBUTE_UNIX_BLOCKS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_BLOCKS) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE")] pub static FILE_ATTRIBUTE_UNIX_BLOCK_SIZE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_DEVICE")] pub static FILE_ATTRIBUTE_UNIX_DEVICE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_DEVICE) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_GID")] pub static FILE_ATTRIBUTE_UNIX_GID: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_GID) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_INODE")] pub static FILE_ATTRIBUTE_UNIX_INODE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_INODE) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT")] pub static FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_MODE")] pub static FILE_ATTRIBUTE_UNIX_MODE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_MODE) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_NLINK")] pub static FILE_ATTRIBUTE_UNIX_NLINK: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_NLINK) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_RDEV")] pub static FILE_ATTRIBUTE_UNIX_RDEV: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_RDEV) }; #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_UID")] pub static FILE_ATTRIBUTE_UNIX_UID: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_FILE_ATTRIBUTE_UNIX_UID) }; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[doc(alias = "G_MEMORY_MONITOR_EXTENSION_POINT_NAME")] pub static MEMORY_MONITOR_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MEMORY_MONITOR_EXTENSION_POINT_NAME) }; #[doc(alias = "G_MENU_ATTRIBUTE_ACTION")] pub static MENU_ATTRIBUTE_ACTION: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_ATTRIBUTE_ACTION) }; #[doc(alias = "G_MENU_ATTRIBUTE_ACTION_NAMESPACE")] pub static MENU_ATTRIBUTE_ACTION_NAMESPACE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_ATTRIBUTE_ACTION_NAMESPACE) }; #[doc(alias = "G_MENU_ATTRIBUTE_ICON")] pub static MENU_ATTRIBUTE_ICON: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_ATTRIBUTE_ICON) }; #[doc(alias = "G_MENU_ATTRIBUTE_LABEL")] pub static MENU_ATTRIBUTE_LABEL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_ATTRIBUTE_LABEL) }; #[doc(alias = "G_MENU_ATTRIBUTE_TARGET")] pub static MENU_ATTRIBUTE_TARGET: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_ATTRIBUTE_TARGET) }; #[doc(alias = "G_MENU_LINK_SECTION")] pub static MENU_LINK_SECTION: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_LINK_SECTION) }; #[doc(alias = "G_MENU_LINK_SUBMENU")] pub static MENU_LINK_SUBMENU: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_MENU_LINK_SUBMENU) }; #[doc(alias = "G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME")] pub static NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME) }; #[doc(alias = "G_NETWORK_MONITOR_EXTENSION_POINT_NAME")] pub static NETWORK_MONITOR_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_NETWORK_MONITOR_EXTENSION_POINT_NAME) }; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "G_POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME")] pub static POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME) }; #[doc(alias = "G_PROXY_EXTENSION_POINT_NAME")] pub static PROXY_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_PROXY_EXTENSION_POINT_NAME) }; #[doc(alias = "G_PROXY_RESOLVER_EXTENSION_POINT_NAME")] pub static PROXY_RESOLVER_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_PROXY_RESOLVER_EXTENSION_POINT_NAME) }; #[doc(alias = "G_SETTINGS_BACKEND_EXTENSION_POINT_NAME")] pub static SETTINGS_BACKEND_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_SETTINGS_BACKEND_EXTENSION_POINT_NAME) }; #[doc(alias = "G_TLS_BACKEND_EXTENSION_POINT_NAME")] pub static TLS_BACKEND_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TLS_BACKEND_EXTENSION_POINT_NAME) }; #[doc(alias = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT")] pub static TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT) }; #[doc(alias = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER")] pub static TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER) }; #[doc(alias = "G_VFS_EXTENSION_POINT_NAME")] pub static VFS_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VFS_EXTENSION_POINT_NAME) }; #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_CLASS")] pub static VOLUME_IDENTIFIER_KIND_CLASS: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_CLASS) }; #[cfg_attr(feature = "v2_58", deprecated = "Since 2.58")] #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_HAL_UDI")] pub static VOLUME_IDENTIFIER_KIND_HAL_UDI: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_HAL_UDI) }; #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_LABEL")] pub static VOLUME_IDENTIFIER_KIND_LABEL: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_LABEL) }; #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT")] pub static VOLUME_IDENTIFIER_KIND_NFS_MOUNT: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT) }; #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE")] pub static VOLUME_IDENTIFIER_KIND_UNIX_DEVICE: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) }; #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_UUID")] pub static VOLUME_IDENTIFIER_KIND_UUID: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_IDENTIFIER_KIND_UUID) }; #[doc(alias = "G_VOLUME_MONITOR_EXTENSION_POINT_NAME")] pub static VOLUME_MONITOR_EXTENSION_POINT_NAME: &GStr = unsafe { GStr::from_utf8_with_nul_unchecked(ffi::G_VOLUME_MONITOR_EXTENSION_POINT_NAME) }; gio-0.20.1/src/auto/converter.rs000064400000000000000000000027141046102023000146020ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GConverter")] pub struct Converter(Interface); match fn { type_ => || ffi::g_converter_get_type(), } } impl Converter { pub const NONE: Option<&'static Converter> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ConverterExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v2_82")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] #[doc(alias = "g_converter_convert_bytes")] fn convert_bytes(&self, bytes: &glib::Bytes) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_converter_convert_bytes( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_converter_reset")] fn reset(&self) { unsafe { ffi::g_converter_reset(self.as_ref().to_glib_none().0); } } } impl> ConverterExt for O {} gio-0.20.1/src/auto/converter_input_stream.rs000064400000000000000000000072121046102023000173720ustar 00000000000000// 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::{ffi, Converter, FilterInputStream, InputStream, PollableInputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GConverterInputStream")] pub struct ConverterInputStream(Object) @extends FilterInputStream, InputStream, @implements PollableInputStream; match fn { type_ => || ffi::g_converter_input_stream_get_type(), } } impl ConverterInputStream { pub const NONE: Option<&'static ConverterInputStream> = None; #[doc(alias = "g_converter_input_stream_new")] pub fn new( base_stream: &impl IsA, converter: &impl IsA, ) -> ConverterInputStream { unsafe { InputStream::from_glib_full(ffi::g_converter_input_stream_new( base_stream.as_ref().to_glib_none().0, converter.as_ref().to_glib_none().0, )) .unsafe_cast() } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`ConverterInputStream`] objects. /// /// This method returns an instance of [`ConverterInputStreamBuilder`](crate::builders::ConverterInputStreamBuilder) which can be used to create [`ConverterInputStream`] objects. pub fn builder() -> ConverterInputStreamBuilder { ConverterInputStreamBuilder::new() } } impl Default for ConverterInputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`ConverterInputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ConverterInputStreamBuilder { builder: glib::object::ObjectBuilder<'static, ConverterInputStream>, } impl ConverterInputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn converter(self, converter: &impl IsA) -> Self { Self { builder: self .builder .property("converter", converter.clone().upcast()), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`ConverterInputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> ConverterInputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ConverterInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_converter_input_stream_get_converter")] #[doc(alias = "get_converter")] fn converter(&self) -> Converter { unsafe { from_glib_none(ffi::g_converter_input_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl> ConverterInputStreamExt for O {} gio-0.20.1/src/auto/converter_output_stream.rs000064400000000000000000000072611046102023000175770ustar 00000000000000// 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::{ffi, Converter, FilterOutputStream, OutputStream, PollableOutputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GConverterOutputStream")] pub struct ConverterOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements PollableOutputStream; match fn { type_ => || ffi::g_converter_output_stream_get_type(), } } impl ConverterOutputStream { pub const NONE: Option<&'static ConverterOutputStream> = None; #[doc(alias = "g_converter_output_stream_new")] pub fn new( base_stream: &impl IsA, converter: &impl IsA, ) -> ConverterOutputStream { unsafe { OutputStream::from_glib_full(ffi::g_converter_output_stream_new( base_stream.as_ref().to_glib_none().0, converter.as_ref().to_glib_none().0, )) .unsafe_cast() } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`ConverterOutputStream`] objects. /// /// This method returns an instance of [`ConverterOutputStreamBuilder`](crate::builders::ConverterOutputStreamBuilder) which can be used to create [`ConverterOutputStream`] objects. pub fn builder() -> ConverterOutputStreamBuilder { ConverterOutputStreamBuilder::new() } } impl Default for ConverterOutputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`ConverterOutputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ConverterOutputStreamBuilder { builder: glib::object::ObjectBuilder<'static, ConverterOutputStream>, } impl ConverterOutputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn converter(self, converter: &impl IsA) -> Self { Self { builder: self .builder .property("converter", converter.clone().upcast()), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`ConverterOutputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> ConverterOutputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ConverterOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_converter_output_stream_get_converter")] #[doc(alias = "get_converter")] fn converter(&self) -> Converter { unsafe { from_glib_none(ffi::g_converter_output_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl> ConverterOutputStreamExt for O {} gio-0.20.1/src/auto/credentials.rs000064400000000000000000000031561046102023000150710ustar 00000000000000// 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::ffi; use glib::translate::*; glib::wrapper! { #[doc(alias = "GCredentials")] pub struct Credentials(Object); match fn { type_ => || ffi::g_credentials_get_type(), } } impl Credentials { #[doc(alias = "g_credentials_new")] pub fn new() -> Credentials { unsafe { from_glib_full(ffi::g_credentials_new()) } } #[doc(alias = "g_credentials_is_same_user")] pub fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_credentials_is_same_user( self.to_glib_none().0, other_credentials.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_credentials_to_string")] #[doc(alias = "to_string")] pub fn to_str(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_credentials_to_string(self.to_glib_none().0)) } } } impl Default for Credentials { fn default() -> Self { Self::new() } } impl std::fmt::Display for Credentials { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(&self.to_str()) } } gio-0.20.1/src/auto/data_input_stream.rs000064400000000000000000000253771046102023000163100ustar 00000000000000// 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::{ ffi, AsyncResult, BufferedInputStream, Cancellable, DataStreamByteOrder, DataStreamNewlineType, FilterInputStream, InputStream, Seekable, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDataInputStream")] pub struct DataInputStream(Object) @extends BufferedInputStream, FilterInputStream, InputStream, @implements Seekable; match fn { type_ => || ffi::g_data_input_stream_get_type(), } } impl DataInputStream { pub const NONE: Option<&'static DataInputStream> = None; #[doc(alias = "g_data_input_stream_new")] pub fn new(base_stream: &impl IsA) -> DataInputStream { unsafe { from_glib_full(ffi::g_data_input_stream_new( base_stream.as_ref().to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`DataInputStream`] objects. /// /// This method returns an instance of [`DataInputStreamBuilder`](crate::builders::DataInputStreamBuilder) which can be used to create [`DataInputStream`] objects. pub fn builder() -> DataInputStreamBuilder { DataInputStreamBuilder::new() } } impl Default for DataInputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`DataInputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct DataInputStreamBuilder { builder: glib::object::ObjectBuilder<'static, DataInputStream>, } impl DataInputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn byte_order(self, byte_order: DataStreamByteOrder) -> Self { Self { builder: self.builder.property("byte-order", byte_order), } } pub fn newline_type(self, newline_type: DataStreamNewlineType) -> Self { Self { builder: self.builder.property("newline-type", newline_type), } } pub fn buffer_size(self, buffer_size: u32) -> Self { Self { builder: self.builder.property("buffer-size", buffer_size), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`DataInputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> DataInputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DataInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_data_input_stream_get_byte_order")] #[doc(alias = "get_byte_order")] #[doc(alias = "byte-order")] fn byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(ffi::g_data_input_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_data_input_stream_get_newline_type")] #[doc(alias = "get_newline_type")] #[doc(alias = "newline-type")] fn newline_type(&self) -> DataStreamNewlineType { unsafe { from_glib(ffi::g_data_input_stream_get_newline_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_data_input_stream_read_byte")] fn read_byte(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_byte( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_int16")] fn read_int16(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_int16( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_int32")] fn read_int32(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_int32( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_int64")] fn read_int64(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_int64( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_uint16")] fn read_uint16(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_uint16( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_uint32")] fn read_uint32(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_uint32( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_uint64")] fn read_uint64(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_data_input_stream_read_uint64( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_set_byte_order")] #[doc(alias = "byte-order")] fn set_byte_order(&self, order: DataStreamByteOrder) { unsafe { ffi::g_data_input_stream_set_byte_order( self.as_ref().to_glib_none().0, order.into_glib(), ); } } #[doc(alias = "g_data_input_stream_set_newline_type")] #[doc(alias = "newline-type")] fn set_newline_type(&self, type_: DataStreamNewlineType) { unsafe { ffi::g_data_input_stream_set_newline_type( self.as_ref().to_glib_none().0, type_.into_glib(), ); } } #[doc(alias = "byte-order")] fn connect_byte_order_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_byte_order_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GDataInputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataInputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::byte-order\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_byte_order_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "newline-type")] fn connect_newline_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_newline_type_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GDataInputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataInputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::newline-type\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_newline_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DataInputStreamExt for O {} gio-0.20.1/src/auto/data_output_stream.rs000064400000000000000000000246621046102023000165050ustar 00000000000000// 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::{ffi, Cancellable, DataStreamByteOrder, FilterOutputStream, OutputStream, Seekable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDataOutputStream")] pub struct DataOutputStream(Object) @extends FilterOutputStream, OutputStream, @implements Seekable; match fn { type_ => || ffi::g_data_output_stream_get_type(), } } impl DataOutputStream { pub const NONE: Option<&'static DataOutputStream> = None; #[doc(alias = "g_data_output_stream_new")] pub fn new(base_stream: &impl IsA) -> DataOutputStream { unsafe { from_glib_full(ffi::g_data_output_stream_new( base_stream.as_ref().to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`DataOutputStream`] objects. /// /// This method returns an instance of [`DataOutputStreamBuilder`](crate::builders::DataOutputStreamBuilder) which can be used to create [`DataOutputStream`] objects. pub fn builder() -> DataOutputStreamBuilder { DataOutputStreamBuilder::new() } } impl Default for DataOutputStream { fn default() -> Self { glib::object::Object::new::() } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`DataOutputStream`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct DataOutputStreamBuilder { builder: glib::object::ObjectBuilder<'static, DataOutputStream>, } impl DataOutputStreamBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn byte_order(self, byte_order: DataStreamByteOrder) -> Self { Self { builder: self.builder.property("byte-order", byte_order), } } pub fn base_stream(self, base_stream: &impl IsA) -> Self { Self { builder: self .builder .property("base-stream", base_stream.clone().upcast()), } } pub fn close_base_stream(self, close_base_stream: bool) -> Self { Self { builder: self .builder .property("close-base-stream", close_base_stream), } } // rustdoc-stripper-ignore-next /// Build the [`DataOutputStream`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> DataOutputStream { self.builder.build() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DataOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_data_output_stream_get_byte_order")] #[doc(alias = "get_byte_order")] #[doc(alias = "byte-order")] fn byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(ffi::g_data_output_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_data_output_stream_put_byte")] fn put_byte( &self, data: u8, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_byte( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_int16")] fn put_int16( &self, data: i16, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_int16( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_int32")] fn put_int32( &self, data: i32, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_int32( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_int64")] fn put_int64( &self, data: i64, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_int64( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_string")] fn put_string( &self, str: &str, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_string( self.as_ref().to_glib_none().0, str.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_uint16")] fn put_uint16( &self, data: u16, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_uint16( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_uint32")] fn put_uint32( &self, data: u32, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_uint32( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_put_uint64")] fn put_uint64( &self, data: u64, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_data_output_stream_put_uint64( self.as_ref().to_glib_none().0, data, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_output_stream_set_byte_order")] #[doc(alias = "byte-order")] fn set_byte_order(&self, order: DataStreamByteOrder) { unsafe { ffi::g_data_output_stream_set_byte_order( self.as_ref().to_glib_none().0, order.into_glib(), ); } } #[doc(alias = "byte-order")] fn connect_byte_order_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_byte_order_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GDataOutputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DataOutputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::byte-order\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_byte_order_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DataOutputStreamExt for O {} gio-0.20.1/src/auto/datagram_based.rs000064400000000000000000000020561046102023000155100ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GDatagramBased")] pub struct DatagramBased(Interface); match fn { type_ => || ffi::g_datagram_based_get_type(), } } impl DatagramBased { pub const NONE: Option<&'static DatagramBased> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DatagramBasedExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_datagram_based_condition_check")] fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition { unsafe { from_glib(ffi::g_datagram_based_condition_check( self.as_ref().to_glib_none().0, condition.into_glib(), )) } } } impl> DatagramBasedExt for O {} gio-0.20.1/src/auto/dbus_action_group.rs000064400000000000000000000016321046102023000162770ustar 00000000000000// 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::{ffi, ActionGroup, DBusConnection, RemoteActionGroup}; use glib::translate::*; glib::wrapper! { #[doc(alias = "GDBusActionGroup")] pub struct DBusActionGroup(Object) @implements ActionGroup, RemoteActionGroup; match fn { type_ => || ffi::g_dbus_action_group_get_type(), } } impl DBusActionGroup { #[doc(alias = "g_dbus_action_group_get")] pub fn get( connection: &DBusConnection, bus_name: Option<&str>, object_path: &str, ) -> DBusActionGroup { unsafe { from_glib_full(ffi::g_dbus_action_group_get( connection.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, )) } } } gio-0.20.1/src/auto/dbus_arg_info.rs000064400000000000000000000007271046102023000153760ustar 00000000000000// 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::ffi; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusArgInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_arg_info_ref(ptr), unref => |ptr| ffi::g_dbus_arg_info_unref(ptr), type_ => || ffi::g_dbus_arg_info_get_type(), } } gio-0.20.1/src/auto/dbus_auth_observer.rs000064400000000000000000000077171046102023000164700ustar 00000000000000// 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::{ffi, Credentials, IOStream}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusAuthObserver")] pub struct DBusAuthObserver(Object); match fn { type_ => || ffi::g_dbus_auth_observer_get_type(), } } impl DBusAuthObserver { #[doc(alias = "g_dbus_auth_observer_new")] pub fn new() -> DBusAuthObserver { unsafe { from_glib_full(ffi::g_dbus_auth_observer_new()) } } #[doc(alias = "g_dbus_auth_observer_allow_mechanism")] pub fn allow_mechanism(&self, mechanism: &str) -> bool { unsafe { from_glib(ffi::g_dbus_auth_observer_allow_mechanism( self.to_glib_none().0, mechanism.to_glib_none().0, )) } } #[doc(alias = "g_dbus_auth_observer_authorize_authenticated_peer")] pub fn authorize_authenticated_peer( &self, stream: &impl IsA, credentials: Option<&Credentials>, ) -> bool { unsafe { from_glib(ffi::g_dbus_auth_observer_authorize_authenticated_peer( self.to_glib_none().0, stream.as_ref().to_glib_none().0, credentials.to_glib_none().0, )) } } #[doc(alias = "allow-mechanism")] pub fn connect_allow_mechanism bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn allow_mechanism_trampoline< F: Fn(&DBusAuthObserver, &str) -> bool + 'static, >( this: *mut ffi::GDBusAuthObserver, mechanism: *mut libc::c_char, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), &glib::GString::from_glib_borrow(mechanism), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"allow-mechanism\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( allow_mechanism_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "authorize-authenticated-peer")] pub fn connect_authorize_authenticated_peer< F: Fn(&Self, &IOStream, Option<&Credentials>) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn authorize_authenticated_peer_trampoline< F: Fn(&DBusAuthObserver, &IOStream, Option<&Credentials>) -> bool + 'static, >( this: *mut ffi::GDBusAuthObserver, stream: *mut ffi::GIOStream, credentials: *mut ffi::GCredentials, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), &from_glib_borrow(stream), Option::::from_glib_borrow(credentials) .as_ref() .as_ref(), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"authorize-authenticated-peer\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( authorize_authenticated_peer_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for DBusAuthObserver { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/dbus_connection.rs000064400000000000000000001173451046102023000157560ustar 00000000000000// 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(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use crate::UnixFDList; use crate::{ ffi, AsyncInitable, AsyncResult, Cancellable, Credentials, DBusAuthObserver, DBusCallFlags, DBusCapabilityFlags, DBusConnectionFlags, DBusMessage, DBusSendMessageFlags, IOStream, Initable, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GDBusConnection")] pub struct DBusConnection(Object) @implements AsyncInitable, Initable; match fn { type_ => || ffi::g_dbus_connection_get_type(), } } impl DBusConnection { #[doc(alias = "g_dbus_connection_new_for_address_sync")] #[doc(alias = "new_for_address_sync")] pub fn for_address_sync( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_new_for_address_sync( address.to_glib_none().0, flags.into_glib(), observer.to_glib_none().0, cancellable.map(|p| p.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_dbus_connection_new_sync")] pub fn new_sync( stream: &impl IsA, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_new_sync( stream.as_ref().to_glib_none().0, guid.to_glib_none().0, flags.into_glib(), observer.to_glib_none().0, cancellable.map(|p| p.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_dbus_connection_call")] pub fn call) + 'static>( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_call_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = call_trampoline::

; unsafe { ffi::g_dbus_connection_call( self.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, reply_type.to_glib_none().0, flags.into_glib(), timeout_msec, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn call_future( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, ) -> Pin> + 'static>> { let bus_name = bus_name.map(ToOwned::to_owned); let object_path = String::from(object_path); let interface_name = String::from(interface_name); let method_name = String::from(method_name); let parameters = parameters.map(ToOwned::to_owned); let reply_type = reply_type.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.call( bus_name.as_ref().map(::std::borrow::Borrow::borrow), &object_path, &interface_name, &method_name, parameters.as_ref().map(::std::borrow::Borrow::borrow), reply_type.as_ref().map(::std::borrow::Borrow::borrow), flags, timeout_msec, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_dbus_connection_call_sync")] pub fn call_sync( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_call_sync( self.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, reply_type.to_glib_none().0, flags.into_glib(), timeout_msec, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_connection_call_with_unix_fd_list")] pub fn call_with_unix_fd_list< P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, >( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_with_unix_fd_list_trampoline< P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut out_fd_list = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_call_with_unix_fd_list_finish( _source_object as *mut _, &mut out_fd_list, res, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_fd_list))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = call_with_unix_fd_list_trampoline::

; unsafe { ffi::g_dbus_connection_call_with_unix_fd_list( self.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, reply_type.to_glib_none().0, flags.into_glib(), timeout_msec, fd_list.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub fn call_with_unix_fd_list_future( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&(impl IsA + Clone + 'static)>, ) -> Pin< Box_< dyn std::future::Future> + 'static, >, > { let bus_name = bus_name.map(ToOwned::to_owned); let object_path = String::from(object_path); let interface_name = String::from(interface_name); let method_name = String::from(method_name); let parameters = parameters.map(ToOwned::to_owned); let reply_type = reply_type.map(ToOwned::to_owned); let fd_list = fd_list.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.call_with_unix_fd_list( bus_name.as_ref().map(::std::borrow::Borrow::borrow), &object_path, &interface_name, &method_name, parameters.as_ref().map(::std::borrow::Borrow::borrow), reply_type.as_ref().map(::std::borrow::Borrow::borrow), flags, timeout_msec, fd_list.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_connection_call_with_unix_fd_list_sync")] pub fn call_with_unix_fd_list_sync( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&glib::Variant>, reply_type: Option<&glib::VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, ) -> Result<(glib::Variant, UnixFDList), glib::Error> { unsafe { let mut out_fd_list = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_call_with_unix_fd_list_sync( self.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, reply_type.to_glib_none().0, flags.into_glib(), timeout_msec, fd_list.map(|p| p.as_ref()).to_glib_none().0, &mut out_fd_list, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_fd_list))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_close")] pub fn close) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn close_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_dbus_connection_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = close_trampoline::

; unsafe { ffi::g_dbus_connection_close( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn close_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.close(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_dbus_connection_close_sync")] pub fn close_sync( &self, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_connection_close_sync( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_emit_signal")] pub fn emit_signal( &self, destination_bus_name: Option<&str>, object_path: &str, interface_name: &str, signal_name: &str, parameters: Option<&glib::Variant>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_connection_emit_signal( self.to_glib_none().0, destination_bus_name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, signal_name.to_glib_none().0, parameters.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_flush")] pub fn flush) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn flush_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_dbus_connection_flush_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = flush_trampoline::

; unsafe { ffi::g_dbus_connection_flush( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn flush_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.flush(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_dbus_connection_flush_sync")] pub fn flush_sync( &self, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_connection_flush_sync( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_get_capabilities")] #[doc(alias = "get_capabilities")] pub fn capabilities(&self) -> DBusCapabilityFlags { unsafe { from_glib(ffi::g_dbus_connection_get_capabilities( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_connection_get_exit_on_close")] #[doc(alias = "get_exit_on_close")] #[doc(alias = "exit-on-close")] pub fn exits_on_close(&self) -> bool { unsafe { from_glib(ffi::g_dbus_connection_get_exit_on_close( self.to_glib_none().0, )) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_dbus_connection_get_flags")] #[doc(alias = "get_flags")] pub fn flags(&self) -> DBusConnectionFlags { unsafe { from_glib(ffi::g_dbus_connection_get_flags(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_connection_get_guid")] #[doc(alias = "get_guid")] pub fn guid(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_connection_get_guid(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_connection_get_last_serial")] #[doc(alias = "get_last_serial")] pub fn last_serial(&self) -> u32 { unsafe { ffi::g_dbus_connection_get_last_serial(self.to_glib_none().0) } } #[doc(alias = "g_dbus_connection_get_peer_credentials")] #[doc(alias = "get_peer_credentials")] pub fn peer_credentials(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_connection_get_peer_credentials( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_connection_get_stream")] #[doc(alias = "get_stream")] pub fn stream(&self) -> IOStream { unsafe { from_glib_none(ffi::g_dbus_connection_get_stream(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_connection_get_unique_name")] #[doc(alias = "get_unique_name")] #[doc(alias = "unique-name")] pub fn unique_name(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_connection_get_unique_name( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_connection_is_closed")] #[doc(alias = "closed")] pub fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_dbus_connection_is_closed(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_connection_send_message")] pub fn send_message( &self, message: &DBusMessage, flags: DBusSendMessageFlags, ) -> Result { unsafe { let mut out_serial = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_connection_send_message( self.to_glib_none().0, message.to_glib_none().0, flags.into_glib(), out_serial.as_mut_ptr(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(out_serial.assume_init()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_send_message_with_reply")] pub fn send_message_with_reply) + 'static>( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, callback: P, ) -> u32 { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn send_message_with_reply_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_send_message_with_reply_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = send_message_with_reply_trampoline::

; unsafe { let mut out_serial = std::mem::MaybeUninit::uninit(); ffi::g_dbus_connection_send_message_with_reply( self.to_glib_none().0, message.to_glib_none().0, flags.into_glib(), timeout_msec, out_serial.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); out_serial.assume_init() } } pub fn send_message_with_reply_future( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, ) -> Pin> + 'static>> { let message = message.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.send_message_with_reply( &message, flags, timeout_msec, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_dbus_connection_send_message_with_reply_sync")] pub fn send_message_with_reply_sync( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, ) -> Result<(DBusMessage, u32), glib::Error> { unsafe { let mut out_serial = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_send_message_with_reply_sync( self.to_glib_none().0, message.to_glib_none().0, flags.into_glib(), timeout_msec, out_serial.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), out_serial.assume_init())) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_set_exit_on_close")] #[doc(alias = "exit-on-close")] pub fn set_exit_on_close(&self, exit_on_close: bool) { unsafe { ffi::g_dbus_connection_set_exit_on_close( self.to_glib_none().0, exit_on_close.into_glib(), ); } } #[doc(alias = "g_dbus_connection_start_message_processing")] pub fn start_message_processing(&self) { unsafe { ffi::g_dbus_connection_start_message_processing(self.to_glib_none().0); } } #[cfg(not(feature = "v2_60"))] #[cfg_attr(docsrs, doc(cfg(not(feature = "v2_60"))))] pub fn flags(&self) -> DBusConnectionFlags { ObjectExt::property(self, "flags") } #[doc(alias = "g_dbus_connection_new")] pub fn new) + 'static>( stream: &impl IsA, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn new_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_new_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = new_trampoline::

; unsafe { ffi::g_dbus_connection_new( stream.as_ref().to_glib_none().0, guid.to_glib_none().0, flags.into_glib(), observer.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn new_future( stream: &(impl IsA + Clone + 'static), guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, ) -> Pin> + 'static>> { let stream = stream.clone(); let guid = guid.map(ToOwned::to_owned); let observer = observer.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::new( &stream, guid.as_ref().map(::std::borrow::Borrow::borrow), flags, observer.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_dbus_connection_new_for_address")] #[doc(alias = "new_for_address")] pub fn for_address) + 'static>( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn for_address_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_connection_new_for_address_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = for_address_trampoline::

; unsafe { ffi::g_dbus_connection_new_for_address( address.to_glib_none().0, flags.into_glib(), observer.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn for_address_future( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, ) -> Pin> + 'static>> { let address = String::from(address); let observer = observer.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::for_address( &address, flags, observer.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "closed")] pub fn connect_closed) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn closed_trampoline< F: Fn(&DBusConnection, bool, Option<&glib::Error>) + Send + Sync + 'static, >( this: *mut ffi::GDBusConnection, remote_peer_vanished: glib::ffi::gboolean, error: *mut glib::ffi::GError, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), from_glib(remote_peer_vanished), Option::::from_glib_borrow(error) .as_ref() .as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"closed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "capabilities")] pub fn connect_capabilities_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_capabilities_trampoline< F: Fn(&DBusConnection) + Send + Sync + 'static, >( this: *mut ffi::GDBusConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::capabilities\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_capabilities_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "closed")] pub fn connect_closed_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_closed_trampoline< F: Fn(&DBusConnection) + Send + Sync + 'static, >( this: *mut ffi::GDBusConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::closed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "exit-on-close")] pub fn connect_exit_on_close_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_exit_on_close_trampoline< F: Fn(&DBusConnection) + Send + Sync + 'static, >( this: *mut ffi::GDBusConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::exit-on-close\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_exit_on_close_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "unique-name")] pub fn connect_unique_name_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_unique_name_trampoline< F: Fn(&DBusConnection) + Send + Sync + 'static, >( this: *mut ffi::GDBusConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::unique-name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_unique_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } unsafe impl Send for DBusConnection {} unsafe impl Sync for DBusConnection {} gio-0.20.1/src/auto/dbus_interface.rs000064400000000000000000000031541046102023000155470ustar 00000000000000// 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::{ffi, DBusInterfaceInfo, DBusObject}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GDBusInterface")] pub struct DBusInterface(Interface); match fn { type_ => || ffi::g_dbus_interface_get_type(), } } impl DBusInterface { pub const NONE: Option<&'static DBusInterface> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusInterfaceExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_dbus_interface_dup_object")] #[doc(alias = "dup_object")] fn get(&self) -> Option { unsafe { from_glib_full(ffi::g_dbus_interface_dup_object( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_get_info")] #[doc(alias = "get_info")] fn info(&self) -> DBusInterfaceInfo { unsafe { from_glib_none(ffi::g_dbus_interface_get_info( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_set_object")] fn set_object(&self, object: Option<&impl IsA>) { unsafe { ffi::g_dbus_interface_set_object( self.as_ref().to_glib_none().0, object.map(|p| p.as_ref()).to_glib_none().0, ); } } } impl> DBusInterfaceExt for O {} gio-0.20.1/src/auto/dbus_interface_info.rs000064400000000000000000000034411046102023000165610ustar 00000000000000// 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::{ffi, DBusMethodInfo, DBusPropertyInfo, DBusSignalInfo}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusInterfaceInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_interface_info_ref(ptr), unref => |ptr| ffi::g_dbus_interface_info_unref(ptr), type_ => || ffi::g_dbus_interface_info_get_type(), } } impl DBusInterfaceInfo { //#[doc(alias = "g_dbus_interface_info_generate_xml")] //pub fn generate_xml(&self, indent: u32, string_builder: /*Ignored*/&mut glib::String) { // unsafe { TODO: call ffi:g_dbus_interface_info_generate_xml() } //} #[doc(alias = "g_dbus_interface_info_lookup_method")] pub fn lookup_method(&self, name: &str) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_info_lookup_method( self.to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_info_lookup_property")] pub fn lookup_property(&self, name: &str) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_info_lookup_property( self.to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_info_lookup_signal")] pub fn lookup_signal(&self, name: &str) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_info_lookup_signal( self.to_glib_none().0, name.to_glib_none().0, )) } } } gio-0.20.1/src/auto/dbus_interface_skeleton.rs000064400000000000000000000171261046102023000174570ustar 00000000000000// 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::{ ffi, DBusConnection, DBusInterface, DBusInterfaceInfo, DBusInterfaceSkeletonFlags, DBusMethodInvocation, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusInterfaceSkeleton")] pub struct DBusInterfaceSkeleton(Object) @implements DBusInterface; match fn { type_ => || ffi::g_dbus_interface_skeleton_get_type(), } } impl DBusInterfaceSkeleton { pub const NONE: Option<&'static DBusInterfaceSkeleton> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusInterfaceSkeletonExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_dbus_interface_skeleton_export")] fn export(&self, connection: &DBusConnection, object_path: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_interface_skeleton_export( self.as_ref().to_glib_none().0, connection.to_glib_none().0, object_path.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_interface_skeleton_flush")] fn flush(&self) { unsafe { ffi::g_dbus_interface_skeleton_flush(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_dbus_interface_skeleton_get_connection")] #[doc(alias = "get_connection")] fn connection(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_skeleton_get_connection( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_get_connections")] #[doc(alias = "get_connections")] fn connections(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_interface_skeleton_get_connections( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> DBusInterfaceSkeletonFlags { unsafe { from_glib(ffi::g_dbus_interface_skeleton_get_flags( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_get_info")] #[doc(alias = "get_info")] fn info(&self) -> DBusInterfaceInfo { unsafe { from_glib_none(ffi::g_dbus_interface_skeleton_get_info( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_skeleton_get_object_path( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_get_properties")] #[doc(alias = "get_properties")] fn properties(&self) -> glib::Variant { unsafe { from_glib_full(ffi::g_dbus_interface_skeleton_get_properties( self.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_dbus_interface_skeleton_get_vtable")] //#[doc(alias = "get_vtable")] //fn vtable(&self) -> /*Ignored*/DBusInterfaceVTable { // unsafe { TODO: call ffi:g_dbus_interface_skeleton_get_vtable() } //} #[doc(alias = "g_dbus_interface_skeleton_has_connection")] fn has_connection(&self, connection: &DBusConnection) -> bool { unsafe { from_glib(ffi::g_dbus_interface_skeleton_has_connection( self.as_ref().to_glib_none().0, connection.to_glib_none().0, )) } } #[doc(alias = "g_dbus_interface_skeleton_set_flags")] fn set_flags(&self, flags: DBusInterfaceSkeletonFlags) { unsafe { ffi::g_dbus_interface_skeleton_set_flags( self.as_ref().to_glib_none().0, flags.into_glib(), ); } } #[doc(alias = "g_dbus_interface_skeleton_unexport")] fn unexport(&self) { unsafe { ffi::g_dbus_interface_skeleton_unexport(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_dbus_interface_skeleton_unexport_from_connection")] fn unexport_from_connection(&self, connection: &DBusConnection) { unsafe { ffi::g_dbus_interface_skeleton_unexport_from_connection( self.as_ref().to_glib_none().0, connection.to_glib_none().0, ); } } #[doc(alias = "g-flags")] fn g_flags(&self) -> DBusInterfaceSkeletonFlags { ObjectExt::property(self.as_ref(), "g-flags") } #[doc(alias = "g-flags")] fn set_g_flags(&self, g_flags: DBusInterfaceSkeletonFlags) { ObjectExt::set_property(self.as_ref(), "g-flags", g_flags) } #[doc(alias = "g-authorize-method")] fn connect_g_authorize_method bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn g_authorize_method_trampoline< P: IsA, F: Fn(&P, &DBusMethodInvocation) -> bool + 'static, >( this: *mut ffi::GDBusInterfaceSkeleton, invocation: *mut ffi::GDBusMethodInvocation, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( DBusInterfaceSkeleton::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(invocation), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"g-authorize-method\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( g_authorize_method_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "g-flags")] fn connect_g_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_g_flags_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GDBusInterfaceSkeleton, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DBusInterfaceSkeleton::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::g-flags\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_g_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DBusInterfaceSkeletonExt for O {} gio-0.20.1/src/auto/dbus_menu_model.rs000064400000000000000000000015351046102023000157340ustar 00000000000000// 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::{ffi, DBusConnection, MenuModel}; use glib::translate::*; glib::wrapper! { #[doc(alias = "GDBusMenuModel")] pub struct DBusMenuModel(Object) @extends MenuModel; match fn { type_ => || ffi::g_dbus_menu_model_get_type(), } } impl DBusMenuModel { #[doc(alias = "g_dbus_menu_model_get")] pub fn get( connection: &DBusConnection, bus_name: Option<&str>, object_path: &str, ) -> DBusMenuModel { unsafe { from_glib_full(ffi::g_dbus_menu_model_get( connection.to_glib_none().0, bus_name.to_glib_none().0, object_path.to_glib_none().0, )) } } } gio-0.20.1/src/auto/dbus_message.rs000064400000000000000000000366561046102023000152500ustar 00000000000000// 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(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use crate::UnixFDList; use crate::{ ffi, DBusCapabilityFlags, DBusMessageByteOrder, DBusMessageFlags, DBusMessageHeaderField, DBusMessageType, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusMessage")] pub struct DBusMessage(Object); match fn { type_ => || ffi::g_dbus_message_get_type(), } } impl DBusMessage { #[doc(alias = "g_dbus_message_new")] pub fn new() -> DBusMessage { unsafe { from_glib_full(ffi::g_dbus_message_new()) } } #[doc(alias = "g_dbus_message_new_from_blob")] #[doc(alias = "new_from_blob")] pub fn from_blob( blob: &[u8], capabilities: DBusCapabilityFlags, ) -> Result { let blob_len = blob.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_message_new_from_blob( blob.to_glib_none().0, blob_len, capabilities.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_message_new_method_call")] pub fn new_method_call( name: Option<&str>, path: &str, interface_: Option<&str>, method: &str, ) -> DBusMessage { unsafe { from_glib_full(ffi::g_dbus_message_new_method_call( name.to_glib_none().0, path.to_glib_none().0, interface_.to_glib_none().0, method.to_glib_none().0, )) } } #[doc(alias = "g_dbus_message_new_signal")] pub fn new_signal(path: &str, interface_: &str, signal: &str) -> DBusMessage { unsafe { from_glib_full(ffi::g_dbus_message_new_signal( path.to_glib_none().0, interface_.to_glib_none().0, signal.to_glib_none().0, )) } } #[doc(alias = "g_dbus_message_copy")] pub fn copy(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_message_copy(self.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_message_get_arg0")] #[doc(alias = "get_arg0")] pub fn arg0(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_arg0(self.to_glib_none().0)) } } #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "g_dbus_message_get_arg0_path")] #[doc(alias = "get_arg0_path")] pub fn arg0_path(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_arg0_path(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_body")] #[doc(alias = "get_body")] pub fn body(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_body(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_byte_order")] #[doc(alias = "get_byte_order")] pub fn byte_order(&self) -> DBusMessageByteOrder { unsafe { from_glib(ffi::g_dbus_message_get_byte_order(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_destination")] #[doc(alias = "get_destination")] pub fn destination(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_destination(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_error_name")] #[doc(alias = "get_error_name")] pub fn error_name(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_error_name(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_flags")] #[doc(alias = "get_flags")] pub fn flags(&self) -> DBusMessageFlags { unsafe { from_glib(ffi::g_dbus_message_get_flags(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_header")] #[doc(alias = "get_header")] pub fn header(&self, header_field: DBusMessageHeaderField) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_header( self.to_glib_none().0, header_field.into_glib(), )) } } #[doc(alias = "g_dbus_message_get_interface")] #[doc(alias = "get_interface")] pub fn interface(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_interface(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_locked")] #[doc(alias = "get_locked")] #[doc(alias = "locked")] pub fn is_locked(&self) -> bool { unsafe { from_glib(ffi::g_dbus_message_get_locked(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_member")] #[doc(alias = "get_member")] pub fn member(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_member(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_message_type")] #[doc(alias = "get_message_type")] pub fn message_type(&self) -> DBusMessageType { unsafe { from_glib(ffi::g_dbus_message_get_message_type(self.to_glib_none().0)) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_message_get_num_unix_fds")] #[doc(alias = "get_num_unix_fds")] pub fn num_unix_fds(&self) -> u32 { unsafe { ffi::g_dbus_message_get_num_unix_fds(self.to_glib_none().0) } } #[doc(alias = "g_dbus_message_get_path")] #[doc(alias = "get_path")] pub fn path(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_path(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_reply_serial")] #[doc(alias = "get_reply_serial")] pub fn reply_serial(&self) -> u32 { unsafe { ffi::g_dbus_message_get_reply_serial(self.to_glib_none().0) } } #[doc(alias = "g_dbus_message_get_sender")] #[doc(alias = "get_sender")] pub fn sender(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_sender(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_get_serial")] #[doc(alias = "get_serial")] pub fn serial(&self) -> u32 { unsafe { ffi::g_dbus_message_get_serial(self.to_glib_none().0) } } #[doc(alias = "g_dbus_message_get_signature")] #[doc(alias = "get_signature")] pub fn signature(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_message_get_signature(self.to_glib_none().0)) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_message_get_unix_fd_list")] #[doc(alias = "get_unix_fd_list")] pub fn unix_fd_list(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_message_get_unix_fd_list(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_lock")] pub fn lock(&self) { unsafe { ffi::g_dbus_message_lock(self.to_glib_none().0); } } //#[doc(alias = "g_dbus_message_new_method_error")] //#[must_use] //pub fn new_method_error(&self, error_name: &str, error_message_format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> DBusMessage { // unsafe { TODO: call ffi:g_dbus_message_new_method_error() } //} #[doc(alias = "g_dbus_message_new_method_error_literal")] #[must_use] pub fn new_method_error_literal(&self, error_name: &str, error_message: &str) -> DBusMessage { unsafe { from_glib_full(ffi::g_dbus_message_new_method_error_literal( self.to_glib_none().0, error_name.to_glib_none().0, error_message.to_glib_none().0, )) } } //#[doc(alias = "g_dbus_message_new_method_error_valist")] //#[must_use] //pub fn new_method_error_valist(&self, error_name: &str, error_message_format: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> DBusMessage { // unsafe { TODO: call ffi:g_dbus_message_new_method_error_valist() } //} #[doc(alias = "g_dbus_message_new_method_reply")] #[must_use] pub fn new_method_reply(&self) -> DBusMessage { unsafe { from_glib_full(ffi::g_dbus_message_new_method_reply(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_message_print")] pub fn print(&self, indent: u32) -> glib::GString { unsafe { from_glib_full(ffi::g_dbus_message_print(self.to_glib_none().0, indent)) } } #[doc(alias = "g_dbus_message_set_body")] pub fn set_body(&self, body: &glib::Variant) { unsafe { ffi::g_dbus_message_set_body(self.to_glib_none().0, body.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_byte_order")] pub fn set_byte_order(&self, byte_order: DBusMessageByteOrder) { unsafe { ffi::g_dbus_message_set_byte_order(self.to_glib_none().0, byte_order.into_glib()); } } #[doc(alias = "g_dbus_message_set_destination")] pub fn set_destination(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_destination(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_error_name")] pub fn set_error_name(&self, value: &str) { unsafe { ffi::g_dbus_message_set_error_name(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_flags")] pub fn set_flags(&self, flags: DBusMessageFlags) { unsafe { ffi::g_dbus_message_set_flags(self.to_glib_none().0, flags.into_glib()); } } #[doc(alias = "g_dbus_message_set_header")] pub fn set_header(&self, header_field: DBusMessageHeaderField, value: Option<&glib::Variant>) { unsafe { ffi::g_dbus_message_set_header( self.to_glib_none().0, header_field.into_glib(), value.to_glib_none().0, ); } } #[doc(alias = "g_dbus_message_set_interface")] pub fn set_interface(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_interface(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_member")] pub fn set_member(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_member(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_message_type")] pub fn set_message_type(&self, type_: DBusMessageType) { unsafe { ffi::g_dbus_message_set_message_type(self.to_glib_none().0, type_.into_glib()); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_message_set_num_unix_fds")] pub fn set_num_unix_fds(&self, value: u32) { unsafe { ffi::g_dbus_message_set_num_unix_fds(self.to_glib_none().0, value); } } #[doc(alias = "g_dbus_message_set_path")] pub fn set_path(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_path(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_reply_serial")] pub fn set_reply_serial(&self, value: u32) { unsafe { ffi::g_dbus_message_set_reply_serial(self.to_glib_none().0, value); } } #[doc(alias = "g_dbus_message_set_sender")] pub fn set_sender(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_sender(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_dbus_message_set_serial")] pub fn set_serial(&self, serial: u32) { unsafe { ffi::g_dbus_message_set_serial(self.to_glib_none().0, serial); } } #[doc(alias = "g_dbus_message_set_signature")] pub fn set_signature(&self, value: Option<&str>) { unsafe { ffi::g_dbus_message_set_signature(self.to_glib_none().0, value.to_glib_none().0); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_message_set_unix_fd_list")] pub fn set_unix_fd_list(&self, fd_list: Option<&impl IsA>) { unsafe { ffi::g_dbus_message_set_unix_fd_list( self.to_glib_none().0, fd_list.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_dbus_message_to_blob")] pub fn to_blob(&self, capabilities: DBusCapabilityFlags) -> Result, glib::Error> { unsafe { let mut out_size = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_message_to_blob( self.to_glib_none().0, out_size.as_mut_ptr(), capabilities.into_glib(), &mut error, ); if error.is_null() { Ok(FromGlibContainer::from_glib_full_num( ret, out_size.assume_init() as _, )) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_message_to_gerror")] pub fn to_gerror(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_message_to_gerror(self.to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_message_bytes_needed")] pub fn bytes_needed(blob: &[u8]) -> Result { let blob_len = blob.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_message_bytes_needed(blob.to_glib_none().0, blob_len, &mut error); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "locked")] pub fn connect_locked_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_locked_trampoline( this: *mut ffi::GDBusMessage, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::locked\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_locked_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for DBusMessage { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/dbus_method_info.rs000064400000000000000000000007461046102023000161060ustar 00000000000000// 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::ffi; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusMethodInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_method_info_ref(ptr), unref => |ptr| ffi::g_dbus_method_info_unref(ptr), type_ => || ffi::g_dbus_method_info_get_type(), } } gio-0.20.1/src/auto/dbus_method_invocation.rs000064400000000000000000000126621046102023000173240ustar 00000000000000// 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(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use crate::UnixFDList; use crate::{ffi, DBusConnection, DBusMessage, DBusMethodInfo, DBusPropertyInfo}; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use glib::prelude::*; use glib::translate::*; glib::wrapper! { #[doc(alias = "GDBusMethodInvocation")] pub struct DBusMethodInvocation(Object); match fn { type_ => || ffi::g_dbus_method_invocation_get_type(), } } impl DBusMethodInvocation { #[doc(alias = "g_dbus_method_invocation_get_connection")] #[doc(alias = "get_connection")] pub fn connection(&self) -> DBusConnection { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_connection( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_interface_name")] #[doc(alias = "get_interface_name")] pub fn interface_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_interface_name( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_message")] #[doc(alias = "get_message")] pub fn message(&self) -> DBusMessage { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_message( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_method_info")] #[doc(alias = "get_method_info")] pub fn method_info(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_method_info( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_method_name")] #[doc(alias = "get_method_name")] pub fn method_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_method_name( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_object_path")] #[doc(alias = "get_object_path")] pub fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_object_path( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_parameters")] #[doc(alias = "get_parameters")] pub fn parameters(&self) -> glib::Variant { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_parameters( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_property_info")] #[doc(alias = "get_property_info")] pub fn property_info(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_property_info( self.to_glib_none().0, )) } } #[doc(alias = "g_dbus_method_invocation_get_sender")] #[doc(alias = "get_sender")] pub fn sender(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_method_invocation_get_sender( self.to_glib_none().0, )) } } //#[doc(alias = "g_dbus_method_invocation_get_user_data")] //#[doc(alias = "get_user_data")] //pub fn user_data(&self) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_dbus_method_invocation_get_user_data() } //} #[doc(alias = "g_dbus_method_invocation_return_dbus_error")] pub fn return_dbus_error(self, error_name: &str, error_message: &str) { unsafe { ffi::g_dbus_method_invocation_return_dbus_error( self.into_glib_ptr(), error_name.to_glib_none().0, error_message.to_glib_none().0, ); } } //#[doc(alias = "g_dbus_method_invocation_return_error")] //pub fn return_error(self, domain: glib::Quark, code: i32, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_dbus_method_invocation_return_error() } //} //#[doc(alias = "g_dbus_method_invocation_return_error_valist")] //pub fn return_error_valist(self, domain: glib::Quark, code: i32, format: &str, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) { // unsafe { TODO: call ffi:g_dbus_method_invocation_return_error_valist() } //} #[doc(alias = "g_dbus_method_invocation_return_value")] pub fn return_value(self, parameters: Option<&glib::Variant>) { unsafe { ffi::g_dbus_method_invocation_return_value( self.into_glib_ptr(), parameters.to_glib_none().0, ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_method_invocation_return_value_with_unix_fd_list")] pub fn return_value_with_unix_fd_list( self, parameters: Option<&glib::Variant>, fd_list: Option<&impl IsA>, ) { unsafe { ffi::g_dbus_method_invocation_return_value_with_unix_fd_list( self.into_glib_ptr(), parameters.to_glib_none().0, fd_list.map(|p| p.as_ref()).to_glib_none().0, ); } } } gio-0.20.1/src/auto/dbus_node_info.rs000064400000000000000000000030621046102023000155450ustar 00000000000000// 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::{ffi, DBusInterfaceInfo}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusNodeInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_node_info_ref(ptr), unref => |ptr| ffi::g_dbus_node_info_unref(ptr), type_ => || ffi::g_dbus_node_info_get_type(), } } impl DBusNodeInfo { #[doc(alias = "g_dbus_node_info_new_for_xml")] #[doc(alias = "new_for_xml")] pub fn for_xml(xml_data: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_node_info_new_for_xml(xml_data.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } //#[doc(alias = "g_dbus_node_info_generate_xml")] //pub fn generate_xml(&self, indent: u32, string_builder: /*Ignored*/&mut glib::String) { // unsafe { TODO: call ffi:g_dbus_node_info_generate_xml() } //} #[doc(alias = "g_dbus_node_info_lookup_interface")] pub fn lookup_interface(&self, name: &str) -> Option { unsafe { from_glib_none(ffi::g_dbus_node_info_lookup_interface( self.to_glib_none().0, name.to_glib_none().0, )) } } } gio-0.20.1/src/auto/dbus_object.rs000064400000000000000000000075331046102023000150620ustar 00000000000000// 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::{ffi, DBusInterface}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusObject")] pub struct DBusObject(Interface); match fn { type_ => || ffi::g_dbus_object_get_type(), } } impl DBusObject { pub const NONE: Option<&'static DBusObject> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusObjectExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_dbus_object_get_interface")] #[doc(alias = "get_interface")] fn interface(&self, interface_name: &str) -> Option { unsafe { from_glib_full(ffi::g_dbus_object_get_interface( self.as_ref().to_glib_none().0, interface_name.to_glib_none().0, )) } } #[doc(alias = "g_dbus_object_get_interfaces")] #[doc(alias = "get_interfaces")] fn interfaces(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_get_interfaces( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_object_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_object_get_object_path( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "interface-added")] fn connect_interface_added( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn interface_added_trampoline< P: IsA, F: Fn(&P, &DBusInterface) + 'static, >( this: *mut ffi::GDBusObject, interface: *mut ffi::GDBusInterface, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObject::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(interface), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"interface-added\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( interface_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "interface-removed")] fn connect_interface_removed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn interface_removed_trampoline< P: IsA, F: Fn(&P, &DBusInterface) + 'static, >( this: *mut ffi::GDBusObject, interface: *mut ffi::GDBusInterface, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObject::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(interface), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"interface-removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( interface_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DBusObjectExt for O {} gio-0.20.1/src/auto/dbus_object_manager.rs000064400000000000000000000152751046102023000165560ustar 00000000000000// 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::{ffi, DBusInterface, DBusObject}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusObjectManager")] pub struct DBusObjectManager(Interface); match fn { type_ => || ffi::g_dbus_object_manager_get_type(), } } impl DBusObjectManager { pub const NONE: Option<&'static DBusObjectManager> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusObjectManagerExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_dbus_object_manager_get_interface")] #[doc(alias = "get_interface")] fn interface(&self, object_path: &str, interface_name: &str) -> Option { unsafe { from_glib_full(ffi::g_dbus_object_manager_get_interface( self.as_ref().to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, )) } } #[doc(alias = "g_dbus_object_manager_get_object")] #[doc(alias = "get_object")] fn object(&self, object_path: &str) -> Option { unsafe { from_glib_full(ffi::g_dbus_object_manager_get_object( self.as_ref().to_glib_none().0, object_path.to_glib_none().0, )) } } #[doc(alias = "g_dbus_object_manager_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_object_manager_get_object_path( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_object_manager_get_objects")] #[doc(alias = "get_objects")] fn objects(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_manager_get_objects( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "interface-added")] fn connect_interface_added( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn interface_added_trampoline< P: IsA, F: Fn(&P, &DBusObject, &DBusInterface) + 'static, >( this: *mut ffi::GDBusObjectManager, object: *mut ffi::GDBusObject, interface: *mut ffi::GDBusInterface, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(object), &from_glib_borrow(interface), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"interface-added\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( interface_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "interface-removed")] fn connect_interface_removed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn interface_removed_trampoline< P: IsA, F: Fn(&P, &DBusObject, &DBusInterface) + 'static, >( this: *mut ffi::GDBusObjectManager, object: *mut ffi::GDBusObject, interface: *mut ffi::GDBusInterface, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(object), &from_glib_borrow(interface), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"interface-removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( interface_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "object-added")] fn connect_object_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn object_added_trampoline< P: IsA, F: Fn(&P, &DBusObject) + 'static, >( this: *mut ffi::GDBusObjectManager, object: *mut ffi::GDBusObject, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(object), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"object-added\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( object_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "object-removed")] fn connect_object_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn object_removed_trampoline< P: IsA, F: Fn(&P, &DBusObject) + 'static, >( this: *mut ffi::GDBusObjectManager, object: *mut ffi::GDBusObject, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusObjectManager::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(object), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"object-removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( object_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DBusObjectManagerExt for O {} gio-0.20.1/src/auto/dbus_property_info.rs000064400000000000000000000007601046102023000165060ustar 00000000000000// 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::ffi; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusPropertyInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_property_info_ref(ptr), unref => |ptr| ffi::g_dbus_property_info_unref(ptr), type_ => || ffi::g_dbus_property_info_get_type(), } } gio-0.20.1/src/auto/dbus_proxy.rs000064400000000000000000000661151046102023000147760ustar 00000000000000// 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(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use crate::UnixFDList; use crate::{ ffi, AsyncInitable, AsyncResult, BusType, Cancellable, DBusCallFlags, DBusConnection, DBusInterface, DBusInterfaceInfo, DBusProxyFlags, Initable, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GDBusProxy")] pub struct DBusProxy(Object) @implements AsyncInitable, DBusInterface, Initable; match fn { type_ => || ffi::g_dbus_proxy_get_type(), } } impl DBusProxy { pub const NONE: Option<&'static DBusProxy> = None; #[doc(alias = "g_dbus_proxy_new_for_bus_sync")] #[doc(alias = "new_for_bus_sync")] pub fn for_bus_sync( bus_type: BusType, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: &str, object_path: &str, interface_name: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_new_for_bus_sync( bus_type.into_glib(), flags.into_glib(), info.to_glib_none().0, name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, cancellable.map(|p| p.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_dbus_proxy_new_sync")] pub fn new_sync( connection: &DBusConnection, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: Option<&str>, object_path: &str, interface_name: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_new_sync( connection.to_glib_none().0, flags.into_glib(), info.to_glib_none().0, name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, cancellable.map(|p| p.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_dbus_proxy_new")] pub fn new) + 'static>( connection: &DBusConnection, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: Option<&str>, object_path: &str, interface_name: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn new_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_new_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = new_trampoline::

; unsafe { ffi::g_dbus_proxy_new( connection.to_glib_none().0, flags.into_glib(), info.to_glib_none().0, name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn new_future( connection: &DBusConnection, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: Option<&str>, object_path: &str, interface_name: &str, ) -> Pin> + 'static>> { let connection = connection.clone(); let info = info.map(ToOwned::to_owned); let name = name.map(ToOwned::to_owned); let object_path = String::from(object_path); let interface_name = String::from(interface_name); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::new( &connection, flags, info.as_ref().map(::std::borrow::Borrow::borrow), name.as_ref().map(::std::borrow::Borrow::borrow), &object_path, &interface_name, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_dbus_proxy_new_for_bus")] #[doc(alias = "new_for_bus")] pub fn for_bus) + 'static>( bus_type: BusType, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: &str, object_path: &str, interface_name: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn for_bus_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_new_for_bus_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = for_bus_trampoline::

; unsafe { ffi::g_dbus_proxy_new_for_bus( bus_type.into_glib(), flags.into_glib(), info.to_glib_none().0, name.to_glib_none().0, object_path.to_glib_none().0, interface_name.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn for_bus_future( bus_type: BusType, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: &str, object_path: &str, interface_name: &str, ) -> Pin> + 'static>> { let info = info.map(ToOwned::to_owned); let name = String::from(name); let object_path = String::from(object_path); let interface_name = String::from(interface_name); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::for_bus( bus_type, flags, info.as_ref().map(::std::borrow::Borrow::borrow), &name, &object_path, &interface_name, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } } unsafe impl Send for DBusProxy {} unsafe impl Sync for DBusProxy {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusProxyExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_dbus_proxy_call")] fn call) + 'static>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_call_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = call_trampoline::

; unsafe { ffi::g_dbus_proxy_call( self.as_ref().to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, flags.into_glib(), timeout_msec, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn call_future( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, ) -> Pin> + 'static>> { let method_name = String::from(method_name); let parameters = parameters.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.call( &method_name, parameters.as_ref().map(::std::borrow::Borrow::borrow), flags, timeout_msec, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_dbus_proxy_call_sync")] fn call_sync( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_call_sync( self.as_ref().to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, flags.into_glib(), timeout_msec, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list")] fn call_with_unix_fd_list< P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, >( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn call_with_unix_fd_list_trampoline< P: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut out_fd_list = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_finish( _source_object as *mut _, &mut out_fd_list, res, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_fd_list))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = call_with_unix_fd_list_trampoline::

; unsafe { ffi::g_dbus_proxy_call_with_unix_fd_list( self.as_ref().to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, flags.into_glib(), timeout_msec, fd_list.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] fn call_with_unix_fd_list_future( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&(impl IsA + Clone + 'static)>, ) -> Pin< Box_< dyn std::future::Future> + 'static, >, > { let method_name = String::from(method_name); let parameters = parameters.map(ToOwned::to_owned); let fd_list = fd_list.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.call_with_unix_fd_list( &method_name, parameters.as_ref().map(::std::borrow::Borrow::borrow), flags, timeout_msec, fd_list.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list_sync")] fn call_with_unix_fd_list_sync( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA>, cancellable: Option<&impl IsA>, ) -> Result<(glib::Variant, UnixFDList), glib::Error> { unsafe { let mut out_fd_list = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_proxy_call_with_unix_fd_list_sync( self.as_ref().to_glib_none().0, method_name.to_glib_none().0, parameters.to_glib_none().0, flags.into_glib(), timeout_msec, fd_list.map(|p| p.as_ref()).to_glib_none().0, &mut out_fd_list, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_fd_list))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_proxy_get_cached_property")] #[doc(alias = "get_cached_property")] fn cached_property(&self, property_name: &str) -> Option { unsafe { from_glib_full(ffi::g_dbus_proxy_get_cached_property( self.as_ref().to_glib_none().0, property_name.to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_cached_property_names")] #[doc(alias = "get_cached_property_names")] fn cached_property_names(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_proxy_get_cached_property_names( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_connection")] #[doc(alias = "get_connection")] fn connection(&self) -> DBusConnection { unsafe { from_glib_none(ffi::g_dbus_proxy_get_connection( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_default_timeout")] #[doc(alias = "get_default_timeout")] fn default_timeout(&self) -> i32 { unsafe { ffi::g_dbus_proxy_get_default_timeout(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_dbus_proxy_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> DBusProxyFlags { unsafe { from_glib(ffi::g_dbus_proxy_get_flags(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_dbus_proxy_get_interface_info")] #[doc(alias = "get_interface_info")] fn interface_info(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_proxy_get_interface_info( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_interface_name")] #[doc(alias = "get_interface_name")] fn interface_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_proxy_get_interface_name( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_name")] #[doc(alias = "get_name")] fn name(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_proxy_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_dbus_proxy_get_name_owner")] #[doc(alias = "get_name_owner")] fn name_owner(&self) -> Option { unsafe { from_glib_full(ffi::g_dbus_proxy_get_name_owner( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_proxy_get_object_path( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_dbus_proxy_set_cached_property")] fn set_cached_property(&self, property_name: &str, value: Option<&glib::Variant>) { unsafe { ffi::g_dbus_proxy_set_cached_property( self.as_ref().to_glib_none().0, property_name.to_glib_none().0, value.to_glib_none().0, ); } } #[doc(alias = "g_dbus_proxy_set_default_timeout")] fn set_default_timeout(&self, timeout_msec: i32) { unsafe { ffi::g_dbus_proxy_set_default_timeout(self.as_ref().to_glib_none().0, timeout_msec); } } #[doc(alias = "g_dbus_proxy_set_interface_info")] fn set_interface_info(&self, info: Option<&DBusInterfaceInfo>) { unsafe { ffi::g_dbus_proxy_set_interface_info( self.as_ref().to_glib_none().0, info.to_glib_none().0, ); } } #[doc(alias = "g-connection")] fn g_connection(&self) -> Option { ObjectExt::property(self.as_ref(), "g-connection") } #[doc(alias = "g-default-timeout")] fn g_default_timeout(&self) -> i32 { ObjectExt::property(self.as_ref(), "g-default-timeout") } #[doc(alias = "g-default-timeout")] fn set_g_default_timeout(&self, g_default_timeout: i32) { ObjectExt::set_property(self.as_ref(), "g-default-timeout", g_default_timeout) } #[doc(alias = "g-flags")] fn g_flags(&self) -> DBusProxyFlags { ObjectExt::property(self.as_ref(), "g-flags") } #[doc(alias = "g-interface-info")] fn g_interface_info(&self) -> Option { ObjectExt::property(self.as_ref(), "g-interface-info") } #[doc(alias = "g-interface-info")] fn set_g_interface_info(&self, g_interface_info: Option<&DBusInterfaceInfo>) { ObjectExt::set_property(self.as_ref(), "g-interface-info", g_interface_info) } #[doc(alias = "g-interface-name")] fn g_interface_name(&self) -> Option { ObjectExt::property(self.as_ref(), "g-interface-name") } #[doc(alias = "g-name")] fn g_name(&self) -> Option { ObjectExt::property(self.as_ref(), "g-name") } #[doc(alias = "g-name-owner")] fn g_name_owner(&self) -> Option { ObjectExt::property(self.as_ref(), "g-name-owner") } #[doc(alias = "g-object-path")] fn g_object_path(&self) -> Option { ObjectExt::property(self.as_ref(), "g-object-path") } #[doc(alias = "g-default-timeout")] fn connect_g_default_timeout_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_g_default_timeout_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GDBusProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::g-default-timeout\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_g_default_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "g-interface-info")] fn connect_g_interface_info_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_g_interface_info_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GDBusProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::g-interface-info\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_g_interface_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "g-name-owner")] fn connect_g_name_owner_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_g_name_owner_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GDBusProxy, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DBusProxy::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::g-name-owner\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_g_name_owner_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DBusProxyExt for O {} gio-0.20.1/src/auto/dbus_server.rs000064400000000000000000000130711046102023000151140ustar 00000000000000// 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::{ffi, Cancellable, DBusAuthObserver, DBusConnection, DBusServerFlags, Initable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDBusServer")] pub struct DBusServer(Object) @implements Initable; match fn { type_ => || ffi::g_dbus_server_get_type(), } } impl DBusServer { #[doc(alias = "g_dbus_server_new_sync")] pub fn new_sync( address: &str, flags: DBusServerFlags, guid: &str, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_server_new_sync( address.to_glib_none().0, flags.into_glib(), guid.to_glib_none().0, observer.to_glib_none().0, cancellable.map(|p| p.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_dbus_server_get_client_address")] #[doc(alias = "get_client_address")] #[doc(alias = "client-address")] pub fn client_address(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_server_get_client_address(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_server_get_flags")] #[doc(alias = "get_flags")] pub fn flags(&self) -> DBusServerFlags { unsafe { from_glib(ffi::g_dbus_server_get_flags(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_server_get_guid")] #[doc(alias = "get_guid")] pub fn guid(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_server_get_guid(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_server_is_active")] #[doc(alias = "active")] pub fn is_active(&self) -> bool { unsafe { from_glib(ffi::g_dbus_server_is_active(self.to_glib_none().0)) } } #[doc(alias = "g_dbus_server_start")] pub fn start(&self) { unsafe { ffi::g_dbus_server_start(self.to_glib_none().0); } } #[doc(alias = "g_dbus_server_stop")] pub fn stop(&self) { unsafe { ffi::g_dbus_server_stop(self.to_glib_none().0); } } pub fn address(&self) -> Option { ObjectExt::property(self, "address") } #[doc(alias = "authentication-observer")] pub fn authentication_observer(&self) -> Option { ObjectExt::property(self, "authentication-observer") } #[doc(alias = "new-connection")] pub fn connect_new_connection bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn new_connection_trampoline< F: Fn(&DBusServer, &DBusConnection) -> bool + 'static, >( this: *mut ffi::GDBusServer, connection: *mut ffi::GDBusConnection, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f(&from_glib_borrow(this), &from_glib_borrow(connection)).into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"new-connection\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( new_connection_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "active")] pub fn connect_active_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_active_trampoline( this: *mut ffi::GDBusServer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::active\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_active_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "client-address")] pub fn connect_client_address_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_client_address_trampoline( this: *mut ffi::GDBusServer, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::client-address\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_client_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/auto/dbus_signal_info.rs000064400000000000000000000007461046102023000161030ustar 00000000000000// 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::ffi; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct DBusSignalInfo(Shared); match fn { ref => |ptr| ffi::g_dbus_signal_info_ref(ptr), unref => |ptr| ffi::g_dbus_signal_info_unref(ptr), type_ => || ffi::g_dbus_signal_info_get_type(), } } gio-0.20.1/src/auto/debug_controller.rs000064400000000000000000000050641046102023000161250ustar 00000000000000// 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::{ffi, Initable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDebugController")] pub struct DebugController(Interface) @requires Initable; match fn { type_ => || ffi::g_debug_controller_get_type(), } } impl DebugController { pub const NONE: Option<&'static DebugController> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DebugControllerExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_debug_controller_get_debug_enabled")] #[doc(alias = "get_debug_enabled")] #[doc(alias = "debug-enabled")] fn is_debug_enabled(&self) -> bool { unsafe { from_glib(ffi::g_debug_controller_get_debug_enabled( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_debug_controller_set_debug_enabled")] #[doc(alias = "debug-enabled")] fn set_debug_enabled(&self, debug_enabled: bool) { unsafe { ffi::g_debug_controller_set_debug_enabled( self.as_ref().to_glib_none().0, debug_enabled.into_glib(), ); } } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "debug-enabled")] fn connect_debug_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_debug_enabled_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GDebugController, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(DebugController::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::debug-enabled\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_debug_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DebugControllerExt for O {} gio-0.20.1/src/auto/debug_controller_dbus.rs000064400000000000000000000060211046102023000171340ustar 00000000000000// 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::{ffi, Cancellable, DBusConnection, DBusMethodInvocation, DebugController, Initable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDebugControllerDBus")] pub struct DebugControllerDBus(Object) @implements DebugController, Initable; match fn { type_ => || ffi::g_debug_controller_dbus_get_type(), } } impl DebugControllerDBus { pub const NONE: Option<&'static DebugControllerDBus> = None; #[doc(alias = "g_debug_controller_dbus_new")] pub fn new( connection: &DBusConnection, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_debug_controller_dbus_new( connection.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DebugControllerDBusExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_debug_controller_dbus_stop")] fn stop(&self) { unsafe { ffi::g_debug_controller_dbus_stop(self.as_ref().to_glib_none().0); } } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "authorize")] fn connect_authorize bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn authorize_trampoline< P: IsA, F: Fn(&P, &DBusMethodInvocation) -> bool + 'static, >( this: *mut ffi::GDebugControllerDBus, invocation: *mut ffi::GDBusMethodInvocation, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( DebugControllerDBus::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(invocation), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"authorize\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( authorize_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DebugControllerDBusExt for O {} gio-0.20.1/src/auto/desktop_app_info.rs000064400000000000000000000232071046102023000161170ustar 00000000000000// 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::{ffi, AppInfo, AppLaunchContext}; use glib::{prelude::*, translate::*}; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GDesktopAppInfo")] pub struct DesktopAppInfo(Object) @implements AppInfo; match fn { type_ => || ffi::g_desktop_app_info_get_type(), } } impl DesktopAppInfo { #[doc(alias = "g_desktop_app_info_new")] pub fn new(desktop_id: &str) -> Option { unsafe { from_glib_full(ffi::g_desktop_app_info_new(desktop_id.to_glib_none().0)) } } #[doc(alias = "g_desktop_app_info_new_from_filename")] #[doc(alias = "new_from_filename")] pub fn from_filename(filename: impl AsRef) -> Option { unsafe { from_glib_full(ffi::g_desktop_app_info_new_from_filename( filename.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_new_from_keyfile")] #[doc(alias = "new_from_keyfile")] pub fn from_keyfile(key_file: &glib::KeyFile) -> Option { unsafe { from_glib_full(ffi::g_desktop_app_info_new_from_keyfile( key_file.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_action_name")] #[doc(alias = "get_action_name")] pub fn action_name(&self, action_name: &str) -> glib::GString { unsafe { from_glib_full(ffi::g_desktop_app_info_get_action_name( self.to_glib_none().0, action_name.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_boolean")] #[doc(alias = "get_boolean")] pub fn boolean(&self, key: &str) -> bool { unsafe { from_glib(ffi::g_desktop_app_info_get_boolean( self.to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_categories")] #[doc(alias = "get_categories")] pub fn categories(&self) -> Option { unsafe { from_glib_none(ffi::g_desktop_app_info_get_categories( self.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_filename")] #[doc(alias = "get_filename")] pub fn filename(&self) -> Option { unsafe { from_glib_none(ffi::g_desktop_app_info_get_filename(self.to_glib_none().0)) } } #[doc(alias = "g_desktop_app_info_get_generic_name")] #[doc(alias = "get_generic_name")] pub fn generic_name(&self) -> Option { unsafe { from_glib_none(ffi::g_desktop_app_info_get_generic_name( self.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_is_hidden")] #[doc(alias = "get_is_hidden")] pub fn is_hidden(&self) -> bool { unsafe { from_glib(ffi::g_desktop_app_info_get_is_hidden(self.to_glib_none().0)) } } #[doc(alias = "g_desktop_app_info_get_keywords")] #[doc(alias = "get_keywords")] pub fn keywords(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_get_keywords( self.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_locale_string")] #[doc(alias = "get_locale_string")] pub fn locale_string(&self, key: &str) -> Option { unsafe { from_glib_full(ffi::g_desktop_app_info_get_locale_string( self.to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_nodisplay")] #[doc(alias = "get_nodisplay")] pub fn is_nodisplay(&self) -> bool { unsafe { from_glib(ffi::g_desktop_app_info_get_nodisplay(self.to_glib_none().0)) } } #[doc(alias = "g_desktop_app_info_get_show_in")] #[doc(alias = "get_show_in")] pub fn shows_in(&self, desktop_env: Option<&str>) -> bool { unsafe { from_glib(ffi::g_desktop_app_info_get_show_in( self.to_glib_none().0, desktop_env.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_startup_wm_class")] #[doc(alias = "get_startup_wm_class")] pub fn startup_wm_class(&self) -> Option { unsafe { from_glib_none(ffi::g_desktop_app_info_get_startup_wm_class( self.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_string")] #[doc(alias = "get_string")] pub fn string(&self, key: &str) -> Option { unsafe { from_glib_full(ffi::g_desktop_app_info_get_string( self.to_glib_none().0, key.to_glib_none().0, )) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_desktop_app_info_get_string_list")] #[doc(alias = "get_string_list")] pub fn string_list(&self, key: &str) -> Vec { unsafe { let mut length = std::mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_full_num( ffi::g_desktop_app_info_get_string_list( self.to_glib_none().0, key.to_glib_none().0, length.as_mut_ptr(), ), length.assume_init() as _, ); ret } } #[doc(alias = "g_desktop_app_info_has_key")] pub fn has_key(&self, key: &str) -> bool { unsafe { from_glib(ffi::g_desktop_app_info_has_key( self.to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_launch_action")] pub fn launch_action( &self, action_name: &str, launch_context: Option<&impl IsA>, ) { unsafe { ffi::g_desktop_app_info_launch_action( self.to_glib_none().0, action_name.to_glib_none().0, launch_context.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_desktop_app_info_launch_uris_as_manager")] pub fn launch_uris_as_manager( &self, uris: &[&str], launch_context: Option<&impl IsA>, spawn_flags: glib::SpawnFlags, user_setup: Option>, pid_callback: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>, ) -> Result<(), glib::Error> { let user_setup_data: Box_>> = Box_::new(user_setup); unsafe extern "C" fn user_setup_func(data: glib::ffi::gpointer) { let callback = Box_::from_raw(data as *mut Option>); let callback = (*callback).expect("cannot get closure..."); callback() } let user_setup = if user_setup_data.is_some() { Some(user_setup_func as _) } else { None }; let pid_callback_data: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = pid_callback; unsafe extern "C" fn pid_callback_func( appinfo: *mut ffi::GDesktopAppInfo, pid: glib::ffi::GPid, user_data: glib::ffi::gpointer, ) { let appinfo = from_glib_borrow(appinfo); let pid = from_glib(pid); let callback = user_data as *mut Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>; if let Some(ref mut callback) = *callback { callback(&appinfo, pid) } else { panic!("cannot get closure...") } } let pid_callback = if pid_callback_data.is_some() { Some(pid_callback_func as _) } else { None }; let super_callback0: Box_>> = user_setup_data; let super_callback1: &Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = &pid_callback_data; unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_desktop_app_info_launch_uris_as_manager( self.to_glib_none().0, uris.to_glib_none().0, launch_context.map(|p| p.as_ref()).to_glib_none().0, spawn_flags.into_glib(), user_setup, Box_::into_raw(super_callback0) as *mut _, pid_callback, super_callback1 as *const _ as *mut _, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_desktop_app_info_list_actions")] pub fn list_actions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_desktop_app_info_list_actions( self.to_glib_none().0, )) } } #[doc(alias = "g_desktop_app_info_get_implementations")] #[doc(alias = "get_implementations")] pub fn implementations(interface: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_desktop_app_info_get_implementations( interface.to_glib_none().0, )) } } } gio-0.20.1/src/auto/drive.rs000064400000000000000000000453561046102023000137150ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, DriveStartFlags, DriveStartStopType, Icon, MountOperation, MountUnmountFlags, Volume, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GDrive")] pub struct Drive(Interface); match fn { type_ => || ffi::g_drive_get_type(), } } impl Drive { pub const NONE: Option<&'static Drive> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DriveExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_drive_can_eject")] fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_eject(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_can_poll_for_media")] fn can_poll_for_media(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_poll_for_media( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_can_start")] fn can_start(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_start(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_can_start_degraded")] fn can_start_degraded(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_start_degraded( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_can_stop")] fn can_stop(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_stop(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_eject_with_operation")] fn eject_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn eject_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_drive_eject_with_operation_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = eject_with_operation_trampoline::

; unsafe { ffi::g_drive_eject_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn eject_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_drive_enumerate_identifiers")] fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_drive_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_drive_get_icon(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_get_identifier")] #[doc(alias = "get_identifier")] fn identifier(&self, kind: &str) -> Option { unsafe { from_glib_full(ffi::g_drive_get_identifier( self.as_ref().to_glib_none().0, kind.to_glib_none().0, )) } } #[doc(alias = "g_drive_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_drive_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_drive_get_sort_key(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_get_start_stop_type")] #[doc(alias = "get_start_stop_type")] fn start_stop_type(&self) -> DriveStartStopType { unsafe { from_glib(ffi::g_drive_get_start_stop_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_drive_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_get_volumes")] #[doc(alias = "get_volumes")] fn volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_drive_get_volumes( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_has_media")] fn has_media(&self) -> bool { unsafe { from_glib(ffi::g_drive_has_media(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_has_volumes")] fn has_volumes(&self) -> bool { unsafe { from_glib(ffi::g_drive_has_volumes(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_is_media_check_automatic")] fn is_media_check_automatic(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_media_check_automatic( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_is_media_removable")] fn is_media_removable(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_media_removable( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_drive_is_removable")] fn is_removable(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_removable(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_drive_poll_for_media")] fn poll_for_media) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn poll_for_media_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_drive_poll_for_media_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = poll_for_media_trampoline::

; unsafe { ffi::g_drive_poll_for_media( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn poll_for_media_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.poll_for_media(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_drive_start")] fn start) + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn start_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_drive_start_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = start_trampoline::

; unsafe { ffi::g_drive_start( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn start_future( &self, flags: DriveStartFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.start( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_drive_stop")] fn stop) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn stop_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_drive_stop_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = stop_trampoline::

; unsafe { ffi::g_drive_stop( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn stop_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.stop( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Drive::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "disconnected")] fn connect_disconnected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn disconnected_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Drive::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"disconnected\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( disconnected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "eject-button")] fn connect_eject_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn eject_button_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Drive::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"eject-button\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( eject_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "stop-button")] fn connect_stop_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn stop_button_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Drive::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"stop-button\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( stop_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DriveExt for O {} gio-0.20.1/src/auto/emblem.rs000064400000000000000000000025151046102023000140330ustar 00000000000000// 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::{ffi, EmblemOrigin, Icon}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GEmblem")] pub struct Emblem(Object) @implements Icon; match fn { type_ => || ffi::g_emblem_get_type(), } } impl Emblem { #[doc(alias = "g_emblem_new")] pub fn new(icon: &impl IsA) -> Emblem { unsafe { from_glib_full(ffi::g_emblem_new(icon.as_ref().to_glib_none().0)) } } #[doc(alias = "g_emblem_new_with_origin")] #[doc(alias = "new_with_origin")] pub fn with_origin(icon: &impl IsA, origin: EmblemOrigin) -> Emblem { unsafe { from_glib_full(ffi::g_emblem_new_with_origin( icon.as_ref().to_glib_none().0, origin.into_glib(), )) } } #[doc(alias = "g_emblem_get_icon")] #[doc(alias = "get_icon")] pub fn icon(&self) -> Icon { unsafe { from_glib_none(ffi::g_emblem_get_icon(self.to_glib_none().0)) } } #[doc(alias = "g_emblem_get_origin")] #[doc(alias = "get_origin")] pub fn origin(&self) -> EmblemOrigin { unsafe { from_glib(ffi::g_emblem_get_origin(self.to_glib_none().0)) } } } gio-0.20.1/src/auto/emblemed_icon.rs000064400000000000000000000042251046102023000153540ustar 00000000000000// 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::{ffi, Emblem, Icon}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GEmblemedIcon")] pub struct EmblemedIcon(Object) @implements Icon; match fn { type_ => || ffi::g_emblemed_icon_get_type(), } } impl EmblemedIcon { pub const NONE: Option<&'static EmblemedIcon> = None; #[doc(alias = "g_emblemed_icon_new")] pub fn new(icon: &impl IsA, emblem: Option<&Emblem>) -> EmblemedIcon { unsafe { from_glib_full(ffi::g_emblemed_icon_new( icon.as_ref().to_glib_none().0, emblem.to_glib_none().0, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait EmblemedIconExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_emblemed_icon_add_emblem")] fn add_emblem(&self, emblem: &Emblem) { unsafe { ffi::g_emblemed_icon_add_emblem( self.as_ref().to_glib_none().0, emblem.to_glib_none().0, ); } } #[doc(alias = "g_emblemed_icon_clear_emblems")] fn clear_emblems(&self) { unsafe { ffi::g_emblemed_icon_clear_emblems(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_emblemed_icon_get_emblems")] #[doc(alias = "get_emblems")] fn emblems(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_emblemed_icon_get_emblems( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_emblemed_icon_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon { unsafe { from_glib_none(ffi::g_emblemed_icon_get_icon( self.as_ref().to_glib_none().0, )) } } fn gicon(&self) -> Option { ObjectExt::property(self.as_ref(), "gicon") } } impl> EmblemedIconExt for O {} gio-0.20.1/src/auto/enums.rs000064400000000000000000004003361046102023000137240ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GBusType")] pub enum BusType { #[doc(alias = "G_BUS_TYPE_STARTER")] Starter, #[doc(alias = "G_BUS_TYPE_NONE")] None, #[doc(alias = "G_BUS_TYPE_SYSTEM")] System, #[doc(alias = "G_BUS_TYPE_SESSION")] Session, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for BusType { type GlibType = ffi::GBusType; #[inline] fn into_glib(self) -> ffi::GBusType { match self { Self::Starter => ffi::G_BUS_TYPE_STARTER, Self::None => ffi::G_BUS_TYPE_NONE, Self::System => ffi::G_BUS_TYPE_SYSTEM, Self::Session => ffi::G_BUS_TYPE_SESSION, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for BusType { #[inline] unsafe fn from_glib(value: ffi::GBusType) -> Self { match value { ffi::G_BUS_TYPE_STARTER => Self::Starter, ffi::G_BUS_TYPE_NONE => Self::None, ffi::G_BUS_TYPE_SYSTEM => Self::System, ffi::G_BUS_TYPE_SESSION => Self::Session, value => Self::__Unknown(value), } } } impl StaticType for BusType { #[inline] #[doc(alias = "g_bus_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_bus_type_get_type()) } } } impl glib::HasParamSpec for BusType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for BusType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for BusType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for BusType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: BusType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GConverterResult")] pub enum ConverterResult { #[doc(alias = "G_CONVERTER_ERROR")] Error, #[doc(alias = "G_CONVERTER_CONVERTED")] Converted, #[doc(alias = "G_CONVERTER_FINISHED")] Finished, #[doc(alias = "G_CONVERTER_FLUSHED")] Flushed, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for ConverterResult { type GlibType = ffi::GConverterResult; #[inline] fn into_glib(self) -> ffi::GConverterResult { match self { Self::Error => ffi::G_CONVERTER_ERROR, Self::Converted => ffi::G_CONVERTER_CONVERTED, Self::Finished => ffi::G_CONVERTER_FINISHED, Self::Flushed => ffi::G_CONVERTER_FLUSHED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ConverterResult { #[inline] unsafe fn from_glib(value: ffi::GConverterResult) -> Self { match value { ffi::G_CONVERTER_ERROR => Self::Error, ffi::G_CONVERTER_CONVERTED => Self::Converted, ffi::G_CONVERTER_FINISHED => Self::Finished, ffi::G_CONVERTER_FLUSHED => Self::Flushed, value => Self::__Unknown(value), } } } impl StaticType for ConverterResult { #[inline] #[doc(alias = "g_converter_result_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_converter_result_get_type()) } } } impl glib::HasParamSpec for ConverterResult { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for ConverterResult { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ConverterResult { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for ConverterResult { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ConverterResult) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GCredentialsType")] pub enum CredentialsType { #[doc(alias = "G_CREDENTIALS_TYPE_INVALID")] Invalid, #[doc(alias = "G_CREDENTIALS_TYPE_LINUX_UCRED")] LinuxUcred, #[doc(alias = "G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED")] FreebsdCmsgcred, #[doc(alias = "G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED")] OpenbsdSockpeercred, #[doc(alias = "G_CREDENTIALS_TYPE_SOLARIS_UCRED")] SolarisUcred, #[doc(alias = "G_CREDENTIALS_TYPE_NETBSD_UNPCBID")] NetbsdUnpcbid, #[doc(alias = "G_CREDENTIALS_TYPE_APPLE_XUCRED")] AppleXucred, #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "G_CREDENTIALS_TYPE_WIN32_PID")] Win32Pid, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for CredentialsType { type GlibType = ffi::GCredentialsType; #[inline] fn into_glib(self) -> ffi::GCredentialsType { match self { Self::Invalid => ffi::G_CREDENTIALS_TYPE_INVALID, Self::LinuxUcred => ffi::G_CREDENTIALS_TYPE_LINUX_UCRED, Self::FreebsdCmsgcred => ffi::G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED, Self::OpenbsdSockpeercred => ffi::G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED, Self::SolarisUcred => ffi::G_CREDENTIALS_TYPE_SOLARIS_UCRED, Self::NetbsdUnpcbid => ffi::G_CREDENTIALS_TYPE_NETBSD_UNPCBID, Self::AppleXucred => ffi::G_CREDENTIALS_TYPE_APPLE_XUCRED, #[cfg(feature = "v2_72")] Self::Win32Pid => ffi::G_CREDENTIALS_TYPE_WIN32_PID, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for CredentialsType { #[inline] unsafe fn from_glib(value: ffi::GCredentialsType) -> Self { match value { ffi::G_CREDENTIALS_TYPE_INVALID => Self::Invalid, ffi::G_CREDENTIALS_TYPE_LINUX_UCRED => Self::LinuxUcred, ffi::G_CREDENTIALS_TYPE_FREEBSD_CMSGCRED => Self::FreebsdCmsgcred, ffi::G_CREDENTIALS_TYPE_OPENBSD_SOCKPEERCRED => Self::OpenbsdSockpeercred, ffi::G_CREDENTIALS_TYPE_SOLARIS_UCRED => Self::SolarisUcred, ffi::G_CREDENTIALS_TYPE_NETBSD_UNPCBID => Self::NetbsdUnpcbid, ffi::G_CREDENTIALS_TYPE_APPLE_XUCRED => Self::AppleXucred, #[cfg(feature = "v2_72")] ffi::G_CREDENTIALS_TYPE_WIN32_PID => Self::Win32Pid, value => Self::__Unknown(value), } } } impl StaticType for CredentialsType { #[inline] #[doc(alias = "g_credentials_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_credentials_type_get_type()) } } } impl glib::HasParamSpec for CredentialsType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for CredentialsType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for CredentialsType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for CredentialsType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: CredentialsType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDBusMessageByteOrder")] pub enum DBusMessageByteOrder { #[doc(alias = "G_DBUS_MESSAGE_BYTE_ORDER_BIG_ENDIAN")] BigEndian, #[doc(alias = "G_DBUS_MESSAGE_BYTE_ORDER_LITTLE_ENDIAN")] LittleEndian, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DBusMessageByteOrder { type GlibType = ffi::GDBusMessageByteOrder; #[inline] fn into_glib(self) -> ffi::GDBusMessageByteOrder { match self { Self::BigEndian => ffi::G_DBUS_MESSAGE_BYTE_ORDER_BIG_ENDIAN, Self::LittleEndian => ffi::G_DBUS_MESSAGE_BYTE_ORDER_LITTLE_ENDIAN, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DBusMessageByteOrder { #[inline] unsafe fn from_glib(value: ffi::GDBusMessageByteOrder) -> Self { match value { ffi::G_DBUS_MESSAGE_BYTE_ORDER_BIG_ENDIAN => Self::BigEndian, ffi::G_DBUS_MESSAGE_BYTE_ORDER_LITTLE_ENDIAN => Self::LittleEndian, value => Self::__Unknown(value), } } } impl StaticType for DBusMessageByteOrder { #[inline] #[doc(alias = "g_dbus_message_byte_order_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_message_byte_order_get_type()) } } } impl glib::HasParamSpec for DBusMessageByteOrder { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DBusMessageByteOrder { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusMessageByteOrder { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DBusMessageByteOrder { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusMessageByteOrder) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDBusMessageHeaderField")] pub enum DBusMessageHeaderField { #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_INVALID")] Invalid, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_PATH")] Path, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE")] Interface, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_MEMBER")] Member, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME")] ErrorName, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL")] ReplySerial, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION")] Destination, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_SENDER")] Sender, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE")] Signature, #[doc(alias = "G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS")] NumUnixFds, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DBusMessageHeaderField { type GlibType = ffi::GDBusMessageHeaderField; #[inline] fn into_glib(self) -> ffi::GDBusMessageHeaderField { match self { Self::Invalid => ffi::G_DBUS_MESSAGE_HEADER_FIELD_INVALID, Self::Path => ffi::G_DBUS_MESSAGE_HEADER_FIELD_PATH, Self::Interface => ffi::G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE, Self::Member => ffi::G_DBUS_MESSAGE_HEADER_FIELD_MEMBER, Self::ErrorName => ffi::G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME, Self::ReplySerial => ffi::G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL, Self::Destination => ffi::G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION, Self::Sender => ffi::G_DBUS_MESSAGE_HEADER_FIELD_SENDER, Self::Signature => ffi::G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE, Self::NumUnixFds => ffi::G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DBusMessageHeaderField { #[inline] unsafe fn from_glib(value: ffi::GDBusMessageHeaderField) -> Self { match value { ffi::G_DBUS_MESSAGE_HEADER_FIELD_INVALID => Self::Invalid, ffi::G_DBUS_MESSAGE_HEADER_FIELD_PATH => Self::Path, ffi::G_DBUS_MESSAGE_HEADER_FIELD_INTERFACE => Self::Interface, ffi::G_DBUS_MESSAGE_HEADER_FIELD_MEMBER => Self::Member, ffi::G_DBUS_MESSAGE_HEADER_FIELD_ERROR_NAME => Self::ErrorName, ffi::G_DBUS_MESSAGE_HEADER_FIELD_REPLY_SERIAL => Self::ReplySerial, ffi::G_DBUS_MESSAGE_HEADER_FIELD_DESTINATION => Self::Destination, ffi::G_DBUS_MESSAGE_HEADER_FIELD_SENDER => Self::Sender, ffi::G_DBUS_MESSAGE_HEADER_FIELD_SIGNATURE => Self::Signature, ffi::G_DBUS_MESSAGE_HEADER_FIELD_NUM_UNIX_FDS => Self::NumUnixFds, value => Self::__Unknown(value), } } } impl StaticType for DBusMessageHeaderField { #[inline] #[doc(alias = "g_dbus_message_header_field_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_message_header_field_get_type()) } } } impl glib::HasParamSpec for DBusMessageHeaderField { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DBusMessageHeaderField { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusMessageHeaderField { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DBusMessageHeaderField { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusMessageHeaderField) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDBusMessageType")] pub enum DBusMessageType { #[doc(alias = "G_DBUS_MESSAGE_TYPE_INVALID")] Invalid, #[doc(alias = "G_DBUS_MESSAGE_TYPE_METHOD_CALL")] MethodCall, #[doc(alias = "G_DBUS_MESSAGE_TYPE_METHOD_RETURN")] MethodReturn, #[doc(alias = "G_DBUS_MESSAGE_TYPE_ERROR")] Error, #[doc(alias = "G_DBUS_MESSAGE_TYPE_SIGNAL")] Signal, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DBusMessageType { type GlibType = ffi::GDBusMessageType; #[inline] fn into_glib(self) -> ffi::GDBusMessageType { match self { Self::Invalid => ffi::G_DBUS_MESSAGE_TYPE_INVALID, Self::MethodCall => ffi::G_DBUS_MESSAGE_TYPE_METHOD_CALL, Self::MethodReturn => ffi::G_DBUS_MESSAGE_TYPE_METHOD_RETURN, Self::Error => ffi::G_DBUS_MESSAGE_TYPE_ERROR, Self::Signal => ffi::G_DBUS_MESSAGE_TYPE_SIGNAL, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DBusMessageType { #[inline] unsafe fn from_glib(value: ffi::GDBusMessageType) -> Self { match value { ffi::G_DBUS_MESSAGE_TYPE_INVALID => Self::Invalid, ffi::G_DBUS_MESSAGE_TYPE_METHOD_CALL => Self::MethodCall, ffi::G_DBUS_MESSAGE_TYPE_METHOD_RETURN => Self::MethodReturn, ffi::G_DBUS_MESSAGE_TYPE_ERROR => Self::Error, ffi::G_DBUS_MESSAGE_TYPE_SIGNAL => Self::Signal, value => Self::__Unknown(value), } } } impl StaticType for DBusMessageType { #[inline] #[doc(alias = "g_dbus_message_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_message_type_get_type()) } } } impl glib::HasParamSpec for DBusMessageType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DBusMessageType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusMessageType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DBusMessageType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusMessageType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDataStreamByteOrder")] pub enum DataStreamByteOrder { #[doc(alias = "G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN")] BigEndian, #[doc(alias = "G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN")] LittleEndian, #[doc(alias = "G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN")] HostEndian, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DataStreamByteOrder { type GlibType = ffi::GDataStreamByteOrder; #[inline] fn into_glib(self) -> ffi::GDataStreamByteOrder { match self { Self::BigEndian => ffi::G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN, Self::LittleEndian => ffi::G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN, Self::HostEndian => ffi::G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DataStreamByteOrder { #[inline] unsafe fn from_glib(value: ffi::GDataStreamByteOrder) -> Self { match value { ffi::G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN => Self::BigEndian, ffi::G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN => Self::LittleEndian, ffi::G_DATA_STREAM_BYTE_ORDER_HOST_ENDIAN => Self::HostEndian, value => Self::__Unknown(value), } } } impl StaticType for DataStreamByteOrder { #[inline] #[doc(alias = "g_data_stream_byte_order_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_data_stream_byte_order_get_type()) } } } impl glib::HasParamSpec for DataStreamByteOrder { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DataStreamByteOrder { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DataStreamByteOrder { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DataStreamByteOrder { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DataStreamByteOrder) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDataStreamNewlineType")] pub enum DataStreamNewlineType { #[doc(alias = "G_DATA_STREAM_NEWLINE_TYPE_LF")] Lf, #[doc(alias = "G_DATA_STREAM_NEWLINE_TYPE_CR")] Cr, #[doc(alias = "G_DATA_STREAM_NEWLINE_TYPE_CR_LF")] CrLf, #[doc(alias = "G_DATA_STREAM_NEWLINE_TYPE_ANY")] Any, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DataStreamNewlineType { type GlibType = ffi::GDataStreamNewlineType; #[inline] fn into_glib(self) -> ffi::GDataStreamNewlineType { match self { Self::Lf => ffi::G_DATA_STREAM_NEWLINE_TYPE_LF, Self::Cr => ffi::G_DATA_STREAM_NEWLINE_TYPE_CR, Self::CrLf => ffi::G_DATA_STREAM_NEWLINE_TYPE_CR_LF, Self::Any => ffi::G_DATA_STREAM_NEWLINE_TYPE_ANY, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DataStreamNewlineType { #[inline] unsafe fn from_glib(value: ffi::GDataStreamNewlineType) -> Self { match value { ffi::G_DATA_STREAM_NEWLINE_TYPE_LF => Self::Lf, ffi::G_DATA_STREAM_NEWLINE_TYPE_CR => Self::Cr, ffi::G_DATA_STREAM_NEWLINE_TYPE_CR_LF => Self::CrLf, ffi::G_DATA_STREAM_NEWLINE_TYPE_ANY => Self::Any, value => Self::__Unknown(value), } } } impl StaticType for DataStreamNewlineType { #[inline] #[doc(alias = "g_data_stream_newline_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_data_stream_newline_type_get_type()) } } } impl glib::HasParamSpec for DataStreamNewlineType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DataStreamNewlineType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DataStreamNewlineType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DataStreamNewlineType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DataStreamNewlineType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GDriveStartStopType")] pub enum DriveStartStopType { #[doc(alias = "G_DRIVE_START_STOP_TYPE_UNKNOWN")] Unknown, #[doc(alias = "G_DRIVE_START_STOP_TYPE_SHUTDOWN")] Shutdown, #[doc(alias = "G_DRIVE_START_STOP_TYPE_NETWORK")] Network, #[doc(alias = "G_DRIVE_START_STOP_TYPE_MULTIDISK")] Multidisk, #[doc(alias = "G_DRIVE_START_STOP_TYPE_PASSWORD")] Password, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for DriveStartStopType { type GlibType = ffi::GDriveStartStopType; #[inline] fn into_glib(self) -> ffi::GDriveStartStopType { match self { Self::Unknown => ffi::G_DRIVE_START_STOP_TYPE_UNKNOWN, Self::Shutdown => ffi::G_DRIVE_START_STOP_TYPE_SHUTDOWN, Self::Network => ffi::G_DRIVE_START_STOP_TYPE_NETWORK, Self::Multidisk => ffi::G_DRIVE_START_STOP_TYPE_MULTIDISK, Self::Password => ffi::G_DRIVE_START_STOP_TYPE_PASSWORD, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for DriveStartStopType { #[inline] unsafe fn from_glib(value: ffi::GDriveStartStopType) -> Self { match value { ffi::G_DRIVE_START_STOP_TYPE_UNKNOWN => Self::Unknown, ffi::G_DRIVE_START_STOP_TYPE_SHUTDOWN => Self::Shutdown, ffi::G_DRIVE_START_STOP_TYPE_NETWORK => Self::Network, ffi::G_DRIVE_START_STOP_TYPE_MULTIDISK => Self::Multidisk, ffi::G_DRIVE_START_STOP_TYPE_PASSWORD => Self::Password, value => Self::__Unknown(value), } } } impl StaticType for DriveStartStopType { #[inline] #[doc(alias = "g_drive_start_stop_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_drive_start_stop_type_get_type()) } } } impl glib::HasParamSpec for DriveStartStopType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for DriveStartStopType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DriveStartStopType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for DriveStartStopType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DriveStartStopType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GEmblemOrigin")] pub enum EmblemOrigin { #[doc(alias = "G_EMBLEM_ORIGIN_UNKNOWN")] Unknown, #[doc(alias = "G_EMBLEM_ORIGIN_DEVICE")] Device, #[doc(alias = "G_EMBLEM_ORIGIN_LIVEMETADATA")] Livemetadata, #[doc(alias = "G_EMBLEM_ORIGIN_TAG")] Tag, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for EmblemOrigin { type GlibType = ffi::GEmblemOrigin; #[inline] fn into_glib(self) -> ffi::GEmblemOrigin { match self { Self::Unknown => ffi::G_EMBLEM_ORIGIN_UNKNOWN, Self::Device => ffi::G_EMBLEM_ORIGIN_DEVICE, Self::Livemetadata => ffi::G_EMBLEM_ORIGIN_LIVEMETADATA, Self::Tag => ffi::G_EMBLEM_ORIGIN_TAG, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for EmblemOrigin { #[inline] unsafe fn from_glib(value: ffi::GEmblemOrigin) -> Self { match value { ffi::G_EMBLEM_ORIGIN_UNKNOWN => Self::Unknown, ffi::G_EMBLEM_ORIGIN_DEVICE => Self::Device, ffi::G_EMBLEM_ORIGIN_LIVEMETADATA => Self::Livemetadata, ffi::G_EMBLEM_ORIGIN_TAG => Self::Tag, value => Self::__Unknown(value), } } } impl StaticType for EmblemOrigin { #[inline] #[doc(alias = "g_emblem_origin_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_emblem_origin_get_type()) } } } impl glib::HasParamSpec for EmblemOrigin { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for EmblemOrigin { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for EmblemOrigin { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for EmblemOrigin { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: EmblemOrigin) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GFileAttributeStatus")] pub enum FileAttributeStatus { #[doc(alias = "G_FILE_ATTRIBUTE_STATUS_UNSET")] Unset, #[doc(alias = "G_FILE_ATTRIBUTE_STATUS_SET")] Set, #[doc(alias = "G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING")] ErrorSetting, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for FileAttributeStatus { type GlibType = ffi::GFileAttributeStatus; #[inline] fn into_glib(self) -> ffi::GFileAttributeStatus { match self { Self::Unset => ffi::G_FILE_ATTRIBUTE_STATUS_UNSET, Self::Set => ffi::G_FILE_ATTRIBUTE_STATUS_SET, Self::ErrorSetting => ffi::G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileAttributeStatus { #[inline] unsafe fn from_glib(value: ffi::GFileAttributeStatus) -> Self { match value { ffi::G_FILE_ATTRIBUTE_STATUS_UNSET => Self::Unset, ffi::G_FILE_ATTRIBUTE_STATUS_SET => Self::Set, ffi::G_FILE_ATTRIBUTE_STATUS_ERROR_SETTING => Self::ErrorSetting, value => Self::__Unknown(value), } } } impl StaticType for FileAttributeStatus { #[inline] #[doc(alias = "g_file_attribute_status_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_attribute_status_get_type()) } } } impl glib::HasParamSpec for FileAttributeStatus { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for FileAttributeStatus { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileAttributeStatus { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for FileAttributeStatus { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileAttributeStatus) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GFileAttributeType")] pub enum FileAttributeType { #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_INVALID")] Invalid, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_STRING")] String, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_BYTE_STRING")] ByteString, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_BOOLEAN")] Boolean, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_UINT32")] Uint32, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_INT32")] Int32, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_UINT64")] Uint64, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_INT64")] Int64, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_OBJECT")] Object, #[doc(alias = "G_FILE_ATTRIBUTE_TYPE_STRINGV")] Stringv, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for FileAttributeType { type GlibType = ffi::GFileAttributeType; #[inline] fn into_glib(self) -> ffi::GFileAttributeType { match self { Self::Invalid => ffi::G_FILE_ATTRIBUTE_TYPE_INVALID, Self::String => ffi::G_FILE_ATTRIBUTE_TYPE_STRING, Self::ByteString => ffi::G_FILE_ATTRIBUTE_TYPE_BYTE_STRING, Self::Boolean => ffi::G_FILE_ATTRIBUTE_TYPE_BOOLEAN, Self::Uint32 => ffi::G_FILE_ATTRIBUTE_TYPE_UINT32, Self::Int32 => ffi::G_FILE_ATTRIBUTE_TYPE_INT32, Self::Uint64 => ffi::G_FILE_ATTRIBUTE_TYPE_UINT64, Self::Int64 => ffi::G_FILE_ATTRIBUTE_TYPE_INT64, Self::Object => ffi::G_FILE_ATTRIBUTE_TYPE_OBJECT, Self::Stringv => ffi::G_FILE_ATTRIBUTE_TYPE_STRINGV, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileAttributeType { #[inline] unsafe fn from_glib(value: ffi::GFileAttributeType) -> Self { match value { ffi::G_FILE_ATTRIBUTE_TYPE_INVALID => Self::Invalid, ffi::G_FILE_ATTRIBUTE_TYPE_STRING => Self::String, ffi::G_FILE_ATTRIBUTE_TYPE_BYTE_STRING => Self::ByteString, ffi::G_FILE_ATTRIBUTE_TYPE_BOOLEAN => Self::Boolean, ffi::G_FILE_ATTRIBUTE_TYPE_UINT32 => Self::Uint32, ffi::G_FILE_ATTRIBUTE_TYPE_INT32 => Self::Int32, ffi::G_FILE_ATTRIBUTE_TYPE_UINT64 => Self::Uint64, ffi::G_FILE_ATTRIBUTE_TYPE_INT64 => Self::Int64, ffi::G_FILE_ATTRIBUTE_TYPE_OBJECT => Self::Object, ffi::G_FILE_ATTRIBUTE_TYPE_STRINGV => Self::Stringv, value => Self::__Unknown(value), } } } impl StaticType for FileAttributeType { #[inline] #[doc(alias = "g_file_attribute_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_attribute_type_get_type()) } } } impl glib::HasParamSpec for FileAttributeType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for FileAttributeType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileAttributeType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for FileAttributeType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileAttributeType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GFileMonitorEvent")] pub enum FileMonitorEvent { #[doc(alias = "G_FILE_MONITOR_EVENT_CHANGED")] Changed, #[doc(alias = "G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT")] ChangesDoneHint, #[doc(alias = "G_FILE_MONITOR_EVENT_DELETED")] Deleted, #[doc(alias = "G_FILE_MONITOR_EVENT_CREATED")] Created, #[doc(alias = "G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED")] AttributeChanged, #[doc(alias = "G_FILE_MONITOR_EVENT_PRE_UNMOUNT")] PreUnmount, #[doc(alias = "G_FILE_MONITOR_EVENT_UNMOUNTED")] Unmounted, #[doc(alias = "G_FILE_MONITOR_EVENT_MOVED")] Moved, #[doc(alias = "G_FILE_MONITOR_EVENT_RENAMED")] Renamed, #[doc(alias = "G_FILE_MONITOR_EVENT_MOVED_IN")] MovedIn, #[doc(alias = "G_FILE_MONITOR_EVENT_MOVED_OUT")] MovedOut, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for FileMonitorEvent { type GlibType = ffi::GFileMonitorEvent; #[inline] fn into_glib(self) -> ffi::GFileMonitorEvent { match self { Self::Changed => ffi::G_FILE_MONITOR_EVENT_CHANGED, Self::ChangesDoneHint => ffi::G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT, Self::Deleted => ffi::G_FILE_MONITOR_EVENT_DELETED, Self::Created => ffi::G_FILE_MONITOR_EVENT_CREATED, Self::AttributeChanged => ffi::G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED, Self::PreUnmount => ffi::G_FILE_MONITOR_EVENT_PRE_UNMOUNT, Self::Unmounted => ffi::G_FILE_MONITOR_EVENT_UNMOUNTED, Self::Moved => ffi::G_FILE_MONITOR_EVENT_MOVED, Self::Renamed => ffi::G_FILE_MONITOR_EVENT_RENAMED, Self::MovedIn => ffi::G_FILE_MONITOR_EVENT_MOVED_IN, Self::MovedOut => ffi::G_FILE_MONITOR_EVENT_MOVED_OUT, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileMonitorEvent { #[inline] unsafe fn from_glib(value: ffi::GFileMonitorEvent) -> Self { match value { ffi::G_FILE_MONITOR_EVENT_CHANGED => Self::Changed, ffi::G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT => Self::ChangesDoneHint, ffi::G_FILE_MONITOR_EVENT_DELETED => Self::Deleted, ffi::G_FILE_MONITOR_EVENT_CREATED => Self::Created, ffi::G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED => Self::AttributeChanged, ffi::G_FILE_MONITOR_EVENT_PRE_UNMOUNT => Self::PreUnmount, ffi::G_FILE_MONITOR_EVENT_UNMOUNTED => Self::Unmounted, ffi::G_FILE_MONITOR_EVENT_MOVED => Self::Moved, ffi::G_FILE_MONITOR_EVENT_RENAMED => Self::Renamed, ffi::G_FILE_MONITOR_EVENT_MOVED_IN => Self::MovedIn, ffi::G_FILE_MONITOR_EVENT_MOVED_OUT => Self::MovedOut, value => Self::__Unknown(value), } } } impl StaticType for FileMonitorEvent { #[inline] #[doc(alias = "g_file_monitor_event_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_monitor_event_get_type()) } } } impl glib::HasParamSpec for FileMonitorEvent { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for FileMonitorEvent { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileMonitorEvent { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for FileMonitorEvent { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileMonitorEvent) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GFileType")] pub enum FileType { #[doc(alias = "G_FILE_TYPE_UNKNOWN")] Unknown, #[doc(alias = "G_FILE_TYPE_REGULAR")] Regular, #[doc(alias = "G_FILE_TYPE_DIRECTORY")] Directory, #[doc(alias = "G_FILE_TYPE_SYMBOLIC_LINK")] SymbolicLink, #[doc(alias = "G_FILE_TYPE_SPECIAL")] Special, #[doc(alias = "G_FILE_TYPE_SHORTCUT")] Shortcut, #[doc(alias = "G_FILE_TYPE_MOUNTABLE")] Mountable, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for FileType { type GlibType = ffi::GFileType; #[inline] fn into_glib(self) -> ffi::GFileType { match self { Self::Unknown => ffi::G_FILE_TYPE_UNKNOWN, Self::Regular => ffi::G_FILE_TYPE_REGULAR, Self::Directory => ffi::G_FILE_TYPE_DIRECTORY, Self::SymbolicLink => ffi::G_FILE_TYPE_SYMBOLIC_LINK, Self::Special => ffi::G_FILE_TYPE_SPECIAL, Self::Shortcut => ffi::G_FILE_TYPE_SHORTCUT, Self::Mountable => ffi::G_FILE_TYPE_MOUNTABLE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for FileType { #[inline] unsafe fn from_glib(value: ffi::GFileType) -> Self { match value { ffi::G_FILE_TYPE_UNKNOWN => Self::Unknown, ffi::G_FILE_TYPE_REGULAR => Self::Regular, ffi::G_FILE_TYPE_DIRECTORY => Self::Directory, ffi::G_FILE_TYPE_SYMBOLIC_LINK => Self::SymbolicLink, ffi::G_FILE_TYPE_SPECIAL => Self::Special, ffi::G_FILE_TYPE_SHORTCUT => Self::Shortcut, ffi::G_FILE_TYPE_MOUNTABLE => Self::Mountable, value => Self::__Unknown(value), } } } impl StaticType for FileType { #[inline] #[doc(alias = "g_file_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_type_get_type()) } } } impl glib::HasParamSpec for FileType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for FileType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for FileType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GIOErrorEnum")] pub enum IOErrorEnum { #[doc(alias = "G_IO_ERROR_FAILED")] Failed, #[doc(alias = "G_IO_ERROR_NOT_FOUND")] NotFound, #[doc(alias = "G_IO_ERROR_EXISTS")] Exists, #[doc(alias = "G_IO_ERROR_IS_DIRECTORY")] IsDirectory, #[doc(alias = "G_IO_ERROR_NOT_DIRECTORY")] NotDirectory, #[doc(alias = "G_IO_ERROR_NOT_EMPTY")] NotEmpty, #[doc(alias = "G_IO_ERROR_NOT_REGULAR_FILE")] NotRegularFile, #[doc(alias = "G_IO_ERROR_NOT_SYMBOLIC_LINK")] NotSymbolicLink, #[doc(alias = "G_IO_ERROR_NOT_MOUNTABLE_FILE")] NotMountableFile, #[doc(alias = "G_IO_ERROR_FILENAME_TOO_LONG")] FilenameTooLong, #[doc(alias = "G_IO_ERROR_INVALID_FILENAME")] InvalidFilename, #[doc(alias = "G_IO_ERROR_TOO_MANY_LINKS")] TooManyLinks, #[doc(alias = "G_IO_ERROR_NO_SPACE")] NoSpace, #[doc(alias = "G_IO_ERROR_INVALID_ARGUMENT")] InvalidArgument, #[doc(alias = "G_IO_ERROR_PERMISSION_DENIED")] PermissionDenied, #[doc(alias = "G_IO_ERROR_NOT_SUPPORTED")] NotSupported, #[doc(alias = "G_IO_ERROR_NOT_MOUNTED")] NotMounted, #[doc(alias = "G_IO_ERROR_ALREADY_MOUNTED")] AlreadyMounted, #[doc(alias = "G_IO_ERROR_CLOSED")] Closed, #[doc(alias = "G_IO_ERROR_CANCELLED")] Cancelled, #[doc(alias = "G_IO_ERROR_PENDING")] Pending, #[doc(alias = "G_IO_ERROR_READ_ONLY")] ReadOnly, #[doc(alias = "G_IO_ERROR_CANT_CREATE_BACKUP")] CantCreateBackup, #[doc(alias = "G_IO_ERROR_WRONG_ETAG")] WrongEtag, #[doc(alias = "G_IO_ERROR_TIMED_OUT")] TimedOut, #[doc(alias = "G_IO_ERROR_WOULD_RECURSE")] WouldRecurse, #[doc(alias = "G_IO_ERROR_BUSY")] Busy, #[doc(alias = "G_IO_ERROR_WOULD_BLOCK")] WouldBlock, #[doc(alias = "G_IO_ERROR_HOST_NOT_FOUND")] HostNotFound, #[doc(alias = "G_IO_ERROR_WOULD_MERGE")] WouldMerge, #[doc(alias = "G_IO_ERROR_FAILED_HANDLED")] FailedHandled, #[doc(alias = "G_IO_ERROR_TOO_MANY_OPEN_FILES")] TooManyOpenFiles, #[doc(alias = "G_IO_ERROR_NOT_INITIALIZED")] NotInitialized, #[doc(alias = "G_IO_ERROR_ADDRESS_IN_USE")] AddressInUse, #[doc(alias = "G_IO_ERROR_PARTIAL_INPUT")] PartialInput, #[doc(alias = "G_IO_ERROR_INVALID_DATA")] InvalidData, #[doc(alias = "G_IO_ERROR_DBUS_ERROR")] DbusError, #[doc(alias = "G_IO_ERROR_HOST_UNREACHABLE")] HostUnreachable, #[doc(alias = "G_IO_ERROR_NETWORK_UNREACHABLE")] NetworkUnreachable, #[doc(alias = "G_IO_ERROR_CONNECTION_REFUSED")] ConnectionRefused, #[doc(alias = "G_IO_ERROR_PROXY_FAILED")] ProxyFailed, #[doc(alias = "G_IO_ERROR_PROXY_AUTH_FAILED")] ProxyAuthFailed, #[doc(alias = "G_IO_ERROR_PROXY_NEED_AUTH")] ProxyNeedAuth, #[doc(alias = "G_IO_ERROR_PROXY_NOT_ALLOWED")] ProxyNotAllowed, #[doc(alias = "G_IO_ERROR_BROKEN_PIPE")] BrokenPipe, #[doc(alias = "G_IO_ERROR_NOT_CONNECTED")] NotConnected, #[doc(alias = "G_IO_ERROR_MESSAGE_TOO_LARGE")] MessageTooLarge, #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "G_IO_ERROR_NO_SUCH_DEVICE")] NoSuchDevice, #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "G_IO_ERROR_DESTINATION_UNSET")] DestinationUnset, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for IOErrorEnum { type GlibType = ffi::GIOErrorEnum; fn into_glib(self) -> ffi::GIOErrorEnum { match self { Self::Failed => ffi::G_IO_ERROR_FAILED, Self::NotFound => ffi::G_IO_ERROR_NOT_FOUND, Self::Exists => ffi::G_IO_ERROR_EXISTS, Self::IsDirectory => ffi::G_IO_ERROR_IS_DIRECTORY, Self::NotDirectory => ffi::G_IO_ERROR_NOT_DIRECTORY, Self::NotEmpty => ffi::G_IO_ERROR_NOT_EMPTY, Self::NotRegularFile => ffi::G_IO_ERROR_NOT_REGULAR_FILE, Self::NotSymbolicLink => ffi::G_IO_ERROR_NOT_SYMBOLIC_LINK, Self::NotMountableFile => ffi::G_IO_ERROR_NOT_MOUNTABLE_FILE, Self::FilenameTooLong => ffi::G_IO_ERROR_FILENAME_TOO_LONG, Self::InvalidFilename => ffi::G_IO_ERROR_INVALID_FILENAME, Self::TooManyLinks => ffi::G_IO_ERROR_TOO_MANY_LINKS, Self::NoSpace => ffi::G_IO_ERROR_NO_SPACE, Self::InvalidArgument => ffi::G_IO_ERROR_INVALID_ARGUMENT, Self::PermissionDenied => ffi::G_IO_ERROR_PERMISSION_DENIED, Self::NotSupported => ffi::G_IO_ERROR_NOT_SUPPORTED, Self::NotMounted => ffi::G_IO_ERROR_NOT_MOUNTED, Self::AlreadyMounted => ffi::G_IO_ERROR_ALREADY_MOUNTED, Self::Closed => ffi::G_IO_ERROR_CLOSED, Self::Cancelled => ffi::G_IO_ERROR_CANCELLED, Self::Pending => ffi::G_IO_ERROR_PENDING, Self::ReadOnly => ffi::G_IO_ERROR_READ_ONLY, Self::CantCreateBackup => ffi::G_IO_ERROR_CANT_CREATE_BACKUP, Self::WrongEtag => ffi::G_IO_ERROR_WRONG_ETAG, Self::TimedOut => ffi::G_IO_ERROR_TIMED_OUT, Self::WouldRecurse => ffi::G_IO_ERROR_WOULD_RECURSE, Self::Busy => ffi::G_IO_ERROR_BUSY, Self::WouldBlock => ffi::G_IO_ERROR_WOULD_BLOCK, Self::HostNotFound => ffi::G_IO_ERROR_HOST_NOT_FOUND, Self::WouldMerge => ffi::G_IO_ERROR_WOULD_MERGE, Self::FailedHandled => ffi::G_IO_ERROR_FAILED_HANDLED, Self::TooManyOpenFiles => ffi::G_IO_ERROR_TOO_MANY_OPEN_FILES, Self::NotInitialized => ffi::G_IO_ERROR_NOT_INITIALIZED, Self::AddressInUse => ffi::G_IO_ERROR_ADDRESS_IN_USE, Self::PartialInput => ffi::G_IO_ERROR_PARTIAL_INPUT, Self::InvalidData => ffi::G_IO_ERROR_INVALID_DATA, Self::DbusError => ffi::G_IO_ERROR_DBUS_ERROR, Self::HostUnreachable => ffi::G_IO_ERROR_HOST_UNREACHABLE, Self::NetworkUnreachable => ffi::G_IO_ERROR_NETWORK_UNREACHABLE, Self::ConnectionRefused => ffi::G_IO_ERROR_CONNECTION_REFUSED, Self::ProxyFailed => ffi::G_IO_ERROR_PROXY_FAILED, Self::ProxyAuthFailed => ffi::G_IO_ERROR_PROXY_AUTH_FAILED, Self::ProxyNeedAuth => ffi::G_IO_ERROR_PROXY_NEED_AUTH, Self::ProxyNotAllowed => ffi::G_IO_ERROR_PROXY_NOT_ALLOWED, Self::BrokenPipe => ffi::G_IO_ERROR_BROKEN_PIPE, Self::NotConnected => ffi::G_IO_ERROR_NOT_CONNECTED, Self::MessageTooLarge => ffi::G_IO_ERROR_MESSAGE_TOO_LARGE, #[cfg(feature = "v2_72")] Self::NoSuchDevice => ffi::G_IO_ERROR_NO_SUCH_DEVICE, #[cfg(feature = "v2_80")] Self::DestinationUnset => ffi::G_IO_ERROR_DESTINATION_UNSET, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for IOErrorEnum { unsafe fn from_glib(value: ffi::GIOErrorEnum) -> Self { match value { ffi::G_IO_ERROR_FAILED => Self::Failed, ffi::G_IO_ERROR_NOT_FOUND => Self::NotFound, ffi::G_IO_ERROR_EXISTS => Self::Exists, ffi::G_IO_ERROR_IS_DIRECTORY => Self::IsDirectory, ffi::G_IO_ERROR_NOT_DIRECTORY => Self::NotDirectory, ffi::G_IO_ERROR_NOT_EMPTY => Self::NotEmpty, ffi::G_IO_ERROR_NOT_REGULAR_FILE => Self::NotRegularFile, ffi::G_IO_ERROR_NOT_SYMBOLIC_LINK => Self::NotSymbolicLink, ffi::G_IO_ERROR_NOT_MOUNTABLE_FILE => Self::NotMountableFile, ffi::G_IO_ERROR_FILENAME_TOO_LONG => Self::FilenameTooLong, ffi::G_IO_ERROR_INVALID_FILENAME => Self::InvalidFilename, ffi::G_IO_ERROR_TOO_MANY_LINKS => Self::TooManyLinks, ffi::G_IO_ERROR_NO_SPACE => Self::NoSpace, ffi::G_IO_ERROR_INVALID_ARGUMENT => Self::InvalidArgument, ffi::G_IO_ERROR_PERMISSION_DENIED => Self::PermissionDenied, ffi::G_IO_ERROR_NOT_SUPPORTED => Self::NotSupported, ffi::G_IO_ERROR_NOT_MOUNTED => Self::NotMounted, ffi::G_IO_ERROR_ALREADY_MOUNTED => Self::AlreadyMounted, ffi::G_IO_ERROR_CLOSED => Self::Closed, ffi::G_IO_ERROR_CANCELLED => Self::Cancelled, ffi::G_IO_ERROR_PENDING => Self::Pending, ffi::G_IO_ERROR_READ_ONLY => Self::ReadOnly, ffi::G_IO_ERROR_CANT_CREATE_BACKUP => Self::CantCreateBackup, ffi::G_IO_ERROR_WRONG_ETAG => Self::WrongEtag, ffi::G_IO_ERROR_TIMED_OUT => Self::TimedOut, ffi::G_IO_ERROR_WOULD_RECURSE => Self::WouldRecurse, ffi::G_IO_ERROR_BUSY => Self::Busy, ffi::G_IO_ERROR_WOULD_BLOCK => Self::WouldBlock, ffi::G_IO_ERROR_HOST_NOT_FOUND => Self::HostNotFound, ffi::G_IO_ERROR_WOULD_MERGE => Self::WouldMerge, ffi::G_IO_ERROR_FAILED_HANDLED => Self::FailedHandled, ffi::G_IO_ERROR_TOO_MANY_OPEN_FILES => Self::TooManyOpenFiles, ffi::G_IO_ERROR_NOT_INITIALIZED => Self::NotInitialized, ffi::G_IO_ERROR_ADDRESS_IN_USE => Self::AddressInUse, ffi::G_IO_ERROR_PARTIAL_INPUT => Self::PartialInput, ffi::G_IO_ERROR_INVALID_DATA => Self::InvalidData, ffi::G_IO_ERROR_DBUS_ERROR => Self::DbusError, ffi::G_IO_ERROR_HOST_UNREACHABLE => Self::HostUnreachable, ffi::G_IO_ERROR_NETWORK_UNREACHABLE => Self::NetworkUnreachable, ffi::G_IO_ERROR_CONNECTION_REFUSED => Self::ConnectionRefused, ffi::G_IO_ERROR_PROXY_FAILED => Self::ProxyFailed, ffi::G_IO_ERROR_PROXY_AUTH_FAILED => Self::ProxyAuthFailed, ffi::G_IO_ERROR_PROXY_NEED_AUTH => Self::ProxyNeedAuth, ffi::G_IO_ERROR_PROXY_NOT_ALLOWED => Self::ProxyNotAllowed, ffi::G_IO_ERROR_BROKEN_PIPE => Self::BrokenPipe, ffi::G_IO_ERROR_NOT_CONNECTED => Self::NotConnected, ffi::G_IO_ERROR_MESSAGE_TOO_LARGE => Self::MessageTooLarge, #[cfg(feature = "v2_72")] ffi::G_IO_ERROR_NO_SUCH_DEVICE => Self::NoSuchDevice, #[cfg(feature = "v2_80")] ffi::G_IO_ERROR_DESTINATION_UNSET => Self::DestinationUnset, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for IOErrorEnum { #[inline] fn domain() -> glib::Quark { unsafe { from_glib(ffi::g_io_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { match unsafe { from_glib(code) } { Self::__Unknown(_) => Some(Self::Failed), value => Some(value), } } } impl StaticType for IOErrorEnum { #[inline] #[doc(alias = "g_io_error_enum_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_io_error_enum_get_type()) } } } impl glib::HasParamSpec for IOErrorEnum { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for IOErrorEnum { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for IOErrorEnum { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for IOErrorEnum { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: IOErrorEnum) -> Self { ToValue::to_value(&v) } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GMemoryMonitorWarningLevel")] pub enum MemoryMonitorWarningLevel { #[doc(alias = "G_MEMORY_MONITOR_WARNING_LEVEL_LOW")] Low, #[doc(alias = "G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM")] Medium, #[doc(alias = "G_MEMORY_MONITOR_WARNING_LEVEL_CRITICAL")] Critical, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[doc(hidden)] impl IntoGlib for MemoryMonitorWarningLevel { type GlibType = ffi::GMemoryMonitorWarningLevel; #[inline] fn into_glib(self) -> ffi::GMemoryMonitorWarningLevel { match self { Self::Low => ffi::G_MEMORY_MONITOR_WARNING_LEVEL_LOW, Self::Medium => ffi::G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM, Self::Critical => ffi::G_MEMORY_MONITOR_WARNING_LEVEL_CRITICAL, Self::__Unknown(value) => value, } } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[doc(hidden)] impl FromGlib for MemoryMonitorWarningLevel { #[inline] unsafe fn from_glib(value: ffi::GMemoryMonitorWarningLevel) -> Self { match value { ffi::G_MEMORY_MONITOR_WARNING_LEVEL_LOW => Self::Low, ffi::G_MEMORY_MONITOR_WARNING_LEVEL_MEDIUM => Self::Medium, ffi::G_MEMORY_MONITOR_WARNING_LEVEL_CRITICAL => Self::Critical, value => Self::__Unknown(value), } } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] impl StaticType for MemoryMonitorWarningLevel { #[inline] #[doc(alias = "g_memory_monitor_warning_level_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_memory_monitor_warning_level_get_type()) } } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] impl glib::HasParamSpec for MemoryMonitorWarningLevel { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] impl glib::value::ValueType for MemoryMonitorWarningLevel { type Type = Self; } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] unsafe impl<'a> glib::value::FromValue<'a> for MemoryMonitorWarningLevel { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] impl ToValue for MemoryMonitorWarningLevel { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] impl From for glib::Value { #[inline] fn from(v: MemoryMonitorWarningLevel) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GMountOperationResult")] pub enum MountOperationResult { #[doc(alias = "G_MOUNT_OPERATION_HANDLED")] Handled, #[doc(alias = "G_MOUNT_OPERATION_ABORTED")] Aborted, #[doc(alias = "G_MOUNT_OPERATION_UNHANDLED")] Unhandled, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for MountOperationResult { type GlibType = ffi::GMountOperationResult; #[inline] fn into_glib(self) -> ffi::GMountOperationResult { match self { Self::Handled => ffi::G_MOUNT_OPERATION_HANDLED, Self::Aborted => ffi::G_MOUNT_OPERATION_ABORTED, Self::Unhandled => ffi::G_MOUNT_OPERATION_UNHANDLED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for MountOperationResult { #[inline] unsafe fn from_glib(value: ffi::GMountOperationResult) -> Self { match value { ffi::G_MOUNT_OPERATION_HANDLED => Self::Handled, ffi::G_MOUNT_OPERATION_ABORTED => Self::Aborted, ffi::G_MOUNT_OPERATION_UNHANDLED => Self::Unhandled, value => Self::__Unknown(value), } } } impl StaticType for MountOperationResult { #[inline] #[doc(alias = "g_mount_operation_result_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_mount_operation_result_get_type()) } } } impl glib::HasParamSpec for MountOperationResult { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for MountOperationResult { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for MountOperationResult { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for MountOperationResult { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: MountOperationResult) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GNetworkConnectivity")] pub enum NetworkConnectivity { #[doc(alias = "G_NETWORK_CONNECTIVITY_LOCAL")] Local, #[doc(alias = "G_NETWORK_CONNECTIVITY_LIMITED")] Limited, #[doc(alias = "G_NETWORK_CONNECTIVITY_PORTAL")] Portal, #[doc(alias = "G_NETWORK_CONNECTIVITY_FULL")] Full, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for NetworkConnectivity { type GlibType = ffi::GNetworkConnectivity; #[inline] fn into_glib(self) -> ffi::GNetworkConnectivity { match self { Self::Local => ffi::G_NETWORK_CONNECTIVITY_LOCAL, Self::Limited => ffi::G_NETWORK_CONNECTIVITY_LIMITED, Self::Portal => ffi::G_NETWORK_CONNECTIVITY_PORTAL, Self::Full => ffi::G_NETWORK_CONNECTIVITY_FULL, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for NetworkConnectivity { #[inline] unsafe fn from_glib(value: ffi::GNetworkConnectivity) -> Self { match value { ffi::G_NETWORK_CONNECTIVITY_LOCAL => Self::Local, ffi::G_NETWORK_CONNECTIVITY_LIMITED => Self::Limited, ffi::G_NETWORK_CONNECTIVITY_PORTAL => Self::Portal, ffi::G_NETWORK_CONNECTIVITY_FULL => Self::Full, value => Self::__Unknown(value), } } } impl StaticType for NetworkConnectivity { #[inline] #[doc(alias = "g_network_connectivity_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_network_connectivity_get_type()) } } } impl glib::HasParamSpec for NetworkConnectivity { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for NetworkConnectivity { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for NetworkConnectivity { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for NetworkConnectivity { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: NetworkConnectivity) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GNotificationPriority")] pub enum NotificationPriority { #[doc(alias = "G_NOTIFICATION_PRIORITY_NORMAL")] Normal, #[doc(alias = "G_NOTIFICATION_PRIORITY_LOW")] Low, #[doc(alias = "G_NOTIFICATION_PRIORITY_HIGH")] High, #[doc(alias = "G_NOTIFICATION_PRIORITY_URGENT")] Urgent, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for NotificationPriority { type GlibType = ffi::GNotificationPriority; #[inline] fn into_glib(self) -> ffi::GNotificationPriority { match self { Self::Normal => ffi::G_NOTIFICATION_PRIORITY_NORMAL, Self::Low => ffi::G_NOTIFICATION_PRIORITY_LOW, Self::High => ffi::G_NOTIFICATION_PRIORITY_HIGH, Self::Urgent => ffi::G_NOTIFICATION_PRIORITY_URGENT, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for NotificationPriority { #[inline] unsafe fn from_glib(value: ffi::GNotificationPriority) -> Self { match value { ffi::G_NOTIFICATION_PRIORITY_NORMAL => Self::Normal, ffi::G_NOTIFICATION_PRIORITY_LOW => Self::Low, ffi::G_NOTIFICATION_PRIORITY_HIGH => Self::High, ffi::G_NOTIFICATION_PRIORITY_URGENT => Self::Urgent, value => Self::__Unknown(value), } } } impl StaticType for NotificationPriority { #[inline] #[doc(alias = "g_notification_priority_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_notification_priority_get_type()) } } } impl glib::HasParamSpec for NotificationPriority { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for NotificationPriority { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for NotificationPriority { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for NotificationPriority { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: NotificationPriority) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GPasswordSave")] pub enum PasswordSave { #[doc(alias = "G_PASSWORD_SAVE_NEVER")] Never, #[doc(alias = "G_PASSWORD_SAVE_FOR_SESSION")] ForSession, #[doc(alias = "G_PASSWORD_SAVE_PERMANENTLY")] Permanently, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for PasswordSave { type GlibType = ffi::GPasswordSave; #[inline] fn into_glib(self) -> ffi::GPasswordSave { match self { Self::Never => ffi::G_PASSWORD_SAVE_NEVER, Self::ForSession => ffi::G_PASSWORD_SAVE_FOR_SESSION, Self::Permanently => ffi::G_PASSWORD_SAVE_PERMANENTLY, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for PasswordSave { #[inline] unsafe fn from_glib(value: ffi::GPasswordSave) -> Self { match value { ffi::G_PASSWORD_SAVE_NEVER => Self::Never, ffi::G_PASSWORD_SAVE_FOR_SESSION => Self::ForSession, ffi::G_PASSWORD_SAVE_PERMANENTLY => Self::Permanently, value => Self::__Unknown(value), } } } impl StaticType for PasswordSave { #[inline] #[doc(alias = "g_password_save_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_password_save_get_type()) } } } impl glib::HasParamSpec for PasswordSave { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for PasswordSave { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for PasswordSave { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for PasswordSave { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: PasswordSave) -> Self { ToValue::to_value(&v) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GPollableReturn")] pub enum PollableReturn { #[doc(alias = "G_POLLABLE_RETURN_FAILED")] Failed, #[doc(alias = "G_POLLABLE_RETURN_OK")] Ok, #[doc(alias = "G_POLLABLE_RETURN_WOULD_BLOCK")] WouldBlock, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl IntoGlib for PollableReturn { type GlibType = ffi::GPollableReturn; #[inline] fn into_glib(self) -> ffi::GPollableReturn { match self { Self::Failed => ffi::G_POLLABLE_RETURN_FAILED, Self::Ok => ffi::G_POLLABLE_RETURN_OK, Self::WouldBlock => ffi::G_POLLABLE_RETURN_WOULD_BLOCK, Self::__Unknown(value) => value, } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl FromGlib for PollableReturn { #[inline] unsafe fn from_glib(value: ffi::GPollableReturn) -> Self { match value { ffi::G_POLLABLE_RETURN_FAILED => Self::Failed, ffi::G_POLLABLE_RETURN_OK => Self::Ok, ffi::G_POLLABLE_RETURN_WOULD_BLOCK => Self::WouldBlock, value => Self::__Unknown(value), } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl StaticType for PollableReturn { #[inline] #[doc(alias = "g_pollable_return_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_pollable_return_get_type()) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl glib::HasParamSpec for PollableReturn { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl glib::value::ValueType for PollableReturn { type Type = Self; } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] unsafe impl<'a> glib::value::FromValue<'a> for PollableReturn { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl ToValue for PollableReturn { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl From for glib::Value { #[inline] fn from(v: PollableReturn) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GResolverError")] pub enum ResolverError { #[doc(alias = "G_RESOLVER_ERROR_NOT_FOUND")] NotFound, #[doc(alias = "G_RESOLVER_ERROR_TEMPORARY_FAILURE")] TemporaryFailure, #[doc(alias = "G_RESOLVER_ERROR_INTERNAL")] Internal, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for ResolverError { type GlibType = ffi::GResolverError; #[inline] fn into_glib(self) -> ffi::GResolverError { match self { Self::NotFound => ffi::G_RESOLVER_ERROR_NOT_FOUND, Self::TemporaryFailure => ffi::G_RESOLVER_ERROR_TEMPORARY_FAILURE, Self::Internal => ffi::G_RESOLVER_ERROR_INTERNAL, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ResolverError { #[inline] unsafe fn from_glib(value: ffi::GResolverError) -> Self { match value { ffi::G_RESOLVER_ERROR_NOT_FOUND => Self::NotFound, ffi::G_RESOLVER_ERROR_TEMPORARY_FAILURE => Self::TemporaryFailure, ffi::G_RESOLVER_ERROR_INTERNAL => Self::Internal, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for ResolverError { #[inline] fn domain() -> glib::Quark { unsafe { from_glib(ffi::g_resolver_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { match unsafe { from_glib(code) } { value => Some(value), } } } impl StaticType for ResolverError { #[inline] #[doc(alias = "g_resolver_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_resolver_error_get_type()) } } } impl glib::HasParamSpec for ResolverError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for ResolverError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ResolverError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for ResolverError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ResolverError) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GResolverRecordType")] pub enum ResolverRecordType { #[doc(alias = "G_RESOLVER_RECORD_SRV")] Srv, #[doc(alias = "G_RESOLVER_RECORD_MX")] Mx, #[doc(alias = "G_RESOLVER_RECORD_TXT")] Txt, #[doc(alias = "G_RESOLVER_RECORD_SOA")] Soa, #[doc(alias = "G_RESOLVER_RECORD_NS")] Ns, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for ResolverRecordType { type GlibType = ffi::GResolverRecordType; #[inline] fn into_glib(self) -> ffi::GResolverRecordType { match self { Self::Srv => ffi::G_RESOLVER_RECORD_SRV, Self::Mx => ffi::G_RESOLVER_RECORD_MX, Self::Txt => ffi::G_RESOLVER_RECORD_TXT, Self::Soa => ffi::G_RESOLVER_RECORD_SOA, Self::Ns => ffi::G_RESOLVER_RECORD_NS, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ResolverRecordType { #[inline] unsafe fn from_glib(value: ffi::GResolverRecordType) -> Self { match value { ffi::G_RESOLVER_RECORD_SRV => Self::Srv, ffi::G_RESOLVER_RECORD_MX => Self::Mx, ffi::G_RESOLVER_RECORD_TXT => Self::Txt, ffi::G_RESOLVER_RECORD_SOA => Self::Soa, ffi::G_RESOLVER_RECORD_NS => Self::Ns, value => Self::__Unknown(value), } } } impl StaticType for ResolverRecordType { #[inline] #[doc(alias = "g_resolver_record_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_resolver_record_type_get_type()) } } } impl glib::HasParamSpec for ResolverRecordType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for ResolverRecordType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ResolverRecordType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for ResolverRecordType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ResolverRecordType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GResourceError")] pub enum ResourceError { #[doc(alias = "G_RESOURCE_ERROR_NOT_FOUND")] NotFound, #[doc(alias = "G_RESOURCE_ERROR_INTERNAL")] Internal, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for ResourceError { type GlibType = ffi::GResourceError; #[inline] fn into_glib(self) -> ffi::GResourceError { match self { Self::NotFound => ffi::G_RESOURCE_ERROR_NOT_FOUND, Self::Internal => ffi::G_RESOURCE_ERROR_INTERNAL, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ResourceError { #[inline] unsafe fn from_glib(value: ffi::GResourceError) -> Self { match value { ffi::G_RESOURCE_ERROR_NOT_FOUND => Self::NotFound, ffi::G_RESOURCE_ERROR_INTERNAL => Self::Internal, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for ResourceError { #[inline] fn domain() -> glib::Quark { unsafe { from_glib(ffi::g_resource_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { match unsafe { from_glib(code) } { value => Some(value), } } } impl StaticType for ResourceError { #[inline] #[doc(alias = "g_resource_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_resource_error_get_type()) } } } impl glib::HasParamSpec for ResourceError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for ResourceError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ResourceError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for ResourceError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ResourceError) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GSocketClientEvent")] pub enum SocketClientEvent { #[doc(alias = "G_SOCKET_CLIENT_RESOLVING")] Resolving, #[doc(alias = "G_SOCKET_CLIENT_RESOLVED")] Resolved, #[doc(alias = "G_SOCKET_CLIENT_CONNECTING")] Connecting, #[doc(alias = "G_SOCKET_CLIENT_CONNECTED")] Connected, #[doc(alias = "G_SOCKET_CLIENT_PROXY_NEGOTIATING")] ProxyNegotiating, #[doc(alias = "G_SOCKET_CLIENT_PROXY_NEGOTIATED")] ProxyNegotiated, #[doc(alias = "G_SOCKET_CLIENT_TLS_HANDSHAKING")] TlsHandshaking, #[doc(alias = "G_SOCKET_CLIENT_TLS_HANDSHAKED")] TlsHandshaked, #[doc(alias = "G_SOCKET_CLIENT_COMPLETE")] Complete, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for SocketClientEvent { type GlibType = ffi::GSocketClientEvent; #[inline] fn into_glib(self) -> ffi::GSocketClientEvent { match self { Self::Resolving => ffi::G_SOCKET_CLIENT_RESOLVING, Self::Resolved => ffi::G_SOCKET_CLIENT_RESOLVED, Self::Connecting => ffi::G_SOCKET_CLIENT_CONNECTING, Self::Connected => ffi::G_SOCKET_CLIENT_CONNECTED, Self::ProxyNegotiating => ffi::G_SOCKET_CLIENT_PROXY_NEGOTIATING, Self::ProxyNegotiated => ffi::G_SOCKET_CLIENT_PROXY_NEGOTIATED, Self::TlsHandshaking => ffi::G_SOCKET_CLIENT_TLS_HANDSHAKING, Self::TlsHandshaked => ffi::G_SOCKET_CLIENT_TLS_HANDSHAKED, Self::Complete => ffi::G_SOCKET_CLIENT_COMPLETE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketClientEvent { #[inline] unsafe fn from_glib(value: ffi::GSocketClientEvent) -> Self { match value { ffi::G_SOCKET_CLIENT_RESOLVING => Self::Resolving, ffi::G_SOCKET_CLIENT_RESOLVED => Self::Resolved, ffi::G_SOCKET_CLIENT_CONNECTING => Self::Connecting, ffi::G_SOCKET_CLIENT_CONNECTED => Self::Connected, ffi::G_SOCKET_CLIENT_PROXY_NEGOTIATING => Self::ProxyNegotiating, ffi::G_SOCKET_CLIENT_PROXY_NEGOTIATED => Self::ProxyNegotiated, ffi::G_SOCKET_CLIENT_TLS_HANDSHAKING => Self::TlsHandshaking, ffi::G_SOCKET_CLIENT_TLS_HANDSHAKED => Self::TlsHandshaked, ffi::G_SOCKET_CLIENT_COMPLETE => Self::Complete, value => Self::__Unknown(value), } } } impl StaticType for SocketClientEvent { #[inline] #[doc(alias = "g_socket_client_event_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_socket_client_event_get_type()) } } } impl glib::HasParamSpec for SocketClientEvent { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for SocketClientEvent { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketClientEvent { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for SocketClientEvent { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SocketClientEvent) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GSocketFamily")] pub enum SocketFamily { #[doc(alias = "G_SOCKET_FAMILY_INVALID")] Invalid, #[doc(alias = "G_SOCKET_FAMILY_UNIX")] Unix, #[doc(alias = "G_SOCKET_FAMILY_IPV4")] Ipv4, #[doc(alias = "G_SOCKET_FAMILY_IPV6")] Ipv6, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for SocketFamily { type GlibType = ffi::GSocketFamily; #[inline] fn into_glib(self) -> ffi::GSocketFamily { match self { Self::Invalid => ffi::G_SOCKET_FAMILY_INVALID, Self::Unix => ffi::G_SOCKET_FAMILY_UNIX, Self::Ipv4 => ffi::G_SOCKET_FAMILY_IPV4, Self::Ipv6 => ffi::G_SOCKET_FAMILY_IPV6, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketFamily { #[inline] unsafe fn from_glib(value: ffi::GSocketFamily) -> Self { match value { ffi::G_SOCKET_FAMILY_INVALID => Self::Invalid, ffi::G_SOCKET_FAMILY_UNIX => Self::Unix, ffi::G_SOCKET_FAMILY_IPV4 => Self::Ipv4, ffi::G_SOCKET_FAMILY_IPV6 => Self::Ipv6, value => Self::__Unknown(value), } } } impl StaticType for SocketFamily { #[inline] #[doc(alias = "g_socket_family_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_socket_family_get_type()) } } } impl glib::HasParamSpec for SocketFamily { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for SocketFamily { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketFamily { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for SocketFamily { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SocketFamily) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GSocketListenerEvent")] pub enum SocketListenerEvent { #[doc(alias = "G_SOCKET_LISTENER_BINDING")] Binding, #[doc(alias = "G_SOCKET_LISTENER_BOUND")] Bound, #[doc(alias = "G_SOCKET_LISTENER_LISTENING")] Listening, #[doc(alias = "G_SOCKET_LISTENER_LISTENED")] Listened, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for SocketListenerEvent { type GlibType = ffi::GSocketListenerEvent; #[inline] fn into_glib(self) -> ffi::GSocketListenerEvent { match self { Self::Binding => ffi::G_SOCKET_LISTENER_BINDING, Self::Bound => ffi::G_SOCKET_LISTENER_BOUND, Self::Listening => ffi::G_SOCKET_LISTENER_LISTENING, Self::Listened => ffi::G_SOCKET_LISTENER_LISTENED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketListenerEvent { #[inline] unsafe fn from_glib(value: ffi::GSocketListenerEvent) -> Self { match value { ffi::G_SOCKET_LISTENER_BINDING => Self::Binding, ffi::G_SOCKET_LISTENER_BOUND => Self::Bound, ffi::G_SOCKET_LISTENER_LISTENING => Self::Listening, ffi::G_SOCKET_LISTENER_LISTENED => Self::Listened, value => Self::__Unknown(value), } } } impl StaticType for SocketListenerEvent { #[inline] #[doc(alias = "g_socket_listener_event_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_socket_listener_event_get_type()) } } } impl glib::HasParamSpec for SocketListenerEvent { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for SocketListenerEvent { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketListenerEvent { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for SocketListenerEvent { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SocketListenerEvent) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GSocketProtocol")] pub enum SocketProtocol { #[doc(alias = "G_SOCKET_PROTOCOL_UNKNOWN")] Unknown, #[doc(alias = "G_SOCKET_PROTOCOL_DEFAULT")] Default, #[doc(alias = "G_SOCKET_PROTOCOL_TCP")] Tcp, #[doc(alias = "G_SOCKET_PROTOCOL_UDP")] Udp, #[doc(alias = "G_SOCKET_PROTOCOL_SCTP")] Sctp, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for SocketProtocol { type GlibType = ffi::GSocketProtocol; #[inline] fn into_glib(self) -> ffi::GSocketProtocol { match self { Self::Unknown => ffi::G_SOCKET_PROTOCOL_UNKNOWN, Self::Default => ffi::G_SOCKET_PROTOCOL_DEFAULT, Self::Tcp => ffi::G_SOCKET_PROTOCOL_TCP, Self::Udp => ffi::G_SOCKET_PROTOCOL_UDP, Self::Sctp => ffi::G_SOCKET_PROTOCOL_SCTP, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketProtocol { #[inline] unsafe fn from_glib(value: ffi::GSocketProtocol) -> Self { match value { ffi::G_SOCKET_PROTOCOL_UNKNOWN => Self::Unknown, ffi::G_SOCKET_PROTOCOL_DEFAULT => Self::Default, ffi::G_SOCKET_PROTOCOL_TCP => Self::Tcp, ffi::G_SOCKET_PROTOCOL_UDP => Self::Udp, ffi::G_SOCKET_PROTOCOL_SCTP => Self::Sctp, value => Self::__Unknown(value), } } } impl StaticType for SocketProtocol { #[inline] #[doc(alias = "g_socket_protocol_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_socket_protocol_get_type()) } } } impl glib::HasParamSpec for SocketProtocol { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for SocketProtocol { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketProtocol { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for SocketProtocol { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SocketProtocol) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GSocketType")] pub enum SocketType { #[doc(alias = "G_SOCKET_TYPE_INVALID")] Invalid, #[doc(alias = "G_SOCKET_TYPE_STREAM")] Stream, #[doc(alias = "G_SOCKET_TYPE_DATAGRAM")] Datagram, #[doc(alias = "G_SOCKET_TYPE_SEQPACKET")] Seqpacket, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for SocketType { type GlibType = ffi::GSocketType; #[inline] fn into_glib(self) -> ffi::GSocketType { match self { Self::Invalid => ffi::G_SOCKET_TYPE_INVALID, Self::Stream => ffi::G_SOCKET_TYPE_STREAM, Self::Datagram => ffi::G_SOCKET_TYPE_DATAGRAM, Self::Seqpacket => ffi::G_SOCKET_TYPE_SEQPACKET, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for SocketType { #[inline] unsafe fn from_glib(value: ffi::GSocketType) -> Self { match value { ffi::G_SOCKET_TYPE_INVALID => Self::Invalid, ffi::G_SOCKET_TYPE_STREAM => Self::Stream, ffi::G_SOCKET_TYPE_DATAGRAM => Self::Datagram, ffi::G_SOCKET_TYPE_SEQPACKET => Self::Seqpacket, value => Self::__Unknown(value), } } } impl StaticType for SocketType { #[inline] #[doc(alias = "g_socket_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_socket_type_get_type()) } } } impl glib::HasParamSpec for SocketType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for SocketType { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for SocketType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SocketType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsAuthenticationMode")] pub enum TlsAuthenticationMode { #[doc(alias = "G_TLS_AUTHENTICATION_NONE")] None, #[doc(alias = "G_TLS_AUTHENTICATION_REQUESTED")] Requested, #[doc(alias = "G_TLS_AUTHENTICATION_REQUIRED")] Required, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TlsAuthenticationMode { type GlibType = ffi::GTlsAuthenticationMode; #[inline] fn into_glib(self) -> ffi::GTlsAuthenticationMode { match self { Self::None => ffi::G_TLS_AUTHENTICATION_NONE, Self::Requested => ffi::G_TLS_AUTHENTICATION_REQUESTED, Self::Required => ffi::G_TLS_AUTHENTICATION_REQUIRED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsAuthenticationMode { #[inline] unsafe fn from_glib(value: ffi::GTlsAuthenticationMode) -> Self { match value { ffi::G_TLS_AUTHENTICATION_NONE => Self::None, ffi::G_TLS_AUTHENTICATION_REQUESTED => Self::Requested, ffi::G_TLS_AUTHENTICATION_REQUIRED => Self::Required, value => Self::__Unknown(value), } } } impl StaticType for TlsAuthenticationMode { #[inline] #[doc(alias = "g_tls_authentication_mode_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_authentication_mode_get_type()) } } } impl glib::HasParamSpec for TlsAuthenticationMode { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TlsAuthenticationMode { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsAuthenticationMode { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TlsAuthenticationMode { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsAuthenticationMode) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsCertificateRequestFlags")] pub enum TlsCertificateRequestFlags { #[doc(alias = "G_TLS_CERTIFICATE_REQUEST_NONE")] None, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TlsCertificateRequestFlags { type GlibType = ffi::GTlsCertificateRequestFlags; #[inline] fn into_glib(self) -> ffi::GTlsCertificateRequestFlags { match self { Self::None => ffi::G_TLS_CERTIFICATE_REQUEST_NONE, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsCertificateRequestFlags { #[inline] unsafe fn from_glib(value: ffi::GTlsCertificateRequestFlags) -> Self { match value { ffi::G_TLS_CERTIFICATE_REQUEST_NONE => Self::None, value => Self::__Unknown(value), } } } impl StaticType for TlsCertificateRequestFlags { #[inline] #[doc(alias = "g_tls_certificate_request_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_certificate_request_flags_get_type()) } } } impl glib::HasParamSpec for TlsCertificateRequestFlags { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TlsCertificateRequestFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsCertificateRequestFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TlsCertificateRequestFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsCertificateRequestFlags) -> Self { ToValue::to_value(&v) } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsChannelBindingType")] pub enum TlsChannelBindingType { #[doc(alias = "G_TLS_CHANNEL_BINDING_TLS_UNIQUE")] Unique, #[doc(alias = "G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT")] ServerEndPoint, #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_TLS_CHANNEL_BINDING_TLS_EXPORTER")] Exporter, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[doc(hidden)] impl IntoGlib for TlsChannelBindingType { type GlibType = ffi::GTlsChannelBindingType; #[inline] fn into_glib(self) -> ffi::GTlsChannelBindingType { match self { Self::Unique => ffi::G_TLS_CHANNEL_BINDING_TLS_UNIQUE, Self::ServerEndPoint => ffi::G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT, #[cfg(feature = "v2_74")] Self::Exporter => ffi::G_TLS_CHANNEL_BINDING_TLS_EXPORTER, Self::__Unknown(value) => value, } } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[doc(hidden)] impl FromGlib for TlsChannelBindingType { #[inline] unsafe fn from_glib(value: ffi::GTlsChannelBindingType) -> Self { match value { ffi::G_TLS_CHANNEL_BINDING_TLS_UNIQUE => Self::Unique, ffi::G_TLS_CHANNEL_BINDING_TLS_SERVER_END_POINT => Self::ServerEndPoint, #[cfg(feature = "v2_74")] ffi::G_TLS_CHANNEL_BINDING_TLS_EXPORTER => Self::Exporter, value => Self::__Unknown(value), } } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] impl StaticType for TlsChannelBindingType { #[inline] #[doc(alias = "g_tls_channel_binding_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_channel_binding_type_get_type()) } } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] impl glib::HasParamSpec for TlsChannelBindingType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] impl glib::value::ValueType for TlsChannelBindingType { type Type = Self; } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] unsafe impl<'a> glib::value::FromValue<'a> for TlsChannelBindingType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] impl ToValue for TlsChannelBindingType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] impl From for glib::Value { #[inline] fn from(v: TlsChannelBindingType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsDatabaseLookupFlags")] pub enum TlsDatabaseLookupFlags { #[doc(alias = "G_TLS_DATABASE_LOOKUP_NONE")] None, #[doc(alias = "G_TLS_DATABASE_LOOKUP_KEYPAIR")] Keypair, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TlsDatabaseLookupFlags { type GlibType = ffi::GTlsDatabaseLookupFlags; #[inline] fn into_glib(self) -> ffi::GTlsDatabaseLookupFlags { match self { Self::None => ffi::G_TLS_DATABASE_LOOKUP_NONE, Self::Keypair => ffi::G_TLS_DATABASE_LOOKUP_KEYPAIR, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsDatabaseLookupFlags { #[inline] unsafe fn from_glib(value: ffi::GTlsDatabaseLookupFlags) -> Self { match value { ffi::G_TLS_DATABASE_LOOKUP_NONE => Self::None, ffi::G_TLS_DATABASE_LOOKUP_KEYPAIR => Self::Keypair, value => Self::__Unknown(value), } } } impl StaticType for TlsDatabaseLookupFlags { #[inline] #[doc(alias = "g_tls_database_lookup_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_database_lookup_flags_get_type()) } } } impl glib::HasParamSpec for TlsDatabaseLookupFlags { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TlsDatabaseLookupFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsDatabaseLookupFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TlsDatabaseLookupFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsDatabaseLookupFlags) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsError")] pub enum TlsError { #[doc(alias = "G_TLS_ERROR_UNAVAILABLE")] Unavailable, #[doc(alias = "G_TLS_ERROR_MISC")] Misc, #[doc(alias = "G_TLS_ERROR_BAD_CERTIFICATE")] BadCertificate, #[doc(alias = "G_TLS_ERROR_NOT_TLS")] NotTls, #[doc(alias = "G_TLS_ERROR_HANDSHAKE")] Handshake, #[doc(alias = "G_TLS_ERROR_CERTIFICATE_REQUIRED")] CertificateRequired, #[doc(alias = "G_TLS_ERROR_EOF")] Eof, #[doc(alias = "G_TLS_ERROR_INAPPROPRIATE_FALLBACK")] InappropriateFallback, #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD")] BadCertificatePassword, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TlsError { type GlibType = ffi::GTlsError; #[inline] fn into_glib(self) -> ffi::GTlsError { match self { Self::Unavailable => ffi::G_TLS_ERROR_UNAVAILABLE, Self::Misc => ffi::G_TLS_ERROR_MISC, Self::BadCertificate => ffi::G_TLS_ERROR_BAD_CERTIFICATE, Self::NotTls => ffi::G_TLS_ERROR_NOT_TLS, Self::Handshake => ffi::G_TLS_ERROR_HANDSHAKE, Self::CertificateRequired => ffi::G_TLS_ERROR_CERTIFICATE_REQUIRED, Self::Eof => ffi::G_TLS_ERROR_EOF, Self::InappropriateFallback => ffi::G_TLS_ERROR_INAPPROPRIATE_FALLBACK, #[cfg(feature = "v2_72")] Self::BadCertificatePassword => ffi::G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsError { #[inline] unsafe fn from_glib(value: ffi::GTlsError) -> Self { match value { ffi::G_TLS_ERROR_UNAVAILABLE => Self::Unavailable, ffi::G_TLS_ERROR_MISC => Self::Misc, ffi::G_TLS_ERROR_BAD_CERTIFICATE => Self::BadCertificate, ffi::G_TLS_ERROR_NOT_TLS => Self::NotTls, ffi::G_TLS_ERROR_HANDSHAKE => Self::Handshake, ffi::G_TLS_ERROR_CERTIFICATE_REQUIRED => Self::CertificateRequired, ffi::G_TLS_ERROR_EOF => Self::Eof, ffi::G_TLS_ERROR_INAPPROPRIATE_FALLBACK => Self::InappropriateFallback, #[cfg(feature = "v2_72")] ffi::G_TLS_ERROR_BAD_CERTIFICATE_PASSWORD => Self::BadCertificatePassword, value => Self::__Unknown(value), } } } impl glib::error::ErrorDomain for TlsError { #[inline] fn domain() -> glib::Quark { unsafe { from_glib(ffi::g_tls_error_quark()) } } #[inline] fn code(self) -> i32 { self.into_glib() } #[inline] #[allow(clippy::match_single_binding)] fn from(code: i32) -> Option { match unsafe { from_glib(code) } { value => Some(value), } } } impl StaticType for TlsError { #[inline] #[doc(alias = "g_tls_error_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_error_get_type()) } } } impl glib::HasParamSpec for TlsError { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TlsError { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsError { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TlsError { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsError) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsInteractionResult")] pub enum TlsInteractionResult { #[doc(alias = "G_TLS_INTERACTION_UNHANDLED")] Unhandled, #[doc(alias = "G_TLS_INTERACTION_HANDLED")] Handled, #[doc(alias = "G_TLS_INTERACTION_FAILED")] Failed, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for TlsInteractionResult { type GlibType = ffi::GTlsInteractionResult; #[inline] fn into_glib(self) -> ffi::GTlsInteractionResult { match self { Self::Unhandled => ffi::G_TLS_INTERACTION_UNHANDLED, Self::Handled => ffi::G_TLS_INTERACTION_HANDLED, Self::Failed => ffi::G_TLS_INTERACTION_FAILED, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for TlsInteractionResult { #[inline] unsafe fn from_glib(value: ffi::GTlsInteractionResult) -> Self { match value { ffi::G_TLS_INTERACTION_UNHANDLED => Self::Unhandled, ffi::G_TLS_INTERACTION_HANDLED => Self::Handled, ffi::G_TLS_INTERACTION_FAILED => Self::Failed, value => Self::__Unknown(value), } } } impl StaticType for TlsInteractionResult { #[inline] #[doc(alias = "g_tls_interaction_result_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_interaction_result_get_type()) } } } impl glib::HasParamSpec for TlsInteractionResult { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for TlsInteractionResult { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsInteractionResult { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for TlsInteractionResult { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsInteractionResult) -> Self { ToValue::to_value(&v) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsProtocolVersion")] pub enum TlsProtocolVersion { #[doc(alias = "G_TLS_PROTOCOL_VERSION_UNKNOWN")] Unknown, #[doc(alias = "G_TLS_PROTOCOL_VERSION_SSL_3_0")] Ssl30, #[doc(alias = "G_TLS_PROTOCOL_VERSION_TLS_1_0")] Tls10, #[doc(alias = "G_TLS_PROTOCOL_VERSION_TLS_1_1")] Tls11, #[doc(alias = "G_TLS_PROTOCOL_VERSION_TLS_1_2")] Tls12, #[doc(alias = "G_TLS_PROTOCOL_VERSION_TLS_1_3")] Tls13, #[doc(alias = "G_TLS_PROTOCOL_VERSION_DTLS_1_0")] Dtls10, #[doc(alias = "G_TLS_PROTOCOL_VERSION_DTLS_1_2")] Dtls12, #[doc(hidden)] __Unknown(i32), } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(hidden)] impl IntoGlib for TlsProtocolVersion { type GlibType = ffi::GTlsProtocolVersion; #[inline] fn into_glib(self) -> ffi::GTlsProtocolVersion { match self { Self::Unknown => ffi::G_TLS_PROTOCOL_VERSION_UNKNOWN, Self::Ssl30 => ffi::G_TLS_PROTOCOL_VERSION_SSL_3_0, Self::Tls10 => ffi::G_TLS_PROTOCOL_VERSION_TLS_1_0, Self::Tls11 => ffi::G_TLS_PROTOCOL_VERSION_TLS_1_1, Self::Tls12 => ffi::G_TLS_PROTOCOL_VERSION_TLS_1_2, Self::Tls13 => ffi::G_TLS_PROTOCOL_VERSION_TLS_1_3, Self::Dtls10 => ffi::G_TLS_PROTOCOL_VERSION_DTLS_1_0, Self::Dtls12 => ffi::G_TLS_PROTOCOL_VERSION_DTLS_1_2, Self::__Unknown(value) => value, } } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(hidden)] impl FromGlib for TlsProtocolVersion { #[inline] unsafe fn from_glib(value: ffi::GTlsProtocolVersion) -> Self { match value { ffi::G_TLS_PROTOCOL_VERSION_UNKNOWN => Self::Unknown, ffi::G_TLS_PROTOCOL_VERSION_SSL_3_0 => Self::Ssl30, ffi::G_TLS_PROTOCOL_VERSION_TLS_1_0 => Self::Tls10, ffi::G_TLS_PROTOCOL_VERSION_TLS_1_1 => Self::Tls11, ffi::G_TLS_PROTOCOL_VERSION_TLS_1_2 => Self::Tls12, ffi::G_TLS_PROTOCOL_VERSION_TLS_1_3 => Self::Tls13, ffi::G_TLS_PROTOCOL_VERSION_DTLS_1_0 => Self::Dtls10, ffi::G_TLS_PROTOCOL_VERSION_DTLS_1_2 => Self::Dtls12, value => Self::__Unknown(value), } } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] impl StaticType for TlsProtocolVersion { #[inline] #[doc(alias = "g_tls_protocol_version_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_protocol_version_get_type()) } } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] impl glib::HasParamSpec for TlsProtocolVersion { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] impl glib::value::ValueType for TlsProtocolVersion { type Type = Self; } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] unsafe impl<'a> glib::value::FromValue<'a> for TlsProtocolVersion { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] impl ToValue for TlsProtocolVersion { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] impl From for glib::Value { #[inline] fn from(v: TlsProtocolVersion) -> Self { ToValue::to_value(&v) } } #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GTlsRehandshakeMode")] pub enum TlsRehandshakeMode { #[doc(alias = "G_TLS_REHANDSHAKE_NEVER")] Never, #[doc(alias = "G_TLS_REHANDSHAKE_SAFELY")] Safely, #[doc(alias = "G_TLS_REHANDSHAKE_UNSAFELY")] Unsafely, #[doc(hidden)] __Unknown(i32), } #[allow(deprecated)] #[doc(hidden)] impl IntoGlib for TlsRehandshakeMode { type GlibType = ffi::GTlsRehandshakeMode; #[inline] fn into_glib(self) -> ffi::GTlsRehandshakeMode { match self { Self::Never => ffi::G_TLS_REHANDSHAKE_NEVER, Self::Safely => ffi::G_TLS_REHANDSHAKE_SAFELY, Self::Unsafely => ffi::G_TLS_REHANDSHAKE_UNSAFELY, Self::__Unknown(value) => value, } } } #[allow(deprecated)] #[doc(hidden)] impl FromGlib for TlsRehandshakeMode { #[inline] unsafe fn from_glib(value: ffi::GTlsRehandshakeMode) -> Self { match value { ffi::G_TLS_REHANDSHAKE_NEVER => Self::Never, ffi::G_TLS_REHANDSHAKE_SAFELY => Self::Safely, ffi::G_TLS_REHANDSHAKE_UNSAFELY => Self::Unsafely, value => Self::__Unknown(value), } } } #[allow(deprecated)] impl StaticType for TlsRehandshakeMode { #[inline] #[doc(alias = "g_tls_rehandshake_mode_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_rehandshake_mode_get_type()) } } } #[allow(deprecated)] impl glib::HasParamSpec for TlsRehandshakeMode { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[allow(deprecated)] impl glib::value::ValueType for TlsRehandshakeMode { type Type = Self; } #[allow(deprecated)] unsafe impl<'a> glib::value::FromValue<'a> for TlsRehandshakeMode { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[allow(deprecated)] impl ToValue for TlsRehandshakeMode { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[allow(deprecated)] impl From for glib::Value { #[inline] fn from(v: TlsRehandshakeMode) -> Self { ToValue::to_value(&v) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GUnixSocketAddressType")] pub enum UnixSocketAddressType { #[doc(alias = "G_UNIX_SOCKET_ADDRESS_INVALID")] Invalid, #[doc(alias = "G_UNIX_SOCKET_ADDRESS_ANONYMOUS")] Anonymous, #[doc(alias = "G_UNIX_SOCKET_ADDRESS_PATH")] Path, #[doc(alias = "G_UNIX_SOCKET_ADDRESS_ABSTRACT")] Abstract, #[doc(alias = "G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED")] AbstractPadded, #[doc(hidden)] __Unknown(i32), } #[cfg(unix)] #[doc(hidden)] impl IntoGlib for UnixSocketAddressType { type GlibType = ffi::GUnixSocketAddressType; #[inline] fn into_glib(self) -> ffi::GUnixSocketAddressType { match self { Self::Invalid => ffi::G_UNIX_SOCKET_ADDRESS_INVALID, Self::Anonymous => ffi::G_UNIX_SOCKET_ADDRESS_ANONYMOUS, Self::Path => ffi::G_UNIX_SOCKET_ADDRESS_PATH, Self::Abstract => ffi::G_UNIX_SOCKET_ADDRESS_ABSTRACT, Self::AbstractPadded => ffi::G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED, Self::__Unknown(value) => value, } } } #[cfg(unix)] #[doc(hidden)] impl FromGlib for UnixSocketAddressType { #[inline] unsafe fn from_glib(value: ffi::GUnixSocketAddressType) -> Self { match value { ffi::G_UNIX_SOCKET_ADDRESS_INVALID => Self::Invalid, ffi::G_UNIX_SOCKET_ADDRESS_ANONYMOUS => Self::Anonymous, ffi::G_UNIX_SOCKET_ADDRESS_PATH => Self::Path, ffi::G_UNIX_SOCKET_ADDRESS_ABSTRACT => Self::Abstract, ffi::G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED => Self::AbstractPadded, value => Self::__Unknown(value), } } } #[cfg(unix)] impl StaticType for UnixSocketAddressType { #[inline] #[doc(alias = "g_unix_socket_address_type_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_unix_socket_address_type_get_type()) } } } #[cfg(unix)] impl glib::HasParamSpec for UnixSocketAddressType { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } #[cfg(unix)] impl glib::value::ValueType for UnixSocketAddressType { type Type = Self; } #[cfg(unix)] unsafe impl<'a> glib::value::FromValue<'a> for UnixSocketAddressType { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(unix)] impl ToValue for UnixSocketAddressType { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(unix)] impl From for glib::Value { #[inline] fn from(v: UnixSocketAddressType) -> Self { ToValue::to_value(&v) } } #[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)] #[non_exhaustive] #[doc(alias = "GZlibCompressorFormat")] pub enum ZlibCompressorFormat { #[doc(alias = "G_ZLIB_COMPRESSOR_FORMAT_ZLIB")] Zlib, #[doc(alias = "G_ZLIB_COMPRESSOR_FORMAT_GZIP")] Gzip, #[doc(alias = "G_ZLIB_COMPRESSOR_FORMAT_RAW")] Raw, #[doc(hidden)] __Unknown(i32), } #[doc(hidden)] impl IntoGlib for ZlibCompressorFormat { type GlibType = ffi::GZlibCompressorFormat; #[inline] fn into_glib(self) -> ffi::GZlibCompressorFormat { match self { Self::Zlib => ffi::G_ZLIB_COMPRESSOR_FORMAT_ZLIB, Self::Gzip => ffi::G_ZLIB_COMPRESSOR_FORMAT_GZIP, Self::Raw => ffi::G_ZLIB_COMPRESSOR_FORMAT_RAW, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for ZlibCompressorFormat { #[inline] unsafe fn from_glib(value: ffi::GZlibCompressorFormat) -> Self { match value { ffi::G_ZLIB_COMPRESSOR_FORMAT_ZLIB => Self::Zlib, ffi::G_ZLIB_COMPRESSOR_FORMAT_GZIP => Self::Gzip, ffi::G_ZLIB_COMPRESSOR_FORMAT_RAW => Self::Raw, value => Self::__Unknown(value), } } } impl StaticType for ZlibCompressorFormat { #[inline] #[doc(alias = "g_zlib_compressor_format_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_zlib_compressor_format_get_type()) } } } impl glib::HasParamSpec for ZlibCompressorFormat { type ParamSpec = glib::ParamSpecEnum; type SetValue = Self; type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder_with_default } } impl glib::value::ValueType for ZlibCompressorFormat { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ZlibCompressorFormat { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } impl ToValue for ZlibCompressorFormat { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ZlibCompressorFormat) -> Self { ToValue::to_value(&v) } } gio-0.20.1/src/auto/file.rs000064400000000000000000003120601046102023000135100ustar 00000000000000// 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::{ ffi, AppInfo, AsyncResult, Cancellable, DriveStartFlags, FileAttributeInfoList, FileCopyFlags, FileCreateFlags, FileEnumerator, FileIOStream, FileInfo, FileInputStream, FileMonitor, FileMonitorFlags, FileOutputStream, FileQueryInfoFlags, FileType, Mount, MountMountFlags, MountOperation, MountUnmountFlags, }; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GFile")] pub struct File(Interface); match fn { type_ => || ffi::g_file_get_type(), } } impl File { pub const NONE: Option<&'static File> = None; //#[doc(alias = "g_file_new_build_filename")] //pub fn new_build_filename(first_element: impl AsRef, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> File { // unsafe { TODO: call ffi:g_file_new_build_filename() } //} #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "g_file_new_build_filenamev")] pub fn new_build_filenamev(args: &[&std::path::Path]) -> File { unsafe { from_glib_full(ffi::g_file_new_build_filenamev(args.to_glib_none().0)) } } #[doc(alias = "g_file_new_for_commandline_arg")] #[doc(alias = "new_for_commandline_arg")] pub fn for_commandline_arg(arg: impl AsRef) -> File { unsafe { from_glib_full(ffi::g_file_new_for_commandline_arg( arg.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_new_for_commandline_arg_and_cwd")] #[doc(alias = "new_for_commandline_arg_and_cwd")] pub fn for_commandline_arg_and_cwd( arg: impl AsRef, cwd: impl AsRef, ) -> File { unsafe { from_glib_full(ffi::g_file_new_for_commandline_arg_and_cwd( arg.as_ref().to_glib_none().0, cwd.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_new_for_path")] #[doc(alias = "new_for_path")] pub fn for_path(path: impl AsRef) -> File { unsafe { from_glib_full(ffi::g_file_new_for_path(path.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_new_for_uri")] #[doc(alias = "new_for_uri")] pub fn for_uri(uri: &str) -> File { unsafe { from_glib_full(ffi::g_file_new_for_uri(uri.to_glib_none().0)) } } #[doc(alias = "g_file_new_tmp")] pub fn new_tmp( tmpl: Option>, ) -> Result<(File, FileIOStream), glib::Error> { unsafe { let mut iostream = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_file_new_tmp( tmpl.as_ref().map(|p| p.as_ref()).to_glib_none().0, &mut iostream, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(iostream))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_parse_name")] #[doc(alias = "parse_name")] pub fn for_parse_name(parse_name: &str) -> File { unsafe { from_glib_full(ffi::g_file_parse_name(parse_name.to_glib_none().0)) } } } unsafe impl Send for File {} unsafe impl Sync for File {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_append_to")] fn append_to( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_append_to( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_append_to_async")] fn append_to_async) + 'static>( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn append_to_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_append_to_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = append_to_async_trampoline::

; unsafe { ffi::g_file_append_to_async( self.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn append_to_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.append_to_async(flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "g_file_build_attribute_list_for_copy")] fn build_attribute_list_for_copy( &self, flags: FileCopyFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_build_attribute_list_for_copy( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_copy")] fn copy( &self, destination: &impl IsA, flags: FileCopyFlags, cancellable: Option<&impl IsA>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), glib::Error> { let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback; unsafe extern "C" fn progress_callback_func( current_num_bytes: i64, total_num_bytes: i64, data: glib::ffi::gpointer, ) { let callback = data as *mut Option<&mut dyn (FnMut(i64, i64))>; if let Some(ref mut callback) = *callback { callback(current_num_bytes, total_num_bytes) } else { panic!("cannot get closure...") } } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func as _) } else { None }; let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data; unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_copy( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, super_callback0 as *const _ as *mut _, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_copy_attributes")] fn copy_attributes( &self, destination: &impl IsA, flags: FileCopyFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_copy_attributes( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_create")] fn create( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_create( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_create_async")] fn create_async) + 'static>( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn create_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_create_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = create_async_trampoline::

; unsafe { ffi::g_file_create_async( self.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn create_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.create_async(flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_create_readwrite")] fn create_readwrite( &self, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_create_readwrite( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_create_readwrite_async")] fn create_readwrite_async) + 'static>( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn create_readwrite_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_create_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = create_readwrite_async_trampoline::

; unsafe { ffi::g_file_create_readwrite_async( self.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn create_readwrite_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.create_readwrite_async(flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_delete")] fn delete(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_delete( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_delete_async")] fn delete_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn delete_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_delete_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = delete_async_trampoline::

; unsafe { ffi::g_file_delete_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn delete_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.delete_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_dup")] #[must_use] fn dup(&self) -> File { unsafe { from_glib_full(ffi::g_file_dup(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_eject_mountable_with_operation")] fn eject_mountable_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn eject_mountable_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_eject_mountable_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = eject_mountable_with_operation_trampoline::

; unsafe { ffi::g_file_eject_mountable_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn eject_mountable_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.eject_mountable_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_enumerate_children")] fn enumerate_children( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_enumerate_children( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_equal")] fn equal(&self, file2: &impl IsA) -> bool { unsafe { from_glib(ffi::g_file_equal( self.as_ref().to_glib_none().0, file2.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_find_enclosing_mount")] fn find_enclosing_mount( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_find_enclosing_mount( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_get_basename")] #[doc(alias = "get_basename")] fn basename(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_basename(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_get_child")] #[doc(alias = "get_child")] #[must_use] fn child(&self, name: impl AsRef) -> File { unsafe { from_glib_full(ffi::g_file_get_child( self.as_ref().to_glib_none().0, name.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_get_child_for_display_name")] #[doc(alias = "get_child_for_display_name")] fn child_for_display_name(&self, display_name: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_get_child_for_display_name( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_get_parent")] #[doc(alias = "get_parent")] #[must_use] fn parent(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_parent(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_get_parse_name")] #[doc(alias = "get_parse_name")] fn parse_name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_file_get_parse_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_get_path")] #[doc(alias = "get_path")] fn path(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_path(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_get_relative_path")] #[doc(alias = "get_relative_path")] fn relative_path(&self, descendant: &impl IsA) -> Option { unsafe { from_glib_full(ffi::g_file_get_relative_path( self.as_ref().to_glib_none().0, descendant.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_get_uri")] #[doc(alias = "get_uri")] fn uri(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_file_get_uri(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_get_uri_scheme")] #[doc(alias = "get_uri_scheme")] fn uri_scheme(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_uri_scheme(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_has_parent")] fn has_parent(&self, parent: Option<&impl IsA>) -> bool { unsafe { from_glib(ffi::g_file_has_parent( self.as_ref().to_glib_none().0, parent.map(|p| p.as_ref()).to_glib_none().0, )) } } #[doc(alias = "g_file_has_prefix")] fn has_prefix(&self, prefix: &impl IsA) -> bool { unsafe { from_glib(ffi::g_file_has_prefix( self.as_ref().to_glib_none().0, prefix.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_has_uri_scheme")] fn has_uri_scheme(&self, uri_scheme: &str) -> bool { unsafe { from_glib(ffi::g_file_has_uri_scheme( self.as_ref().to_glib_none().0, uri_scheme.to_glib_none().0, )) } } #[doc(alias = "g_file_is_native")] fn is_native(&self) -> bool { unsafe { from_glib(ffi::g_file_is_native(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_load_bytes")] fn load_bytes( &self, cancellable: Option<&impl IsA>, ) -> Result<(glib::Bytes, Option), glib::Error> { unsafe { let mut etag_out = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_file_load_bytes( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut etag_out, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(etag_out))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_load_bytes_async")] fn load_bytes_async< P: FnOnce(Result<(glib::Bytes, Option), glib::Error>) + 'static, >( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn load_bytes_async_trampoline< P: FnOnce(Result<(glib::Bytes, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut etag_out = std::ptr::null_mut(); let ret = ffi::g_file_load_bytes_finish( _source_object as *mut _, res, &mut etag_out, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(etag_out))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = load_bytes_async_trampoline::

; unsafe { ffi::g_file_load_bytes_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn load_bytes_future( &self, ) -> Pin< Box_< dyn std::future::Future< Output = Result<(glib::Bytes, Option), glib::Error>, > + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.load_bytes_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_make_directory")] fn make_directory( &self, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_make_directory( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_make_directory_async")] fn make_directory_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn make_directory_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_make_directory_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = make_directory_async_trampoline::

; unsafe { ffi::g_file_make_directory_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn make_directory_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.make_directory_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_make_directory_with_parents")] fn make_directory_with_parents( &self, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_make_directory_with_parents( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_make_symbolic_link")] fn make_symbolic_link( &self, symlink_value: impl AsRef, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_make_symbolic_link( self.as_ref().to_glib_none().0, symlink_value.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_monitor")] fn monitor( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_monitor( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_monitor_directory")] fn monitor_directory( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_monitor_directory( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_monitor_file")] fn monitor_file( &self, flags: FileMonitorFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_monitor_file( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_mount_enclosing_volume")] fn mount_enclosing_volume) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn mount_enclosing_volume_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_mount_enclosing_volume_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = mount_enclosing_volume_trampoline::

; unsafe { ffi::g_file_mount_enclosing_volume( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn mount_enclosing_volume_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.mount_enclosing_volume( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_mount_mountable")] fn mount_mountable) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn mount_mountable_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_mount_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = mount_mountable_trampoline::

; unsafe { ffi::g_file_mount_mountable( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn mount_mountable_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.mount_mountable( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_move")] #[doc(alias = "move")] fn move_( &self, destination: &impl IsA, flags: FileCopyFlags, cancellable: Option<&impl IsA>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), glib::Error> { let progress_callback_data: Option<&mut dyn (FnMut(i64, i64))> = progress_callback; unsafe extern "C" fn progress_callback_func( current_num_bytes: i64, total_num_bytes: i64, data: glib::ffi::gpointer, ) { let callback = data as *mut Option<&mut dyn (FnMut(i64, i64))>; if let Some(ref mut callback) = *callback { callback(current_num_bytes, total_num_bytes) } else { panic!("cannot get closure...") } } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func as _) } else { None }; let super_callback0: &Option<&mut dyn (FnMut(i64, i64))> = &progress_callback_data; unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_move( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, super_callback0 as *const _ as *mut _, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_open_readwrite")] fn open_readwrite( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_open_readwrite( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_open_readwrite_async")] fn open_readwrite_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn open_readwrite_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_open_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = open_readwrite_async_trampoline::

; unsafe { ffi::g_file_open_readwrite_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn open_readwrite_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.open_readwrite_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_peek_path")] fn peek_path(&self) -> Option { unsafe { from_glib_none(ffi::g_file_peek_path(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_poll_mountable")] fn poll_mountable) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn poll_mountable_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_poll_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = poll_mountable_trampoline::

; unsafe { ffi::g_file_poll_mountable( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn poll_mountable_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.poll_mountable(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_query_default_handler")] fn query_default_handler( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_default_handler( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_file_query_default_handler_async")] fn query_default_handler_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_default_handler_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_default_handler_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_default_handler_async_trampoline::

; unsafe { ffi::g_file_query_default_handler_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn query_default_handler_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_default_handler_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_query_exists")] fn query_exists(&self, cancellable: Option<&impl IsA>) -> bool { unsafe { from_glib(ffi::g_file_query_exists( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, )) } } #[doc(alias = "g_file_query_file_type")] fn query_file_type( &self, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> FileType { unsafe { from_glib(ffi::g_file_query_file_type( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, )) } } #[doc(alias = "g_file_query_filesystem_info")] fn query_filesystem_info( &self, attributes: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_filesystem_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.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_file_query_filesystem_info_async")] fn query_filesystem_info_async) + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_filesystem_info_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_filesystem_info_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_filesystem_info_async_trampoline::

; unsafe { ffi::g_file_query_filesystem_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn query_filesystem_info_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = String::from(attributes); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_filesystem_info_async( &attributes, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_query_info")] fn query_info( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_file_query_info_async")] fn query_info_async) + 'static>( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_info_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_info_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_info_async_trampoline::

; unsafe { ffi::g_file_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn query_info_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = String::from(attributes); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_info_async( &attributes, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_query_settable_attributes")] fn query_settable_attributes( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_settable_attributes( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_query_writable_namespaces")] fn query_writable_namespaces( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_query_writable_namespaces( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_read")] fn read( &self, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_read( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_read_async")] fn read_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_read_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = read_async_trampoline::

; unsafe { ffi::g_file_read_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn read_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_replace")] fn replace( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_replace( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.into_glib(), flags.into_glib(), cancellable.map(|p| p.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_file_replace_async")] fn replace_async) + 'static>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn replace_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_replace_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = replace_async_trampoline::

; unsafe { ffi::g_file_replace_async( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.into_glib(), flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn replace_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let etag = etag.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.replace_async( etag.as_ref().map(::std::borrow::Borrow::borrow), make_backup, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_replace_contents")] fn replace_contents( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { let length = contents.len() as _; unsafe { let mut new_etag = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_replace_contents( self.as_ref().to_glib_none().0, contents.to_glib_none().0, length, etag.to_glib_none().0, make_backup.into_glib(), flags.into_glib(), &mut new_etag, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(from_glib_full(new_etag)) } else { Err(from_glib_full(error)) } } } //#[doc(alias = "g_file_replace_contents_bytes_async")] //fn replace_contents_bytes_async) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA>, callback: P) { // unsafe { TODO: call ffi:g_file_replace_contents_bytes_async() } //} #[doc(alias = "g_file_replace_readwrite")] fn replace_readwrite( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_replace_readwrite( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.into_glib(), flags.into_glib(), cancellable.map(|p| p.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_file_replace_readwrite_async")] fn replace_readwrite_async) + 'static>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn replace_readwrite_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_replace_readwrite_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = replace_readwrite_async_trampoline::

; unsafe { ffi::g_file_replace_readwrite_async( self.as_ref().to_glib_none().0, etag.to_glib_none().0, make_backup.into_glib(), flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn replace_readwrite_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let etag = etag.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.replace_readwrite_async( etag.as_ref().map(::std::borrow::Borrow::borrow), make_backup, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_resolve_relative_path")] #[must_use] fn resolve_relative_path(&self, relative_path: impl AsRef) -> File { unsafe { from_glib_full(ffi::g_file_resolve_relative_path( self.as_ref().to_glib_none().0, relative_path.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_file_set_attribute")] //fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:g_file_set_attribute() } //} #[doc(alias = "g_file_set_attribute_byte_string")] fn set_attribute_byte_string( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_byte_string( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attribute_int32")] fn set_attribute_int32( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_int32( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attribute_int64")] fn set_attribute_int64( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_int64( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attribute_string")] fn set_attribute_string( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_string( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attribute_uint32")] fn set_attribute_uint32( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_uint32( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attribute_uint64")] fn set_attribute_uint64( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attribute_uint64( self.as_ref().to_glib_none().0, attribute.to_glib_none().0, value, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_attributes_async")] fn set_attributes_async) + 'static>( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn set_attributes_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut info = std::ptr::null_mut(); let _ = ffi::g_file_set_attributes_finish( _source_object as *mut _, res, &mut info, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(info)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = set_attributes_async_trampoline::

; unsafe { ffi::g_file_set_attributes_async( self.as_ref().to_glib_none().0, info.to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn set_attributes_future( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let info = info.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.set_attributes_async( &info, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_set_attributes_from_info")] fn set_attributes_from_info( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_set_attributes_from_info( self.as_ref().to_glib_none().0, info.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_set_display_name")] fn set_display_name( &self, display_name: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_set_display_name( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, cancellable.map(|p| p.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_file_set_display_name_async")] fn set_display_name_async) + 'static>( &self, display_name: &str, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn set_display_name_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_set_display_name_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = set_display_name_async_trampoline::

; unsafe { ffi::g_file_set_display_name_async( self.as_ref().to_glib_none().0, display_name.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn set_display_name_future( &self, display_name: &str, io_priority: glib::Priority, ) -> Pin> + 'static>> { let display_name = String::from(display_name); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.set_display_name_async( &display_name, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_start_mountable")] fn start_mountable) + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn start_mountable_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_start_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = start_mountable_trampoline::

; unsafe { ffi::g_file_start_mountable( self.as_ref().to_glib_none().0, flags.into_glib(), start_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn start_mountable_future( &self, flags: DriveStartFlags, start_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let start_operation = start_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.start_mountable( flags, start_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_stop_mountable")] fn stop_mountable) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn stop_mountable_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_stop_mountable_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = stop_mountable_trampoline::

; unsafe { ffi::g_file_stop_mountable( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn stop_mountable_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.stop_mountable( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_supports_thread_contexts")] fn supports_thread_contexts(&self) -> bool { unsafe { from_glib(ffi::g_file_supports_thread_contexts( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_trash")] fn trash(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_trash( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_trash_async")] fn trash_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn trash_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_trash_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = trash_async_trampoline::

; unsafe { ffi::g_file_trash_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn trash_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.trash_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_unmount_mountable_with_operation")] fn unmount_mountable_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn unmount_mountable_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_unmount_mountable_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = unmount_mountable_with_operation_trampoline::

; unsafe { ffi::g_file_unmount_mountable_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn unmount_mountable_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.unmount_mountable_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } } impl> FileExt for O {} gio-0.20.1/src/auto/file_attribute_info_list.rs000064400000000000000000000027451046102023000176470ustar 00000000000000// 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::{ffi, FileAttributeInfoFlags, FileAttributeType}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FileAttributeInfoList(Shared); match fn { ref => |ptr| ffi::g_file_attribute_info_list_ref(ptr), unref => |ptr| ffi::g_file_attribute_info_list_unref(ptr), type_ => || ffi::g_file_attribute_info_list_get_type(), } } impl FileAttributeInfoList { #[doc(alias = "g_file_attribute_info_list_new")] pub fn new() -> FileAttributeInfoList { unsafe { from_glib_full(ffi::g_file_attribute_info_list_new()) } } #[doc(alias = "g_file_attribute_info_list_add")] pub fn add(&self, name: &str, type_: FileAttributeType, flags: FileAttributeInfoFlags) { unsafe { ffi::g_file_attribute_info_list_add( self.to_glib_none().0, name.to_glib_none().0, type_.into_glib(), flags.into_glib(), ); } } #[doc(alias = "g_file_attribute_info_list_dup")] #[must_use] pub fn dup(&self) -> FileAttributeInfoList { unsafe { from_glib_full(ffi::g_file_attribute_info_list_dup(self.to_glib_none().0)) } } } impl Default for FileAttributeInfoList { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/file_attribute_matcher.rs000064400000000000000000000051161046102023000172770ustar 00000000000000// 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::ffi; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct FileAttributeMatcher(Shared); match fn { ref => |ptr| ffi::g_file_attribute_matcher_ref(ptr), unref => |ptr| ffi::g_file_attribute_matcher_unref(ptr), type_ => || ffi::g_file_attribute_matcher_get_type(), } } impl FileAttributeMatcher { #[doc(alias = "g_file_attribute_matcher_new")] pub fn new(attributes: &str) -> FileAttributeMatcher { unsafe { from_glib_full(ffi::g_file_attribute_matcher_new( attributes.to_glib_none().0, )) } } #[doc(alias = "g_file_attribute_matcher_enumerate_namespace")] pub fn enumerate_namespace(&self, ns: &str) -> bool { unsafe { from_glib(ffi::g_file_attribute_matcher_enumerate_namespace( self.to_glib_none().0, ns.to_glib_none().0, )) } } #[doc(alias = "g_file_attribute_matcher_matches")] pub fn matches(&self, attribute: &str) -> bool { unsafe { from_glib(ffi::g_file_attribute_matcher_matches( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_attribute_matcher_matches_only")] pub fn matches_only(&self, attribute: &str) -> bool { unsafe { from_glib(ffi::g_file_attribute_matcher_matches_only( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_attribute_matcher_subtract")] #[must_use] pub fn subtract( &self, subtract: Option<&FileAttributeMatcher>, ) -> Option { unsafe { from_glib_full(ffi::g_file_attribute_matcher_subtract( self.to_glib_none().0, subtract.to_glib_none().0, )) } } #[doc(alias = "g_file_attribute_matcher_to_string")] #[doc(alias = "to_string")] pub fn to_str(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_file_attribute_matcher_to_string( self.to_glib_none().0, )) } } } impl std::fmt::Display for FileAttributeMatcher { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(&self.to_str()) } } gio-0.20.1/src/auto/file_enumerator.rs000064400000000000000000000206051046102023000157520ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, File, FileInfo}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GFileEnumerator")] pub struct FileEnumerator(Object); match fn { type_ => || ffi::g_file_enumerator_get_type(), } } impl FileEnumerator { pub const NONE: Option<&'static FileEnumerator> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileEnumeratorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_enumerator_close")] fn close(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_enumerator_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_enumerator_close_async")] fn close_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn close_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_file_enumerator_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = close_async_trampoline::

; unsafe { ffi::g_file_enumerator_close_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn close_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.close_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_enumerator_get_child")] #[doc(alias = "get_child")] fn child(&self, info: &FileInfo) -> File { unsafe { from_glib_full(ffi::g_file_enumerator_get_child( self.as_ref().to_glib_none().0, info.to_glib_none().0, )) } } #[doc(alias = "g_file_enumerator_get_container")] #[doc(alias = "get_container")] fn container(&self) -> File { unsafe { from_glib_none(ffi::g_file_enumerator_get_container( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_enumerator_has_pending")] fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_file_enumerator_has_pending( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_enumerator_is_closed")] fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_file_enumerator_is_closed( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_enumerator_next_file")] fn next_file( &self, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_enumerator_next_file( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_file_enumerator_next_files_async")] fn next_files_async, glib::Error>) + 'static>( &self, num_files: i32, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn next_files_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_enumerator_next_files_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = next_files_async_trampoline::

; unsafe { ffi::g_file_enumerator_next_files_async( self.as_ref().to_glib_none().0, num_files, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn next_files_future( &self, num_files: i32, io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.next_files_async(num_files, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_enumerator_set_pending")] fn set_pending(&self, pending: bool) { unsafe { ffi::g_file_enumerator_set_pending(self.as_ref().to_glib_none().0, pending.into_glib()); } } } impl> FileEnumeratorExt for O {} gio-0.20.1/src/auto/file_icon.rs000064400000000000000000000015151046102023000145200ustar 00000000000000// 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::{ffi, File, Icon, LoadableIcon}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GFileIcon")] pub struct FileIcon(Object) @implements Icon, LoadableIcon; match fn { type_ => || ffi::g_file_icon_get_type(), } } impl FileIcon { #[doc(alias = "g_file_icon_new")] pub fn new(file: &impl IsA) -> FileIcon { unsafe { from_glib_full(ffi::g_file_icon_new(file.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_icon_get_file")] #[doc(alias = "get_file")] pub fn file(&self) -> File { unsafe { from_glib_none(ffi::g_file_icon_get_file(self.to_glib_none().0)) } } } gio-0.20.1/src/auto/file_info.rs000064400000000000000000000470511046102023000145300ustar 00000000000000// 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(deprecated)] use crate::{ffi, FileAttributeMatcher, FileAttributeStatus, FileAttributeType, FileType, Icon}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GFileInfo")] pub struct FileInfo(Object); match fn { type_ => || ffi::g_file_info_get_type(), } } impl FileInfo { #[doc(alias = "g_file_info_new")] pub fn new() -> FileInfo { unsafe { from_glib_full(ffi::g_file_info_new()) } } #[doc(alias = "g_file_info_clear_status")] pub fn clear_status(&self) { unsafe { ffi::g_file_info_clear_status(self.to_glib_none().0); } } #[doc(alias = "g_file_info_copy_into")] pub fn copy_into(&self, dest_info: &FileInfo) { unsafe { ffi::g_file_info_copy_into(self.to_glib_none().0, dest_info.to_glib_none().0); } } #[doc(alias = "g_file_info_dup")] #[must_use] pub fn dup(&self) -> FileInfo { unsafe { from_glib_full(ffi::g_file_info_dup(self.to_glib_none().0)) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_file_info_get_access_date_time")] #[doc(alias = "get_access_date_time")] pub fn access_date_time(&self) -> Option { unsafe { from_glib_full(ffi::g_file_info_get_access_date_time(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_attribute_as_string")] #[doc(alias = "get_attribute_as_string")] pub fn attribute_as_string(&self, attribute: &str) -> Option { unsafe { from_glib_full(ffi::g_file_info_get_attribute_as_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_boolean")] #[doc(alias = "get_attribute_boolean")] pub fn boolean(&self, attribute: &str) -> bool { unsafe { from_glib(ffi::g_file_info_get_attribute_boolean( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_byte_string")] #[doc(alias = "get_attribute_byte_string")] pub fn attribute_byte_string(&self, attribute: &str) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_attribute_byte_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } //#[doc(alias = "g_file_info_get_attribute_data")] //#[doc(alias = "get_attribute_data")] //pub fn attribute_data(&self, attribute: &str, value_pp: /*Unimplemented*/&mut Basic: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> { // unsafe { TODO: call ffi:g_file_info_get_attribute_data() } //} #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "g_file_info_get_attribute_file_path")] #[doc(alias = "get_attribute_file_path")] pub fn attribute_file_path(&self, attribute: &str) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_attribute_file_path( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_int32")] #[doc(alias = "get_attribute_int32")] pub fn attribute_int32(&self, attribute: &str) -> i32 { unsafe { ffi::g_file_info_get_attribute_int32(self.to_glib_none().0, attribute.to_glib_none().0) } } #[doc(alias = "g_file_info_get_attribute_int64")] #[doc(alias = "get_attribute_int64")] pub fn attribute_int64(&self, attribute: &str) -> i64 { unsafe { ffi::g_file_info_get_attribute_int64(self.to_glib_none().0, attribute.to_glib_none().0) } } #[doc(alias = "g_file_info_get_attribute_object")] #[doc(alias = "get_attribute_object")] pub fn attribute_object(&self, attribute: &str) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_attribute_object( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_status")] #[doc(alias = "get_attribute_status")] pub fn attribute_status(&self, attribute: &str) -> FileAttributeStatus { unsafe { from_glib(ffi::g_file_info_get_attribute_status( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_string")] #[doc(alias = "get_attribute_string")] pub fn attribute_string(&self, attribute: &str) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_attribute_string( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_type")] #[doc(alias = "get_attribute_type")] pub fn attribute_type(&self, attribute: &str) -> FileAttributeType { unsafe { from_glib(ffi::g_file_info_get_attribute_type( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_attribute_uint32")] #[doc(alias = "get_attribute_uint32")] pub fn attribute_uint32(&self, attribute: &str) -> u32 { unsafe { ffi::g_file_info_get_attribute_uint32(self.to_glib_none().0, attribute.to_glib_none().0) } } #[doc(alias = "g_file_info_get_attribute_uint64")] #[doc(alias = "get_attribute_uint64")] pub fn attribute_uint64(&self, attribute: &str) -> u64 { unsafe { ffi::g_file_info_get_attribute_uint64(self.to_glib_none().0, attribute.to_glib_none().0) } } #[doc(alias = "g_file_info_get_content_type")] #[doc(alias = "get_content_type")] pub fn content_type(&self) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_content_type(self.to_glib_none().0)) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_file_info_get_creation_date_time")] #[doc(alias = "get_creation_date_time")] pub fn creation_date_time(&self) -> Option { unsafe { from_glib_full(ffi::g_file_info_get_creation_date_time( self.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_deletion_date")] #[doc(alias = "get_deletion_date")] pub fn deletion_date(&self) -> Option { unsafe { from_glib_full(ffi::g_file_info_get_deletion_date(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_display_name")] #[doc(alias = "get_display_name")] pub fn display_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_file_info_get_display_name(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_edit_name")] #[doc(alias = "get_edit_name")] pub fn edit_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_file_info_get_edit_name(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_etag")] #[doc(alias = "get_etag")] pub fn etag(&self) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_etag(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_file_type")] #[doc(alias = "get_file_type")] pub fn file_type(&self) -> FileType { unsafe { from_glib(ffi::g_file_info_get_file_type(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_icon")] #[doc(alias = "get_icon")] pub fn icon(&self) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_icon(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_is_backup")] #[doc(alias = "get_is_backup")] pub fn is_backup(&self) -> bool { unsafe { from_glib(ffi::g_file_info_get_is_backup(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_is_hidden")] #[doc(alias = "get_is_hidden")] pub fn is_hidden(&self) -> bool { unsafe { from_glib(ffi::g_file_info_get_is_hidden(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_is_symlink")] #[doc(alias = "get_is_symlink")] pub fn is_symlink(&self) -> bool { unsafe { from_glib(ffi::g_file_info_get_is_symlink(self.to_glib_none().0)) } } #[cfg(feature = "v2_62")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))] #[doc(alias = "g_file_info_get_modification_date_time")] #[doc(alias = "get_modification_date_time")] pub fn modification_date_time(&self) -> Option { unsafe { from_glib_full(ffi::g_file_info_get_modification_date_time( self.to_glib_none().0, )) } } #[doc(alias = "g_file_info_get_name")] #[doc(alias = "get_name")] pub fn name(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_file_info_get_name(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_size")] #[doc(alias = "get_size")] pub fn size(&self) -> i64 { unsafe { ffi::g_file_info_get_size(self.to_glib_none().0) } } #[doc(alias = "g_file_info_get_sort_order")] #[doc(alias = "get_sort_order")] pub fn sort_order(&self) -> i32 { unsafe { ffi::g_file_info_get_sort_order(self.to_glib_none().0) } } #[doc(alias = "g_file_info_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] pub fn symbolic_icon(&self) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_symbolic_icon(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_get_symlink_target")] #[doc(alias = "get_symlink_target")] pub fn symlink_target(&self) -> Option { unsafe { from_glib_none(ffi::g_file_info_get_symlink_target(self.to_glib_none().0)) } } #[doc(alias = "g_file_info_has_attribute")] pub fn has_attribute(&self, attribute: &str) -> bool { unsafe { from_glib(ffi::g_file_info_has_attribute( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_has_namespace")] pub fn has_namespace(&self, name_space: &str) -> bool { unsafe { from_glib(ffi::g_file_info_has_namespace( self.to_glib_none().0, name_space.to_glib_none().0, )) } } #[doc(alias = "g_file_info_list_attributes")] pub fn list_attributes(&self, name_space: Option<&str>) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_file_info_list_attributes( self.to_glib_none().0, name_space.to_glib_none().0, )) } } #[doc(alias = "g_file_info_remove_attribute")] pub fn remove_attribute(&self, attribute: &str) { unsafe { ffi::g_file_info_remove_attribute(self.to_glib_none().0, attribute.to_glib_none().0); } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_file_info_set_access_date_time")] pub fn set_access_date_time(&self, atime: &glib::DateTime) { unsafe { ffi::g_file_info_set_access_date_time(self.to_glib_none().0, atime.to_glib_none().0); } } //#[doc(alias = "g_file_info_set_attribute")] //pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Basic: Pointer) { // unsafe { TODO: call ffi:g_file_info_set_attribute() } //} #[doc(alias = "g_file_info_set_attribute_boolean")] pub fn set_attribute_boolean(&self, attribute: &str, attr_value: bool) { unsafe { ffi::g_file_info_set_attribute_boolean( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.into_glib(), ); } } #[doc(alias = "g_file_info_set_attribute_byte_string")] pub fn set_attribute_byte_string(&self, attribute: &str, attr_value: &str) { unsafe { ffi::g_file_info_set_attribute_byte_string( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib_none().0, ); } } #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "g_file_info_set_attribute_file_path")] pub fn set_attribute_file_path( &self, attribute: &str, attr_value: impl AsRef, ) { unsafe { ffi::g_file_info_set_attribute_file_path( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_attribute_int32")] pub fn set_attribute_int32(&self, attribute: &str, attr_value: i32) { unsafe { ffi::g_file_info_set_attribute_int32( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } #[doc(alias = "g_file_info_set_attribute_int64")] pub fn set_attribute_int64(&self, attribute: &str, attr_value: i64) { unsafe { ffi::g_file_info_set_attribute_int64( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } #[doc(alias = "g_file_info_set_attribute_mask")] pub fn set_attribute_mask(&self, mask: &FileAttributeMatcher) { unsafe { ffi::g_file_info_set_attribute_mask(self.to_glib_none().0, mask.to_glib_none().0); } } #[doc(alias = "g_file_info_set_attribute_object")] pub fn set_attribute_object(&self, attribute: &str, attr_value: &impl IsA) { unsafe { ffi::g_file_info_set_attribute_object( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_attribute_status")] pub fn set_attribute_status(&self, attribute: &str, status: FileAttributeStatus) -> bool { unsafe { from_glib(ffi::g_file_info_set_attribute_status( self.to_glib_none().0, attribute.to_glib_none().0, status.into_glib(), )) } } #[doc(alias = "g_file_info_set_attribute_string")] pub fn set_attribute_string(&self, attribute: &str, attr_value: &str) { unsafe { ffi::g_file_info_set_attribute_string( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_attribute_uint32")] pub fn set_attribute_uint32(&self, attribute: &str, attr_value: u32) { unsafe { ffi::g_file_info_set_attribute_uint32( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } #[doc(alias = "g_file_info_set_attribute_uint64")] pub fn set_attribute_uint64(&self, attribute: &str, attr_value: u64) { unsafe { ffi::g_file_info_set_attribute_uint64( self.to_glib_none().0, attribute.to_glib_none().0, attr_value, ); } } #[doc(alias = "g_file_info_set_content_type")] pub fn set_content_type(&self, content_type: &str) { unsafe { ffi::g_file_info_set_content_type(self.to_glib_none().0, content_type.to_glib_none().0); } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_file_info_set_creation_date_time")] pub fn set_creation_date_time(&self, creation_time: &glib::DateTime) { unsafe { ffi::g_file_info_set_creation_date_time( self.to_glib_none().0, creation_time.to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_display_name")] pub fn set_display_name(&self, display_name: &str) { unsafe { ffi::g_file_info_set_display_name(self.to_glib_none().0, display_name.to_glib_none().0); } } #[doc(alias = "g_file_info_set_edit_name")] pub fn set_edit_name(&self, edit_name: &str) { unsafe { ffi::g_file_info_set_edit_name(self.to_glib_none().0, edit_name.to_glib_none().0); } } #[doc(alias = "g_file_info_set_file_type")] pub fn set_file_type(&self, type_: FileType) { unsafe { ffi::g_file_info_set_file_type(self.to_glib_none().0, type_.into_glib()); } } #[doc(alias = "g_file_info_set_icon")] pub fn set_icon(&self, icon: &impl IsA) { unsafe { ffi::g_file_info_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } #[doc(alias = "g_file_info_set_is_hidden")] pub fn set_is_hidden(&self, is_hidden: bool) { unsafe { ffi::g_file_info_set_is_hidden(self.to_glib_none().0, is_hidden.into_glib()); } } #[doc(alias = "g_file_info_set_is_symlink")] pub fn set_is_symlink(&self, is_symlink: bool) { unsafe { ffi::g_file_info_set_is_symlink(self.to_glib_none().0, is_symlink.into_glib()); } } #[cfg(feature = "v2_62")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_62")))] #[doc(alias = "g_file_info_set_modification_date_time")] pub fn set_modification_date_time(&self, mtime: &glib::DateTime) { unsafe { ffi::g_file_info_set_modification_date_time( self.to_glib_none().0, mtime.to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_name")] pub fn set_name(&self, name: impl AsRef) { unsafe { ffi::g_file_info_set_name(self.to_glib_none().0, name.as_ref().to_glib_none().0); } } #[doc(alias = "g_file_info_set_size")] pub fn set_size(&self, size: i64) { unsafe { ffi::g_file_info_set_size(self.to_glib_none().0, size); } } #[doc(alias = "g_file_info_set_sort_order")] pub fn set_sort_order(&self, sort_order: i32) { unsafe { ffi::g_file_info_set_sort_order(self.to_glib_none().0, sort_order); } } #[doc(alias = "g_file_info_set_symbolic_icon")] pub fn set_symbolic_icon(&self, icon: &impl IsA) { unsafe { ffi::g_file_info_set_symbolic_icon( self.to_glib_none().0, icon.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_file_info_set_symlink_target")] pub fn set_symlink_target(&self, symlink_target: impl AsRef) { unsafe { ffi::g_file_info_set_symlink_target( self.to_glib_none().0, symlink_target.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_file_info_unset_attribute_mask")] pub fn unset_attribute_mask(&self) { unsafe { ffi::g_file_info_unset_attribute_mask(self.to_glib_none().0); } } } impl Default for FileInfo { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/file_input_stream.rs000064400000000000000000000104301046102023000162760ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, FileInfo, InputStream, Seekable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GFileInputStream")] pub struct FileInputStream(Object) @extends InputStream, @implements Seekable; match fn { type_ => || ffi::g_file_input_stream_get_type(), } } impl FileInputStream { pub const NONE: Option<&'static FileInputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_input_stream_query_info")] fn query_info( &self, attributes: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_input_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.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_file_input_stream_query_info_async")] fn query_info_async) + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_info_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_input_stream_query_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_info_async_trampoline::

; unsafe { ffi::g_file_input_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn query_info_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = String::from(attributes); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_info_async(&attributes, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> FileInputStreamExt for O {} gio-0.20.1/src/auto/file_io_stream.rs000064400000000000000000000107111046102023000155500ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, FileInfo, IOStream, Seekable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GFileIOStream")] pub struct FileIOStream(Object) @extends IOStream, @implements Seekable; match fn { type_ => || ffi::g_file_io_stream_get_type(), } } impl FileIOStream { pub const NONE: Option<&'static FileIOStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileIOStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_io_stream_get_etag")] #[doc(alias = "get_etag")] fn etag(&self) -> Option { unsafe { from_glib_full(ffi::g_file_io_stream_get_etag( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_io_stream_query_info")] fn query_info( &self, attributes: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_io_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.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_file_io_stream_query_info_async")] fn query_info_async) + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_info_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_io_stream_query_info_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_info_async_trampoline::

; unsafe { ffi::g_file_io_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn query_info_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = String::from(attributes); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_info_async(&attributes, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> FileIOStreamExt for O {} gio-0.20.1/src/auto/file_monitor.rs000064400000000000000000000123221046102023000152550ustar 00000000000000// 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::{ffi, File, FileMonitorEvent}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GFileMonitor")] pub struct FileMonitor(Object); match fn { type_ => || ffi::g_file_monitor_get_type(), } } impl FileMonitor { pub const NONE: Option<&'static FileMonitor> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileMonitorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_monitor_cancel")] fn cancel(&self) -> bool { unsafe { from_glib(ffi::g_file_monitor_cancel(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_file_monitor_emit_event")] fn emit_event( &self, child: &impl IsA, other_file: &impl IsA, event_type: FileMonitorEvent, ) { unsafe { ffi::g_file_monitor_emit_event( self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, other_file.as_ref().to_glib_none().0, event_type.into_glib(), ); } } #[doc(alias = "g_file_monitor_is_cancelled")] #[doc(alias = "cancelled")] fn is_cancelled(&self) -> bool { unsafe { from_glib(ffi::g_file_monitor_is_cancelled( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_monitor_set_rate_limit")] #[doc(alias = "rate-limit")] fn set_rate_limit(&self, limit_msecs: i32) { unsafe { ffi::g_file_monitor_set_rate_limit(self.as_ref().to_glib_none().0, limit_msecs); } } #[doc(alias = "rate-limit")] fn rate_limit(&self) -> i32 { ObjectExt::property(self.as_ref(), "rate-limit") } #[doc(alias = "changed")] fn connect_changed, FileMonitorEvent) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline< P: IsA, F: Fn(&P, &File, Option<&File>, FileMonitorEvent) + 'static, >( this: *mut ffi::GFileMonitor, file: *mut ffi::GFile, other_file: *mut ffi::GFile, event_type: ffi::GFileMonitorEvent, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( FileMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(file), Option::::from_glib_borrow(other_file) .as_ref() .as_ref(), from_glib(event_type), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "cancelled")] fn connect_cancelled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_cancelled_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GFileMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(FileMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::cancelled\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_cancelled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "rate-limit")] fn connect_rate_limit_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_rate_limit_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GFileMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(FileMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::rate-limit\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_rate_limit_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> FileMonitorExt for O {} gio-0.20.1/src/auto/file_output_stream.rs000064400000000000000000000111141046102023000164770ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, FileInfo, OutputStream, Seekable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GFileOutputStream")] pub struct FileOutputStream(Object) @extends OutputStream, @implements Seekable; match fn { type_ => || ffi::g_file_output_stream_get_type(), } } impl FileOutputStream { pub const NONE: Option<&'static FileOutputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_file_output_stream_get_etag")] #[doc(alias = "get_etag")] fn etag(&self) -> Option { unsafe { from_glib_full(ffi::g_file_output_stream_get_etag( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_file_output_stream_query_info")] fn query_info( &self, attributes: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_output_stream_query_info( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, cancellable.map(|p| p.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_file_output_stream_query_info_async")] fn query_info_async) + 'static>( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn query_info_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_file_output_stream_query_info_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = query_info_async_trampoline::

; unsafe { ffi::g_file_output_stream_query_info_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn query_info_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = String::from(attributes); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.query_info_async(&attributes, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> FileOutputStreamExt for O {} gio-0.20.1/src/auto/filename_completer.rs000064400000000000000000000051761046102023000164320ustar 00000000000000// 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::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GFilenameCompleter")] pub struct FilenameCompleter(Object); match fn { type_ => || ffi::g_filename_completer_get_type(), } } impl FilenameCompleter { #[doc(alias = "g_filename_completer_new")] pub fn new() -> FilenameCompleter { unsafe { from_glib_full(ffi::g_filename_completer_new()) } } #[doc(alias = "g_filename_completer_get_completion_suffix")] #[doc(alias = "get_completion_suffix")] pub fn completion_suffix(&self, initial_text: &str) -> Option { unsafe { from_glib_full(ffi::g_filename_completer_get_completion_suffix( self.to_glib_none().0, initial_text.to_glib_none().0, )) } } #[doc(alias = "g_filename_completer_get_completions")] #[doc(alias = "get_completions")] pub fn completions(&self, initial_text: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_filename_completer_get_completions( self.to_glib_none().0, initial_text.to_glib_none().0, )) } } #[doc(alias = "g_filename_completer_set_dirs_only")] pub fn set_dirs_only(&self, dirs_only: bool) { unsafe { ffi::g_filename_completer_set_dirs_only(self.to_glib_none().0, dirs_only.into_glib()); } } #[doc(alias = "got-completion-data")] pub fn connect_got_completion_data(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn got_completion_data_trampoline( this: *mut ffi::GFilenameCompleter, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"got-completion-data\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( got_completion_data_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for FilenameCompleter { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/filter_input_stream.rs000064400000000000000000000056211046102023000166520ustar 00000000000000// 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::{ffi, InputStream}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GFilterInputStream")] pub struct FilterInputStream(Object) @extends InputStream; match fn { type_ => || ffi::g_filter_input_stream_get_type(), } } impl FilterInputStream { pub const NONE: Option<&'static FilterInputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FilterInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_filter_input_stream_get_base_stream")] #[doc(alias = "get_base_stream")] #[doc(alias = "base-stream")] fn base_stream(&self) -> InputStream { unsafe { from_glib_none(ffi::g_filter_input_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_filter_input_stream_get_close_base_stream")] #[doc(alias = "get_close_base_stream")] #[doc(alias = "close-base-stream")] fn closes_base_stream(&self) -> bool { unsafe { from_glib(ffi::g_filter_input_stream_get_close_base_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_filter_input_stream_set_close_base_stream")] #[doc(alias = "close-base-stream")] fn set_close_base_stream(&self, close_base: bool) { unsafe { ffi::g_filter_input_stream_set_close_base_stream( self.as_ref().to_glib_none().0, close_base.into_glib(), ); } } #[doc(alias = "close-base-stream")] fn connect_close_base_stream_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_close_base_stream_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GFilterInputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(FilterInputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::close-base-stream\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_close_base_stream_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> FilterInputStreamExt for O {} gio-0.20.1/src/auto/filter_output_stream.rs000064400000000000000000000056011046102023000170510ustar 00000000000000// 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::{ffi, OutputStream}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GFilterOutputStream")] pub struct FilterOutputStream(Object) @extends OutputStream; match fn { type_ => || ffi::g_filter_output_stream_get_type(), } } impl FilterOutputStream { pub const NONE: Option<&'static FilterOutputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FilterOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_filter_output_stream_get_base_stream")] #[doc(alias = "get_base_stream")] #[doc(alias = "base-stream")] fn base_stream(&self) -> OutputStream { unsafe { from_glib_none(ffi::g_filter_output_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_filter_output_stream_get_close_base_stream")] #[doc(alias = "get_close_base_stream")] #[doc(alias = "close-base-stream")] fn closes_base_stream(&self) -> bool { unsafe { from_glib(ffi::g_filter_output_stream_get_close_base_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_filter_output_stream_set_close_base_stream")] fn set_close_base_stream(&self, close_base: bool) { unsafe { ffi::g_filter_output_stream_set_close_base_stream( self.as_ref().to_glib_none().0, close_base.into_glib(), ); } } #[doc(alias = "close-base-stream")] fn connect_close_base_stream_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_close_base_stream_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GFilterOutputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(FilterOutputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::close-base-stream\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_close_base_stream_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> FilterOutputStreamExt for O {} gio-0.20.1/src/auto/flags.rs000064400000000000000000002510721046102023000136720ustar 00000000000000// 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::ffi; use glib::{bitflags::bitflags, prelude::*, translate::*}; bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GAppInfoCreateFlags")] pub struct AppInfoCreateFlags: u32 { #[doc(alias = "G_APP_INFO_CREATE_NONE")] const NONE = ffi::G_APP_INFO_CREATE_NONE as _; #[doc(alias = "G_APP_INFO_CREATE_NEEDS_TERMINAL")] const NEEDS_TERMINAL = ffi::G_APP_INFO_CREATE_NEEDS_TERMINAL as _; #[doc(alias = "G_APP_INFO_CREATE_SUPPORTS_URIS")] const SUPPORTS_URIS = ffi::G_APP_INFO_CREATE_SUPPORTS_URIS as _; #[doc(alias = "G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION")] const SUPPORTS_STARTUP_NOTIFICATION = ffi::G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION as _; } } #[doc(hidden)] impl IntoGlib for AppInfoCreateFlags { type GlibType = ffi::GAppInfoCreateFlags; #[inline] fn into_glib(self) -> ffi::GAppInfoCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AppInfoCreateFlags { #[inline] unsafe fn from_glib(value: ffi::GAppInfoCreateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for AppInfoCreateFlags { #[inline] #[doc(alias = "g_app_info_create_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_app_info_create_flags_get_type()) } } } impl glib::HasParamSpec for AppInfoCreateFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for AppInfoCreateFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for AppInfoCreateFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for AppInfoCreateFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: AppInfoCreateFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GApplicationFlags")] pub struct ApplicationFlags: u32 { #[doc(alias = "G_APPLICATION_FLAGS_NONE")] const FLAGS_NONE = ffi::G_APPLICATION_FLAGS_NONE as _; #[doc(alias = "G_APPLICATION_IS_SERVICE")] const IS_SERVICE = ffi::G_APPLICATION_IS_SERVICE as _; #[doc(alias = "G_APPLICATION_IS_LAUNCHER")] const IS_LAUNCHER = ffi::G_APPLICATION_IS_LAUNCHER as _; #[doc(alias = "G_APPLICATION_HANDLES_OPEN")] const HANDLES_OPEN = ffi::G_APPLICATION_HANDLES_OPEN as _; #[doc(alias = "G_APPLICATION_HANDLES_COMMAND_LINE")] const HANDLES_COMMAND_LINE = ffi::G_APPLICATION_HANDLES_COMMAND_LINE as _; #[doc(alias = "G_APPLICATION_SEND_ENVIRONMENT")] const SEND_ENVIRONMENT = ffi::G_APPLICATION_SEND_ENVIRONMENT as _; #[doc(alias = "G_APPLICATION_NON_UNIQUE")] const NON_UNIQUE = ffi::G_APPLICATION_NON_UNIQUE as _; #[doc(alias = "G_APPLICATION_CAN_OVERRIDE_APP_ID")] const CAN_OVERRIDE_APP_ID = ffi::G_APPLICATION_CAN_OVERRIDE_APP_ID as _; #[doc(alias = "G_APPLICATION_ALLOW_REPLACEMENT")] const ALLOW_REPLACEMENT = ffi::G_APPLICATION_ALLOW_REPLACEMENT as _; #[doc(alias = "G_APPLICATION_REPLACE")] const REPLACE = ffi::G_APPLICATION_REPLACE as _; } } #[doc(hidden)] impl IntoGlib for ApplicationFlags { type GlibType = ffi::GApplicationFlags; #[inline] fn into_glib(self) -> ffi::GApplicationFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ApplicationFlags { #[inline] unsafe fn from_glib(value: ffi::GApplicationFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ApplicationFlags { #[inline] #[doc(alias = "g_application_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_application_flags_get_type()) } } } impl glib::HasParamSpec for ApplicationFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for ApplicationFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ApplicationFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for ApplicationFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ApplicationFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GAskPasswordFlags")] pub struct AskPasswordFlags: u32 { #[doc(alias = "G_ASK_PASSWORD_NEED_PASSWORD")] const NEED_PASSWORD = ffi::G_ASK_PASSWORD_NEED_PASSWORD as _; #[doc(alias = "G_ASK_PASSWORD_NEED_USERNAME")] const NEED_USERNAME = ffi::G_ASK_PASSWORD_NEED_USERNAME as _; #[doc(alias = "G_ASK_PASSWORD_NEED_DOMAIN")] const NEED_DOMAIN = ffi::G_ASK_PASSWORD_NEED_DOMAIN as _; #[doc(alias = "G_ASK_PASSWORD_SAVING_SUPPORTED")] const SAVING_SUPPORTED = ffi::G_ASK_PASSWORD_SAVING_SUPPORTED as _; #[doc(alias = "G_ASK_PASSWORD_ANONYMOUS_SUPPORTED")] const ANONYMOUS_SUPPORTED = ffi::G_ASK_PASSWORD_ANONYMOUS_SUPPORTED as _; #[doc(alias = "G_ASK_PASSWORD_TCRYPT")] const TCRYPT = ffi::G_ASK_PASSWORD_TCRYPT as _; } } #[doc(hidden)] impl IntoGlib for AskPasswordFlags { type GlibType = ffi::GAskPasswordFlags; #[inline] fn into_glib(self) -> ffi::GAskPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AskPasswordFlags { #[inline] unsafe fn from_glib(value: ffi::GAskPasswordFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for AskPasswordFlags { #[inline] #[doc(alias = "g_ask_password_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_ask_password_flags_get_type()) } } } impl glib::HasParamSpec for AskPasswordFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for AskPasswordFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for AskPasswordFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for AskPasswordFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: AskPasswordFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GBusNameOwnerFlags")] pub struct BusNameOwnerFlags: u32 { #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_NONE")] const NONE = ffi::G_BUS_NAME_OWNER_FLAGS_NONE as _; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT")] const ALLOW_REPLACEMENT = ffi::G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT as _; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_REPLACE")] const REPLACE = ffi::G_BUS_NAME_OWNER_FLAGS_REPLACE as _; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE")] const DO_NOT_QUEUE = ffi::G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE as _; } } #[doc(hidden)] impl IntoGlib for BusNameOwnerFlags { type GlibType = ffi::GBusNameOwnerFlags; #[inline] fn into_glib(self) -> ffi::GBusNameOwnerFlags { self.bits() } } #[doc(hidden)] impl FromGlib for BusNameOwnerFlags { #[inline] unsafe fn from_glib(value: ffi::GBusNameOwnerFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for BusNameOwnerFlags { #[inline] #[doc(alias = "g_bus_name_owner_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_bus_name_owner_flags_get_type()) } } } impl glib::HasParamSpec for BusNameOwnerFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for BusNameOwnerFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for BusNameOwnerFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for BusNameOwnerFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: BusNameOwnerFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GBusNameWatcherFlags")] pub struct BusNameWatcherFlags: u32 { #[doc(alias = "G_BUS_NAME_WATCHER_FLAGS_NONE")] const NONE = ffi::G_BUS_NAME_WATCHER_FLAGS_NONE as _; #[doc(alias = "G_BUS_NAME_WATCHER_FLAGS_AUTO_START")] const AUTO_START = ffi::G_BUS_NAME_WATCHER_FLAGS_AUTO_START as _; } } #[doc(hidden)] impl IntoGlib for BusNameWatcherFlags { type GlibType = ffi::GBusNameWatcherFlags; #[inline] fn into_glib(self) -> ffi::GBusNameWatcherFlags { self.bits() } } #[doc(hidden)] impl FromGlib for BusNameWatcherFlags { #[inline] unsafe fn from_glib(value: ffi::GBusNameWatcherFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for BusNameWatcherFlags { #[inline] #[doc(alias = "g_bus_name_watcher_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_bus_name_watcher_flags_get_type()) } } } impl glib::HasParamSpec for BusNameWatcherFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for BusNameWatcherFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for BusNameWatcherFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for BusNameWatcherFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: BusNameWatcherFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GConverterFlags")] pub struct ConverterFlags: u32 { #[doc(alias = "G_CONVERTER_NO_FLAGS")] const NONE = ffi::G_CONVERTER_NO_FLAGS as _; #[doc(alias = "G_CONVERTER_INPUT_AT_END")] const INPUT_AT_END = ffi::G_CONVERTER_INPUT_AT_END as _; #[doc(alias = "G_CONVERTER_FLUSH")] const FLUSH = ffi::G_CONVERTER_FLUSH as _; } } #[doc(hidden)] impl IntoGlib for ConverterFlags { type GlibType = ffi::GConverterFlags; #[inline] fn into_glib(self) -> ffi::GConverterFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ConverterFlags { #[inline] unsafe fn from_glib(value: ffi::GConverterFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ConverterFlags { #[inline] #[doc(alias = "g_converter_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_converter_flags_get_type()) } } } impl glib::HasParamSpec for ConverterFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for ConverterFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ConverterFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for ConverterFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ConverterFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusCallFlags")] pub struct DBusCallFlags: u32 { #[doc(alias = "G_DBUS_CALL_FLAGS_NONE")] const NONE = ffi::G_DBUS_CALL_FLAGS_NONE as _; #[doc(alias = "G_DBUS_CALL_FLAGS_NO_AUTO_START")] const NO_AUTO_START = ffi::G_DBUS_CALL_FLAGS_NO_AUTO_START as _; #[doc(alias = "G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION")] const ALLOW_INTERACTIVE_AUTHORIZATION = ffi::G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION as _; } } #[doc(hidden)] impl IntoGlib for DBusCallFlags { type GlibType = ffi::GDBusCallFlags; #[inline] fn into_glib(self) -> ffi::GDBusCallFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusCallFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusCallFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusCallFlags { #[inline] #[doc(alias = "g_dbus_call_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_call_flags_get_type()) } } } impl glib::HasParamSpec for DBusCallFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusCallFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusCallFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusCallFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusCallFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusCapabilityFlags")] pub struct DBusCapabilityFlags: u32 { #[doc(alias = "G_DBUS_CAPABILITY_FLAGS_NONE")] const NONE = ffi::G_DBUS_CAPABILITY_FLAGS_NONE as _; #[doc(alias = "G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING")] const UNIX_FD_PASSING = ffi::G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING as _; } } #[doc(hidden)] impl IntoGlib for DBusCapabilityFlags { type GlibType = ffi::GDBusCapabilityFlags; #[inline] fn into_glib(self) -> ffi::GDBusCapabilityFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusCapabilityFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusCapabilityFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusCapabilityFlags { #[inline] #[doc(alias = "g_dbus_capability_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_capability_flags_get_type()) } } } impl glib::HasParamSpec for DBusCapabilityFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusCapabilityFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusCapabilityFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusCapabilityFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusCapabilityFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusConnectionFlags")] pub struct DBusConnectionFlags: u32 { #[doc(alias = "G_DBUS_CONNECTION_FLAGS_NONE")] const NONE = ffi::G_DBUS_CONNECTION_FLAGS_NONE as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT")] const AUTHENTICATION_CLIENT = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER")] const AUTHENTICATION_SERVER = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS")] const AUTHENTICATION_ALLOW_ANONYMOUS = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION")] const MESSAGE_BUS_CONNECTION = ffi::G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING")] const DELAY_MESSAGE_PROCESSING = ffi::G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING as _; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER")] const AUTHENTICATION_REQUIRE_SAME_USER = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER as _; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "G_DBUS_CONNECTION_FLAGS_CROSS_NAMESPACE")] const CROSS_NAMESPACE = ffi::G_DBUS_CONNECTION_FLAGS_CROSS_NAMESPACE as _; } } #[doc(hidden)] impl IntoGlib for DBusConnectionFlags { type GlibType = ffi::GDBusConnectionFlags; #[inline] fn into_glib(self) -> ffi::GDBusConnectionFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusConnectionFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusConnectionFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusConnectionFlags { #[inline] #[doc(alias = "g_dbus_connection_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_connection_flags_get_type()) } } } impl glib::HasParamSpec for DBusConnectionFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusConnectionFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusConnectionFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusConnectionFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusConnectionFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusInterfaceSkeletonFlags")] pub struct DBusInterfaceSkeletonFlags: u32 { #[doc(alias = "G_DBUS_INTERFACE_SKELETON_FLAGS_NONE")] const NONE = ffi::G_DBUS_INTERFACE_SKELETON_FLAGS_NONE as _; #[doc(alias = "G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD")] const HANDLE_METHOD_INVOCATIONS_IN_THREAD = ffi::G_DBUS_INTERFACE_SKELETON_FLAGS_HANDLE_METHOD_INVOCATIONS_IN_THREAD as _; } } #[doc(hidden)] impl IntoGlib for DBusInterfaceSkeletonFlags { type GlibType = ffi::GDBusInterfaceSkeletonFlags; #[inline] fn into_glib(self) -> ffi::GDBusInterfaceSkeletonFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusInterfaceSkeletonFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusInterfaceSkeletonFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusInterfaceSkeletonFlags { #[inline] #[doc(alias = "g_dbus_interface_skeleton_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_interface_skeleton_flags_get_type()) } } } impl glib::HasParamSpec for DBusInterfaceSkeletonFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusInterfaceSkeletonFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusInterfaceSkeletonFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusInterfaceSkeletonFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusInterfaceSkeletonFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusMessageFlags")] pub struct DBusMessageFlags: u32 { #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NONE")] const NONE = ffi::G_DBUS_MESSAGE_FLAGS_NONE as _; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED")] const NO_REPLY_EXPECTED = ffi::G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED as _; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NO_AUTO_START")] const NO_AUTO_START = ffi::G_DBUS_MESSAGE_FLAGS_NO_AUTO_START as _; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION")] const ALLOW_INTERACTIVE_AUTHORIZATION = ffi::G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION as _; } } #[doc(hidden)] impl IntoGlib for DBusMessageFlags { type GlibType = ffi::GDBusMessageFlags; #[inline] fn into_glib(self) -> ffi::GDBusMessageFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusMessageFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusMessageFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusMessageFlags { #[inline] #[doc(alias = "g_dbus_message_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_message_flags_get_type()) } } } impl glib::HasParamSpec for DBusMessageFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusMessageFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusMessageFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusMessageFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusMessageFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusObjectManagerClientFlags")] pub struct DBusObjectManagerClientFlags: u32 { #[doc(alias = "G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE")] const NONE = ffi::G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE as _; #[doc(alias = "G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START")] const DO_NOT_AUTO_START = ffi::G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START as _; } } #[doc(hidden)] impl IntoGlib for DBusObjectManagerClientFlags { type GlibType = ffi::GDBusObjectManagerClientFlags; #[inline] fn into_glib(self) -> ffi::GDBusObjectManagerClientFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusObjectManagerClientFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusObjectManagerClientFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusObjectManagerClientFlags { #[inline] #[doc(alias = "g_dbus_object_manager_client_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_object_manager_client_flags_get_type()) } } } impl glib::HasParamSpec for DBusObjectManagerClientFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusObjectManagerClientFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusObjectManagerClientFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusObjectManagerClientFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusObjectManagerClientFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusProxyFlags")] pub struct DBusProxyFlags: u32 { #[doc(alias = "G_DBUS_PROXY_FLAGS_NONE")] const NONE = ffi::G_DBUS_PROXY_FLAGS_NONE as _; #[doc(alias = "G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES")] const DO_NOT_LOAD_PROPERTIES = ffi::G_DBUS_PROXY_FLAGS_DO_NOT_LOAD_PROPERTIES as _; #[doc(alias = "G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS")] const DO_NOT_CONNECT_SIGNALS = ffi::G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS as _; #[doc(alias = "G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START")] const DO_NOT_AUTO_START = ffi::G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START as _; #[doc(alias = "G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES")] const GET_INVALIDATED_PROPERTIES = ffi::G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES as _; #[doc(alias = "G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION")] const DO_NOT_AUTO_START_AT_CONSTRUCTION = ffi::G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START_AT_CONSTRUCTION as _; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "G_DBUS_PROXY_FLAGS_NO_MATCH_RULE")] const NO_MATCH_RULE = ffi::G_DBUS_PROXY_FLAGS_NO_MATCH_RULE as _; } } #[doc(hidden)] impl IntoGlib for DBusProxyFlags { type GlibType = ffi::GDBusProxyFlags; #[inline] fn into_glib(self) -> ffi::GDBusProxyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusProxyFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusProxyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusProxyFlags { #[inline] #[doc(alias = "g_dbus_proxy_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_proxy_flags_get_type()) } } } impl glib::HasParamSpec for DBusProxyFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusProxyFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusProxyFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusProxyFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusProxyFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusSendMessageFlags")] pub struct DBusSendMessageFlags: u32 { #[doc(alias = "G_DBUS_SEND_MESSAGE_FLAGS_NONE")] const NONE = ffi::G_DBUS_SEND_MESSAGE_FLAGS_NONE as _; #[doc(alias = "G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL")] const PRESERVE_SERIAL = ffi::G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL as _; } } #[doc(hidden)] impl IntoGlib for DBusSendMessageFlags { type GlibType = ffi::GDBusSendMessageFlags; #[inline] fn into_glib(self) -> ffi::GDBusSendMessageFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusSendMessageFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusSendMessageFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusSendMessageFlags { #[inline] #[doc(alias = "g_dbus_send_message_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_send_message_flags_get_type()) } } } impl glib::HasParamSpec for DBusSendMessageFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusSendMessageFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusSendMessageFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusSendMessageFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusSendMessageFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusServerFlags")] pub struct DBusServerFlags: u32 { #[doc(alias = "G_DBUS_SERVER_FLAGS_NONE")] const NONE = ffi::G_DBUS_SERVER_FLAGS_NONE as _; #[doc(alias = "G_DBUS_SERVER_FLAGS_RUN_IN_THREAD")] const RUN_IN_THREAD = ffi::G_DBUS_SERVER_FLAGS_RUN_IN_THREAD as _; #[doc(alias = "G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS")] const AUTHENTICATION_ALLOW_ANONYMOUS = ffi::G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS as _; #[doc(alias = "G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER")] const AUTHENTICATION_REQUIRE_SAME_USER = ffi::G_DBUS_SERVER_FLAGS_AUTHENTICATION_REQUIRE_SAME_USER as _; } } #[doc(hidden)] impl IntoGlib for DBusServerFlags { type GlibType = ffi::GDBusServerFlags; #[inline] fn into_glib(self) -> ffi::GDBusServerFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusServerFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusServerFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusServerFlags { #[inline] #[doc(alias = "g_dbus_server_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_server_flags_get_type()) } } } impl glib::HasParamSpec for DBusServerFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusServerFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusServerFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusServerFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusServerFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDBusSignalFlags")] pub struct DBusSignalFlags: u32 { #[doc(alias = "G_DBUS_SIGNAL_FLAGS_NONE")] const NONE = ffi::G_DBUS_SIGNAL_FLAGS_NONE as _; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE")] const NO_MATCH_RULE = ffi::G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE as _; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE")] const MATCH_ARG0_NAMESPACE = ffi::G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE as _; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH")] const MATCH_ARG0_PATH = ffi::G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH as _; } } #[doc(hidden)] impl IntoGlib for DBusSignalFlags { type GlibType = ffi::GDBusSignalFlags; #[inline] fn into_glib(self) -> ffi::GDBusSignalFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusSignalFlags { #[inline] unsafe fn from_glib(value: ffi::GDBusSignalFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusSignalFlags { #[inline] #[doc(alias = "g_dbus_signal_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_dbus_signal_flags_get_type()) } } } impl glib::HasParamSpec for DBusSignalFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DBusSignalFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DBusSignalFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DBusSignalFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DBusSignalFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GDriveStartFlags")] pub struct DriveStartFlags: u32 { #[doc(alias = "G_DRIVE_START_NONE")] const NONE = ffi::G_DRIVE_START_NONE as _; } } #[doc(hidden)] impl IntoGlib for DriveStartFlags { type GlibType = ffi::GDriveStartFlags; #[inline] fn into_glib(self) -> ffi::GDriveStartFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DriveStartFlags { #[inline] unsafe fn from_glib(value: ffi::GDriveStartFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DriveStartFlags { #[inline] #[doc(alias = "g_drive_start_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_drive_start_flags_get_type()) } } } impl glib::HasParamSpec for DriveStartFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for DriveStartFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for DriveStartFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for DriveStartFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: DriveStartFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileAttributeInfoFlags")] pub struct FileAttributeInfoFlags: u32 { #[doc(alias = "G_FILE_ATTRIBUTE_INFO_NONE")] const NONE = ffi::G_FILE_ATTRIBUTE_INFO_NONE as _; #[doc(alias = "G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE")] const COPY_WITH_FILE = ffi::G_FILE_ATTRIBUTE_INFO_COPY_WITH_FILE as _; #[doc(alias = "G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED")] const COPY_WHEN_MOVED = ffi::G_FILE_ATTRIBUTE_INFO_COPY_WHEN_MOVED as _; } } #[doc(hidden)] impl IntoGlib for FileAttributeInfoFlags { type GlibType = ffi::GFileAttributeInfoFlags; #[inline] fn into_glib(self) -> ffi::GFileAttributeInfoFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileAttributeInfoFlags { #[inline] unsafe fn from_glib(value: ffi::GFileAttributeInfoFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileAttributeInfoFlags { #[inline] #[doc(alias = "g_file_attribute_info_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_attribute_info_flags_get_type()) } } } impl glib::HasParamSpec for FileAttributeInfoFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileAttributeInfoFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileAttributeInfoFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileAttributeInfoFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileAttributeInfoFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileCopyFlags")] pub struct FileCopyFlags: u32 { #[doc(alias = "G_FILE_COPY_NONE")] const NONE = ffi::G_FILE_COPY_NONE as _; #[doc(alias = "G_FILE_COPY_OVERWRITE")] const OVERWRITE = ffi::G_FILE_COPY_OVERWRITE as _; #[doc(alias = "G_FILE_COPY_BACKUP")] const BACKUP = ffi::G_FILE_COPY_BACKUP as _; #[doc(alias = "G_FILE_COPY_NOFOLLOW_SYMLINKS")] const NOFOLLOW_SYMLINKS = ffi::G_FILE_COPY_NOFOLLOW_SYMLINKS as _; #[doc(alias = "G_FILE_COPY_ALL_METADATA")] const ALL_METADATA = ffi::G_FILE_COPY_ALL_METADATA as _; #[doc(alias = "G_FILE_COPY_NO_FALLBACK_FOR_MOVE")] const NO_FALLBACK_FOR_MOVE = ffi::G_FILE_COPY_NO_FALLBACK_FOR_MOVE as _; #[doc(alias = "G_FILE_COPY_TARGET_DEFAULT_PERMS")] const TARGET_DEFAULT_PERMS = ffi::G_FILE_COPY_TARGET_DEFAULT_PERMS as _; #[cfg(feature = "v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_80")))] #[doc(alias = "G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME")] const TARGET_DEFAULT_MODIFIED_TIME = ffi::G_FILE_COPY_TARGET_DEFAULT_MODIFIED_TIME as _; } } #[doc(hidden)] impl IntoGlib for FileCopyFlags { type GlibType = ffi::GFileCopyFlags; #[inline] fn into_glib(self) -> ffi::GFileCopyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCopyFlags { #[inline] unsafe fn from_glib(value: ffi::GFileCopyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileCopyFlags { #[inline] #[doc(alias = "g_file_copy_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_copy_flags_get_type()) } } } impl glib::HasParamSpec for FileCopyFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileCopyFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileCopyFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileCopyFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileCopyFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileCreateFlags")] pub struct FileCreateFlags: u32 { #[doc(alias = "G_FILE_CREATE_NONE")] const NONE = ffi::G_FILE_CREATE_NONE as _; #[doc(alias = "G_FILE_CREATE_PRIVATE")] const PRIVATE = ffi::G_FILE_CREATE_PRIVATE as _; #[doc(alias = "G_FILE_CREATE_REPLACE_DESTINATION")] const REPLACE_DESTINATION = ffi::G_FILE_CREATE_REPLACE_DESTINATION as _; } } #[doc(hidden)] impl IntoGlib for FileCreateFlags { type GlibType = ffi::GFileCreateFlags; #[inline] fn into_glib(self) -> ffi::GFileCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCreateFlags { #[inline] unsafe fn from_glib(value: ffi::GFileCreateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileCreateFlags { #[inline] #[doc(alias = "g_file_create_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_create_flags_get_type()) } } } impl glib::HasParamSpec for FileCreateFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileCreateFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileCreateFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileCreateFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileCreateFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileMeasureFlags")] pub struct FileMeasureFlags: u32 { #[doc(alias = "G_FILE_MEASURE_NONE")] const NONE = ffi::G_FILE_MEASURE_NONE as _; #[doc(alias = "G_FILE_MEASURE_REPORT_ANY_ERROR")] const REPORT_ANY_ERROR = ffi::G_FILE_MEASURE_REPORT_ANY_ERROR as _; #[doc(alias = "G_FILE_MEASURE_APPARENT_SIZE")] const APPARENT_SIZE = ffi::G_FILE_MEASURE_APPARENT_SIZE as _; #[doc(alias = "G_FILE_MEASURE_NO_XDEV")] const NO_XDEV = ffi::G_FILE_MEASURE_NO_XDEV as _; } } #[doc(hidden)] impl IntoGlib for FileMeasureFlags { type GlibType = ffi::GFileMeasureFlags; #[inline] fn into_glib(self) -> ffi::GFileMeasureFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMeasureFlags { #[inline] unsafe fn from_glib(value: ffi::GFileMeasureFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileMeasureFlags { #[inline] #[doc(alias = "g_file_measure_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_measure_flags_get_type()) } } } impl glib::HasParamSpec for FileMeasureFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileMeasureFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileMeasureFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileMeasureFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileMeasureFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileMonitorFlags")] pub struct FileMonitorFlags: u32 { #[doc(alias = "G_FILE_MONITOR_NONE")] const NONE = ffi::G_FILE_MONITOR_NONE as _; #[doc(alias = "G_FILE_MONITOR_WATCH_MOUNTS")] const WATCH_MOUNTS = ffi::G_FILE_MONITOR_WATCH_MOUNTS as _; #[doc(alias = "G_FILE_MONITOR_SEND_MOVED")] const SEND_MOVED = ffi::G_FILE_MONITOR_SEND_MOVED as _; #[doc(alias = "G_FILE_MONITOR_WATCH_HARD_LINKS")] const WATCH_HARD_LINKS = ffi::G_FILE_MONITOR_WATCH_HARD_LINKS as _; #[doc(alias = "G_FILE_MONITOR_WATCH_MOVES")] const WATCH_MOVES = ffi::G_FILE_MONITOR_WATCH_MOVES as _; } } #[doc(hidden)] impl IntoGlib for FileMonitorFlags { type GlibType = ffi::GFileMonitorFlags; #[inline] fn into_glib(self) -> ffi::GFileMonitorFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMonitorFlags { #[inline] unsafe fn from_glib(value: ffi::GFileMonitorFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileMonitorFlags { #[inline] #[doc(alias = "g_file_monitor_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_monitor_flags_get_type()) } } } impl glib::HasParamSpec for FileMonitorFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileMonitorFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileMonitorFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileMonitorFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileMonitorFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GFileQueryInfoFlags")] pub struct FileQueryInfoFlags: u32 { #[doc(alias = "G_FILE_QUERY_INFO_NONE")] const NONE = ffi::G_FILE_QUERY_INFO_NONE as _; #[doc(alias = "G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS")] const NOFOLLOW_SYMLINKS = ffi::G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS as _; } } #[doc(hidden)] impl IntoGlib for FileQueryInfoFlags { type GlibType = ffi::GFileQueryInfoFlags; #[inline] fn into_glib(self) -> ffi::GFileQueryInfoFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileQueryInfoFlags { #[inline] unsafe fn from_glib(value: ffi::GFileQueryInfoFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileQueryInfoFlags { #[inline] #[doc(alias = "g_file_query_info_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_file_query_info_flags_get_type()) } } } impl glib::HasParamSpec for FileQueryInfoFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for FileQueryInfoFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for FileQueryInfoFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for FileQueryInfoFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: FileQueryInfoFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GIOStreamSpliceFlags")] pub struct IOStreamSpliceFlags: u32 { #[doc(alias = "G_IO_STREAM_SPLICE_NONE")] const NONE = ffi::G_IO_STREAM_SPLICE_NONE as _; #[doc(alias = "G_IO_STREAM_SPLICE_CLOSE_STREAM1")] const CLOSE_STREAM1 = ffi::G_IO_STREAM_SPLICE_CLOSE_STREAM1 as _; #[doc(alias = "G_IO_STREAM_SPLICE_CLOSE_STREAM2")] const CLOSE_STREAM2 = ffi::G_IO_STREAM_SPLICE_CLOSE_STREAM2 as _; #[doc(alias = "G_IO_STREAM_SPLICE_WAIT_FOR_BOTH")] const WAIT_FOR_BOTH = ffi::G_IO_STREAM_SPLICE_WAIT_FOR_BOTH as _; } } #[doc(hidden)] impl IntoGlib for IOStreamSpliceFlags { type GlibType = ffi::GIOStreamSpliceFlags; #[inline] fn into_glib(self) -> ffi::GIOStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for IOStreamSpliceFlags { #[inline] unsafe fn from_glib(value: ffi::GIOStreamSpliceFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for IOStreamSpliceFlags { #[inline] #[doc(alias = "g_io_stream_splice_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_io_stream_splice_flags_get_type()) } } } impl glib::HasParamSpec for IOStreamSpliceFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for IOStreamSpliceFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for IOStreamSpliceFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for IOStreamSpliceFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: IOStreamSpliceFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GMountMountFlags")] pub struct MountMountFlags: u32 { #[doc(alias = "G_MOUNT_MOUNT_NONE")] const NONE = ffi::G_MOUNT_MOUNT_NONE as _; } } #[doc(hidden)] impl IntoGlib for MountMountFlags { type GlibType = ffi::GMountMountFlags; #[inline] fn into_glib(self) -> ffi::GMountMountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountMountFlags { #[inline] unsafe fn from_glib(value: ffi::GMountMountFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for MountMountFlags { #[inline] #[doc(alias = "g_mount_mount_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_mount_mount_flags_get_type()) } } } impl glib::HasParamSpec for MountMountFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for MountMountFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for MountMountFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for MountMountFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: MountMountFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GMountUnmountFlags")] pub struct MountUnmountFlags: u32 { #[doc(alias = "G_MOUNT_UNMOUNT_NONE")] const NONE = ffi::G_MOUNT_UNMOUNT_NONE as _; #[doc(alias = "G_MOUNT_UNMOUNT_FORCE")] const FORCE = ffi::G_MOUNT_UNMOUNT_FORCE as _; } } #[doc(hidden)] impl IntoGlib for MountUnmountFlags { type GlibType = ffi::GMountUnmountFlags; #[inline] fn into_glib(self) -> ffi::GMountUnmountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountUnmountFlags { #[inline] unsafe fn from_glib(value: ffi::GMountUnmountFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for MountUnmountFlags { #[inline] #[doc(alias = "g_mount_unmount_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_mount_unmount_flags_get_type()) } } } impl glib::HasParamSpec for MountUnmountFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for MountUnmountFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for MountUnmountFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for MountUnmountFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: MountUnmountFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GOutputStreamSpliceFlags")] pub struct OutputStreamSpliceFlags: u32 { #[doc(alias = "G_OUTPUT_STREAM_SPLICE_NONE")] const NONE = ffi::G_OUTPUT_STREAM_SPLICE_NONE as _; #[doc(alias = "G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE")] const CLOSE_SOURCE = ffi::G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE as _; #[doc(alias = "G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET")] const CLOSE_TARGET = ffi::G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET as _; } } #[doc(hidden)] impl IntoGlib for OutputStreamSpliceFlags { type GlibType = ffi::GOutputStreamSpliceFlags; #[inline] fn into_glib(self) -> ffi::GOutputStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for OutputStreamSpliceFlags { #[inline] unsafe fn from_glib(value: ffi::GOutputStreamSpliceFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for OutputStreamSpliceFlags { #[inline] #[doc(alias = "g_output_stream_splice_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_output_stream_splice_flags_get_type()) } } } impl glib::HasParamSpec for OutputStreamSpliceFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for OutputStreamSpliceFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for OutputStreamSpliceFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for OutputStreamSpliceFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: OutputStreamSpliceFlags) -> Self { ToValue::to_value(&v) } } #[cfg(feature = "v2_60")] bitflags! { #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GResolverNameLookupFlags")] pub struct ResolverNameLookupFlags: u32 { #[doc(alias = "G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT")] const DEFAULT = ffi::G_RESOLVER_NAME_LOOKUP_FLAGS_DEFAULT as _; #[doc(alias = "G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY")] const IPV4_ONLY = ffi::G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY as _; #[doc(alias = "G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY")] const IPV6_ONLY = ffi::G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY as _; } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl IntoGlib for ResolverNameLookupFlags { type GlibType = ffi::GResolverNameLookupFlags; #[inline] fn into_glib(self) -> ffi::GResolverNameLookupFlags { self.bits() } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl FromGlib for ResolverNameLookupFlags { #[inline] unsafe fn from_glib(value: ffi::GResolverNameLookupFlags) -> Self { Self::from_bits_truncate(value) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl StaticType for ResolverNameLookupFlags { #[inline] #[doc(alias = "g_resolver_name_lookup_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_resolver_name_lookup_flags_get_type()) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl glib::HasParamSpec for ResolverNameLookupFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl glib::value::ValueType for ResolverNameLookupFlags { type Type = Self; } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] unsafe impl<'a> glib::value::FromValue<'a> for ResolverNameLookupFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl ToValue for ResolverNameLookupFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] impl From for glib::Value { #[inline] fn from(v: ResolverNameLookupFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GResourceLookupFlags")] pub struct ResourceLookupFlags: u32 { #[doc(alias = "G_RESOURCE_LOOKUP_FLAGS_NONE")] const NONE = ffi::G_RESOURCE_LOOKUP_FLAGS_NONE as _; } } #[doc(hidden)] impl IntoGlib for ResourceLookupFlags { type GlibType = ffi::GResourceLookupFlags; #[inline] fn into_glib(self) -> ffi::GResourceLookupFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ResourceLookupFlags { #[inline] unsafe fn from_glib(value: ffi::GResourceLookupFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ResourceLookupFlags { #[inline] #[doc(alias = "g_resource_lookup_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_resource_lookup_flags_get_type()) } } } impl glib::HasParamSpec for ResourceLookupFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for ResourceLookupFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for ResourceLookupFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for ResourceLookupFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: ResourceLookupFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GSettingsBindFlags")] pub struct SettingsBindFlags: u32 { #[doc(alias = "G_SETTINGS_BIND_DEFAULT")] const DEFAULT = ffi::G_SETTINGS_BIND_DEFAULT as _; #[doc(alias = "G_SETTINGS_BIND_GET")] const GET = ffi::G_SETTINGS_BIND_GET as _; #[doc(alias = "G_SETTINGS_BIND_SET")] const SET = ffi::G_SETTINGS_BIND_SET as _; #[doc(alias = "G_SETTINGS_BIND_NO_SENSITIVITY")] const NO_SENSITIVITY = ffi::G_SETTINGS_BIND_NO_SENSITIVITY as _; #[doc(alias = "G_SETTINGS_BIND_GET_NO_CHANGES")] const GET_NO_CHANGES = ffi::G_SETTINGS_BIND_GET_NO_CHANGES as _; #[doc(alias = "G_SETTINGS_BIND_INVERT_BOOLEAN")] const INVERT_BOOLEAN = ffi::G_SETTINGS_BIND_INVERT_BOOLEAN as _; } } #[doc(hidden)] impl IntoGlib for SettingsBindFlags { type GlibType = ffi::GSettingsBindFlags; #[inline] fn into_glib(self) -> ffi::GSettingsBindFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SettingsBindFlags { #[inline] unsafe fn from_glib(value: ffi::GSettingsBindFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for SettingsBindFlags { #[inline] #[doc(alias = "g_settings_bind_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_settings_bind_flags_get_type()) } } } impl glib::HasParamSpec for SettingsBindFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for SettingsBindFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SettingsBindFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for SettingsBindFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SettingsBindFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GSubprocessFlags")] pub struct SubprocessFlags: u32 { #[doc(alias = "G_SUBPROCESS_FLAGS_NONE")] const NONE = ffi::G_SUBPROCESS_FLAGS_NONE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDIN_PIPE")] const STDIN_PIPE = ffi::G_SUBPROCESS_FLAGS_STDIN_PIPE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDIN_INHERIT")] const STDIN_INHERIT = ffi::G_SUBPROCESS_FLAGS_STDIN_INHERIT as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDOUT_PIPE")] const STDOUT_PIPE = ffi::G_SUBPROCESS_FLAGS_STDOUT_PIPE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDOUT_SILENCE")] const STDOUT_SILENCE = ffi::G_SUBPROCESS_FLAGS_STDOUT_SILENCE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_PIPE")] const STDERR_PIPE = ffi::G_SUBPROCESS_FLAGS_STDERR_PIPE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_SILENCE")] const STDERR_SILENCE = ffi::G_SUBPROCESS_FLAGS_STDERR_SILENCE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_MERGE")] const STDERR_MERGE = ffi::G_SUBPROCESS_FLAGS_STDERR_MERGE as _; #[doc(alias = "G_SUBPROCESS_FLAGS_INHERIT_FDS")] const INHERIT_FDS = ffi::G_SUBPROCESS_FLAGS_INHERIT_FDS as _; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP")] const SEARCH_PATH_FROM_ENVP = ffi::G_SUBPROCESS_FLAGS_SEARCH_PATH_FROM_ENVP as _; } } #[doc(hidden)] impl IntoGlib for SubprocessFlags { type GlibType = ffi::GSubprocessFlags; #[inline] fn into_glib(self) -> ffi::GSubprocessFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SubprocessFlags { #[inline] unsafe fn from_glib(value: ffi::GSubprocessFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for SubprocessFlags { #[inline] #[doc(alias = "g_subprocess_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_subprocess_flags_get_type()) } } } impl glib::HasParamSpec for SubprocessFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for SubprocessFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SubprocessFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for SubprocessFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: SubprocessFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GTlsCertificateFlags")] pub struct TlsCertificateFlags: u32 { #[doc(alias = "G_TLS_CERTIFICATE_UNKNOWN_CA")] const UNKNOWN_CA = ffi::G_TLS_CERTIFICATE_UNKNOWN_CA as _; #[doc(alias = "G_TLS_CERTIFICATE_BAD_IDENTITY")] const BAD_IDENTITY = ffi::G_TLS_CERTIFICATE_BAD_IDENTITY as _; #[doc(alias = "G_TLS_CERTIFICATE_NOT_ACTIVATED")] const NOT_ACTIVATED = ffi::G_TLS_CERTIFICATE_NOT_ACTIVATED as _; #[doc(alias = "G_TLS_CERTIFICATE_EXPIRED")] const EXPIRED = ffi::G_TLS_CERTIFICATE_EXPIRED as _; #[doc(alias = "G_TLS_CERTIFICATE_REVOKED")] const REVOKED = ffi::G_TLS_CERTIFICATE_REVOKED as _; #[doc(alias = "G_TLS_CERTIFICATE_INSECURE")] const INSECURE = ffi::G_TLS_CERTIFICATE_INSECURE as _; #[doc(alias = "G_TLS_CERTIFICATE_GENERIC_ERROR")] const GENERIC_ERROR = ffi::G_TLS_CERTIFICATE_GENERIC_ERROR as _; #[doc(alias = "G_TLS_CERTIFICATE_VALIDATE_ALL")] const VALIDATE_ALL = ffi::G_TLS_CERTIFICATE_VALIDATE_ALL as _; } } #[doc(hidden)] impl IntoGlib for TlsCertificateFlags { type GlibType = ffi::GTlsCertificateFlags; #[inline] fn into_glib(self) -> ffi::GTlsCertificateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsCertificateFlags { #[inline] unsafe fn from_glib(value: ffi::GTlsCertificateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsCertificateFlags { #[inline] #[doc(alias = "g_tls_certificate_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_certificate_flags_get_type()) } } } impl glib::HasParamSpec for TlsCertificateFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for TlsCertificateFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsCertificateFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for TlsCertificateFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsCertificateFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GTlsDatabaseVerifyFlags")] pub struct TlsDatabaseVerifyFlags: u32 { #[doc(alias = "G_TLS_DATABASE_VERIFY_NONE")] const NONE = ffi::G_TLS_DATABASE_VERIFY_NONE as _; } } #[doc(hidden)] impl IntoGlib for TlsDatabaseVerifyFlags { type GlibType = ffi::GTlsDatabaseVerifyFlags; #[inline] fn into_glib(self) -> ffi::GTlsDatabaseVerifyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsDatabaseVerifyFlags { #[inline] unsafe fn from_glib(value: ffi::GTlsDatabaseVerifyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsDatabaseVerifyFlags { #[inline] #[doc(alias = "g_tls_database_verify_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_database_verify_flags_get_type()) } } } impl glib::HasParamSpec for TlsDatabaseVerifyFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for TlsDatabaseVerifyFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsDatabaseVerifyFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for TlsDatabaseVerifyFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsDatabaseVerifyFlags) -> Self { ToValue::to_value(&v) } } bitflags! { #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] #[doc(alias = "GTlsPasswordFlags")] pub struct TlsPasswordFlags: u32 { #[doc(alias = "G_TLS_PASSWORD_NONE")] const NONE = ffi::G_TLS_PASSWORD_NONE as _; #[doc(alias = "G_TLS_PASSWORD_RETRY")] const RETRY = ffi::G_TLS_PASSWORD_RETRY as _; #[doc(alias = "G_TLS_PASSWORD_MANY_TRIES")] const MANY_TRIES = ffi::G_TLS_PASSWORD_MANY_TRIES as _; #[doc(alias = "G_TLS_PASSWORD_FINAL_TRY")] const FINAL_TRY = ffi::G_TLS_PASSWORD_FINAL_TRY as _; #[doc(alias = "G_TLS_PASSWORD_PKCS11_USER")] const PKCS11_USER = ffi::G_TLS_PASSWORD_PKCS11_USER as _; #[doc(alias = "G_TLS_PASSWORD_PKCS11_SECURITY_OFFICER")] const PKCS11_SECURITY_OFFICER = ffi::G_TLS_PASSWORD_PKCS11_SECURITY_OFFICER as _; #[doc(alias = "G_TLS_PASSWORD_PKCS11_CONTEXT_SPECIFIC")] const PKCS11_CONTEXT_SPECIFIC = ffi::G_TLS_PASSWORD_PKCS11_CONTEXT_SPECIFIC as _; } } #[doc(hidden)] impl IntoGlib for TlsPasswordFlags { type GlibType = ffi::GTlsPasswordFlags; #[inline] fn into_glib(self) -> ffi::GTlsPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsPasswordFlags { #[inline] unsafe fn from_glib(value: ffi::GTlsPasswordFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsPasswordFlags { #[inline] #[doc(alias = "g_tls_password_flags_get_type")] fn static_type() -> glib::Type { unsafe { from_glib(ffi::g_tls_password_flags_get_type()) } } } impl glib::HasParamSpec for TlsPasswordFlags { type ParamSpec = glib::ParamSpecFlags; type SetValue = Self; type BuilderFn = fn(&str) -> glib::ParamSpecFlagsBuilder; fn param_spec_builder() -> Self::BuilderFn { Self::ParamSpec::builder } } impl glib::value::ValueType for TlsPasswordFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for TlsPasswordFlags { type Checker = glib::value::GenericValueTypeChecker; #[inline] unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0)) } } impl ToValue for TlsPasswordFlags { #[inline] fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags(value.to_glib_none_mut().0, self.into_glib()); } value } #[inline] fn value_type(&self) -> glib::Type { Self::static_type() } } impl From for glib::Value { #[inline] fn from(v: TlsPasswordFlags) -> Self { ToValue::to_value(&v) } } gio-0.20.1/src/auto/functions.rs000064400000000000000000000515431046102023000146070ustar 00000000000000// 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::{ ffi, AsyncResult, BusType, Cancellable, DBusConnection, File, IOErrorEnum, IOStream, Icon, InputStream, Resource, ResourceLookupFlags, SettingsBackend, }; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; #[doc(alias = "g_bus_get")] pub fn bus_get) + 'static>( bus_type: BusType, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn bus_get_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_bus_get_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = bus_get_trampoline::

; unsafe { ffi::g_bus_get( bus_type.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn bus_get_future( bus_type: BusType, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { bus_get(bus_type, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_bus_get_sync")] pub fn bus_get_sync( bus_type: BusType, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_bus_get_sync( bus_type.into_glib(), cancellable.map(|p| p.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_bus_own_name")] //pub fn bus_own_name(bus_type: BusType, name: &str, flags: BusNameOwnerFlags, bus_acquired_handler: Option>, name_acquired_handler: Option>, name_lost_handler: Option>) -> u32 { // unsafe { TODO: call ffi:g_bus_own_name() } //} //#[doc(alias = "g_bus_own_name_on_connection")] //pub fn bus_own_name_on_connection(connection: &DBusConnection, name: &str, flags: BusNameOwnerFlags, name_acquired_handler: Option>, name_lost_handler: Option>) -> u32 { // unsafe { TODO: call ffi:g_bus_own_name_on_connection() } //} //#[doc(alias = "g_bus_watch_name")] //pub fn bus_watch_name(bus_type: BusType, name: &str, flags: BusNameWatcherFlags, name_appeared_handler: Option>, name_vanished_handler: Option>) -> u32 { // unsafe { TODO: call ffi:g_bus_watch_name() } //} //#[doc(alias = "g_bus_watch_name_on_connection")] //pub fn bus_watch_name_on_connection(connection: &DBusConnection, name: &str, flags: BusNameWatcherFlags, name_appeared_handler: Option>, name_vanished_handler: Option>) -> u32 { // unsafe { TODO: call ffi:g_bus_watch_name_on_connection() } //} #[doc(alias = "g_content_type_can_be_executable")] pub fn content_type_can_be_executable(type_: &str) -> bool { unsafe { from_glib(ffi::g_content_type_can_be_executable( type_.to_glib_none().0, )) } } #[doc(alias = "g_content_type_equals")] pub fn content_type_equals(type1: &str, type2: &str) -> bool { unsafe { from_glib(ffi::g_content_type_equals( type1.to_glib_none().0, type2.to_glib_none().0, )) } } #[doc(alias = "g_content_type_from_mime_type")] pub fn content_type_from_mime_type(mime_type: &str) -> Option { unsafe { from_glib_full(ffi::g_content_type_from_mime_type( mime_type.to_glib_none().0, )) } } #[doc(alias = "g_content_type_get_description")] pub fn content_type_get_description(type_: &str) -> glib::GString { unsafe { from_glib_full(ffi::g_content_type_get_description(type_.to_glib_none().0)) } } #[doc(alias = "g_content_type_get_generic_icon_name")] pub fn content_type_get_generic_icon_name(type_: &str) -> Option { unsafe { from_glib_full(ffi::g_content_type_get_generic_icon_name( type_.to_glib_none().0, )) } } #[doc(alias = "g_content_type_get_icon")] pub fn content_type_get_icon(type_: &str) -> Icon { unsafe { from_glib_full(ffi::g_content_type_get_icon(type_.to_glib_none().0)) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_content_type_get_mime_dirs")] pub fn content_type_get_mime_dirs() -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_content_type_get_mime_dirs()) } } #[doc(alias = "g_content_type_get_mime_type")] pub fn content_type_get_mime_type(type_: &str) -> Option { unsafe { from_glib_full(ffi::g_content_type_get_mime_type(type_.to_glib_none().0)) } } #[doc(alias = "g_content_type_get_symbolic_icon")] pub fn content_type_get_symbolic_icon(type_: &str) -> Icon { unsafe { from_glib_full(ffi::g_content_type_get_symbolic_icon( type_.to_glib_none().0, )) } } #[doc(alias = "g_content_type_guess")] pub fn content_type_guess( filename: Option>, data: &[u8], ) -> (glib::GString, bool) { let data_size = data.len() as _; unsafe { let mut result_uncertain = std::mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_content_type_guess( filename.as_ref().map(|p| p.as_ref()).to_glib_none().0, data.to_glib_none().0, data_size, result_uncertain.as_mut_ptr(), )); (ret, from_glib(result_uncertain.assume_init())) } } #[doc(alias = "g_content_type_guess_for_tree")] pub fn content_type_guess_for_tree(root: &impl IsA) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_content_type_guess_for_tree( root.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_content_type_is_a")] pub fn content_type_is_a(type_: &str, supertype: &str) -> bool { unsafe { from_glib(ffi::g_content_type_is_a( type_.to_glib_none().0, supertype.to_glib_none().0, )) } } #[doc(alias = "g_content_type_is_mime_type")] pub fn content_type_is_mime_type(type_: &str, mime_type: &str) -> bool { unsafe { from_glib(ffi::g_content_type_is_mime_type( type_.to_glib_none().0, mime_type.to_glib_none().0, )) } } #[doc(alias = "g_content_type_is_unknown")] pub fn content_type_is_unknown(type_: &str) -> bool { unsafe { from_glib(ffi::g_content_type_is_unknown(type_.to_glib_none().0)) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_content_type_set_mime_dirs")] pub fn content_type_set_mime_dirs(dirs: &[&str]) { unsafe { ffi::g_content_type_set_mime_dirs(dirs.to_glib_none().0); } } #[doc(alias = "g_content_types_get_registered")] pub fn content_types_get_registered() -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_content_types_get_registered()) } } #[doc(alias = "g_dbus_address_escape_value")] pub fn dbus_address_escape_value(string: &str) -> glib::GString { unsafe { from_glib_full(ffi::g_dbus_address_escape_value(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_address_get_for_bus_sync")] pub fn dbus_address_get_for_bus_sync( bus_type: BusType, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_address_get_for_bus_sync( bus_type.into_glib(), cancellable.map(|p| p.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_dbus_address_get_stream")] pub fn dbus_address_get_stream< P: FnOnce(Result<(IOStream, Option), glib::Error>) + 'static, >( address: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn dbus_address_get_stream_trampoline< P: FnOnce(Result<(IOStream, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut out_guid = std::ptr::null_mut(); let ret = ffi::g_dbus_address_get_stream_finish(res, &mut out_guid, &mut error); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_guid))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = dbus_address_get_stream_trampoline::

; unsafe { ffi::g_dbus_address_get_stream( address.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn dbus_address_get_stream_future( address: &str, ) -> Pin< Box_< dyn std::future::Future), glib::Error>> + 'static, >, > { let address = String::from(address); Box_::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { dbus_address_get_stream(&address, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_dbus_address_get_stream_sync")] pub fn dbus_address_get_stream_sync( address: &str, cancellable: Option<&impl IsA>, ) -> Result<(IOStream, Option), glib::Error> { unsafe { let mut out_guid = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_dbus_address_get_stream_sync( address.to_glib_none().0, &mut out_guid, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(out_guid))) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "g_dbus_escape_object_path")] pub fn dbus_escape_object_path(s: &str) -> glib::GString { unsafe { from_glib_full(ffi::g_dbus_escape_object_path(s.to_glib_none().0)) } } //#[cfg(feature = "v2_68")] //#[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] //#[doc(alias = "g_dbus_escape_object_path_bytestring")] //pub fn dbus_escape_object_path_bytestring(bytes: &[u8]) -> glib::GString { // unsafe { TODO: call ffi:g_dbus_escape_object_path_bytestring() } //} #[doc(alias = "g_dbus_generate_guid")] pub fn dbus_generate_guid() -> glib::GString { unsafe { from_glib_full(ffi::g_dbus_generate_guid()) } } #[doc(alias = "g_dbus_gvalue_to_gvariant")] pub fn dbus_gvalue_to_gvariant(gvalue: &glib::Value, type_: &glib::VariantTy) -> glib::Variant { unsafe { from_glib_full(ffi::g_dbus_gvalue_to_gvariant( gvalue.to_glib_none().0, type_.to_glib_none().0, )) } } #[doc(alias = "g_dbus_gvariant_to_gvalue")] pub fn dbus_gvariant_to_gvalue(value: &glib::Variant) -> glib::Value { unsafe { let mut out_gvalue = glib::Value::uninitialized(); ffi::g_dbus_gvariant_to_gvalue(value.to_glib_none().0, out_gvalue.to_glib_none_mut().0); out_gvalue } } #[doc(alias = "g_dbus_is_address")] pub fn dbus_is_address(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_address(string.to_glib_none().0)) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_dbus_is_error_name")] pub fn dbus_is_error_name(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_error_name(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_is_guid")] pub fn dbus_is_guid(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_guid(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_is_interface_name")] pub fn dbus_is_interface_name(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_interface_name(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_is_member_name")] pub fn dbus_is_member_name(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_member_name(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_is_name")] pub fn dbus_is_name(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_name(string.to_glib_none().0)) } } #[doc(alias = "g_dbus_is_supported_address")] pub fn dbus_is_supported_address(string: &str) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_dbus_is_supported_address(string.to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_is_unique_name")] pub fn dbus_is_unique_name(string: &str) -> bool { unsafe { from_glib(ffi::g_dbus_is_unique_name(string.to_glib_none().0)) } } #[doc(alias = "g_io_error_from_errno")] pub fn io_error_from_errno(err_no: i32) -> IOErrorEnum { unsafe { from_glib(ffi::g_io_error_from_errno(err_no)) } } //#[doc(alias = "g_io_modules_load_all_in_directory")] //pub fn io_modules_load_all_in_directory(dirname: impl AsRef) -> /*Ignored*/Vec { // unsafe { TODO: call ffi:g_io_modules_load_all_in_directory() } //} //#[doc(alias = "g_io_modules_load_all_in_directory_with_scope")] //pub fn io_modules_load_all_in_directory_with_scope(dirname: impl AsRef, scope: /*Ignored*/&mut IOModuleScope) -> /*Ignored*/Vec { // unsafe { TODO: call ffi:g_io_modules_load_all_in_directory_with_scope() } //} #[doc(alias = "g_io_modules_scan_all_in_directory")] pub fn io_modules_scan_all_in_directory(dirname: impl AsRef) { unsafe { ffi::g_io_modules_scan_all_in_directory(dirname.as_ref().to_glib_none().0); } } //#[doc(alias = "g_io_modules_scan_all_in_directory_with_scope")] //pub fn io_modules_scan_all_in_directory_with_scope(dirname: impl AsRef, scope: /*Ignored*/&mut IOModuleScope) { // unsafe { TODO: call ffi:g_io_modules_scan_all_in_directory_with_scope() } //} #[doc(alias = "g_keyfile_settings_backend_new")] pub fn keyfile_settings_backend_new( filename: &str, root_path: &str, root_group: Option<&str>, ) -> SettingsBackend { unsafe { from_glib_full(ffi::g_keyfile_settings_backend_new( filename.to_glib_none().0, root_path.to_glib_none().0, root_group.to_glib_none().0, )) } } #[doc(alias = "g_memory_settings_backend_new")] pub fn memory_settings_backend_new() -> SettingsBackend { unsafe { from_glib_full(ffi::g_memory_settings_backend_new()) } } #[doc(alias = "g_null_settings_backend_new")] pub fn null_settings_backend_new() -> SettingsBackend { unsafe { from_glib_full(ffi::g_null_settings_backend_new()) } } #[doc(alias = "g_resources_enumerate_children")] pub fn resources_enumerate_children( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resources_enumerate_children( path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resources_get_info")] pub fn resources_get_info( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result<(usize, u32), glib::Error> { unsafe { let mut size = std::mem::MaybeUninit::uninit(); let mut flags = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_resources_get_info( path.to_glib_none().0, lookup_flags.into_glib(), size.as_mut_ptr(), flags.as_mut_ptr(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok((size.assume_init(), flags.assume_init())) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resources_lookup_data")] pub fn resources_lookup_data( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resources_lookup_data( path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resources_open_stream")] pub fn resources_open_stream( path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resources_open_stream( path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resources_register")] pub fn resources_register(resource: &Resource) { unsafe { ffi::g_resources_register(resource.to_glib_none().0); } } #[doc(alias = "g_resources_unregister")] pub fn resources_unregister(resource: &Resource) { unsafe { ffi::g_resources_unregister(resource.to_glib_none().0); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_unix_is_mount_path_system_internal")] pub fn unix_is_mount_path_system_internal(mount_path: impl AsRef) -> bool { unsafe { from_glib(ffi::g_unix_is_mount_path_system_internal( mount_path.as_ref().to_glib_none().0, )) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_unix_is_system_device_path")] pub fn unix_is_system_device_path(device_path: impl AsRef) -> bool { unsafe { from_glib(ffi::g_unix_is_system_device_path( device_path.as_ref().to_glib_none().0, )) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_unix_is_system_fs_type")] pub fn unix_is_system_fs_type(fs_type: &str) -> bool { unsafe { from_glib(ffi::g_unix_is_system_fs_type(fs_type.to_glib_none().0)) } } gio-0.20.1/src/auto/icon.rs000064400000000000000000000042451046102023000135240ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GIcon")] pub struct Icon(Interface); match fn { type_ => || ffi::g_icon_get_type(), } } impl Icon { pub const NONE: Option<&'static Icon> = None; #[doc(alias = "g_icon_deserialize")] pub fn deserialize(value: &glib::Variant) -> Option { unsafe { from_glib_full(ffi::g_icon_deserialize(value.to_glib_none().0)) } } #[doc(alias = "g_icon_new_for_string")] #[doc(alias = "new_for_string")] pub fn for_string(str: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_icon_new_for_string(str.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait IconExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_icon_equal")] fn equal(&self, icon2: Option<&impl IsA>) -> bool { unsafe { from_glib(ffi::g_icon_equal( self.as_ref().to_glib_none().0, icon2.map(|p| p.as_ref()).to_glib_none().0, )) } } #[doc(alias = "g_icon_hash")] fn hash(&self) -> u32 { unsafe { ffi::g_icon_hash( ToGlibPtr::<*mut ffi::GIcon>::to_glib_none(self.as_ref()).0 as glib::ffi::gconstpointer, ) } } #[doc(alias = "g_icon_serialize")] fn serialize(&self) -> Option { unsafe { from_glib_full(ffi::g_icon_serialize(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_icon_to_string")] fn to_string(&self) -> Option { unsafe { from_glib_full(ffi::g_icon_to_string(self.as_ref().to_glib_none().0)) } } } impl> IconExt for O {} gio-0.20.1/src/auto/inet_address.rs000064400000000000000000000376271046102023000152520ustar 00000000000000// 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::{ffi, SocketFamily}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GInetAddress")] pub struct InetAddress(Object); match fn { type_ => || ffi::g_inet_address_get_type(), } } impl InetAddress { pub const NONE: Option<&'static InetAddress> = None; #[doc(alias = "g_inet_address_new_any")] pub fn new_any(family: SocketFamily) -> InetAddress { unsafe { from_glib_full(ffi::g_inet_address_new_any(family.into_glib())) } } #[doc(alias = "g_inet_address_new_from_string")] #[doc(alias = "new_from_string")] pub fn from_string(string: &str) -> Option { unsafe { from_glib_full(ffi::g_inet_address_new_from_string(string.to_glib_none().0)) } } #[doc(alias = "g_inet_address_new_loopback")] pub fn new_loopback(family: SocketFamily) -> InetAddress { unsafe { from_glib_full(ffi::g_inet_address_new_loopback(family.into_glib())) } } } impl std::fmt::Display for InetAddress { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(&InetAddressExt::to_str(self)) } } unsafe impl Send for InetAddress {} unsafe impl Sync for InetAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InetAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_inet_address_equal")] fn equal(&self, other_address: &impl IsA) -> bool { unsafe { from_glib(ffi::g_inet_address_equal( self.as_ref().to_glib_none().0, other_address.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_inet_address_get_family( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_any")] #[doc(alias = "get_is_any")] #[doc(alias = "is-any")] fn is_any(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_any( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_link_local")] #[doc(alias = "get_is_link_local")] #[doc(alias = "is-link-local")] fn is_link_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_link_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_loopback")] #[doc(alias = "get_is_loopback")] #[doc(alias = "is-loopback")] fn is_loopback(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_loopback( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_mc_global")] #[doc(alias = "get_is_mc_global")] #[doc(alias = "is-mc-global")] fn is_mc_global(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_global( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_mc_link_local")] #[doc(alias = "get_is_mc_link_local")] #[doc(alias = "is-mc-link-local")] fn is_mc_link_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_link_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_mc_node_local")] #[doc(alias = "get_is_mc_node_local")] #[doc(alias = "is-mc-node-local")] fn is_mc_node_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_node_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_mc_org_local")] #[doc(alias = "get_is_mc_org_local")] #[doc(alias = "is-mc-org-local")] fn is_mc_org_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_org_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_mc_site_local")] #[doc(alias = "get_is_mc_site_local")] #[doc(alias = "is-mc-site-local")] fn is_mc_site_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_site_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_multicast")] #[doc(alias = "get_is_multicast")] #[doc(alias = "is-multicast")] fn is_multicast(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_multicast( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_is_site_local")] #[doc(alias = "get_is_site_local")] #[doc(alias = "is-site-local")] fn is_site_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_site_local( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_get_native_size")] #[doc(alias = "get_native_size")] fn native_size(&self) -> usize { unsafe { ffi::g_inet_address_get_native_size(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_inet_address_to_string")] #[doc(alias = "to_string")] fn to_str(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_inet_address_to_string( self.as_ref().to_glib_none().0, )) } } //fn bytes(&self) -> /*Unimplemented*/Basic: Pointer { // ObjectExt::property(self.as_ref(), "bytes") //} #[doc(alias = "is-any")] fn connect_is_any_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_is_any_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-any\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_any_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-link-local")] fn connect_is_link_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_link_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-link-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_link_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-loopback")] fn connect_is_loopback_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_loopback_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-loopback\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_loopback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-mc-global")] fn connect_is_mc_global_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_global_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-global\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_mc_global_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-mc-link-local")] fn connect_is_mc_link_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_link_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-link-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_mc_link_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-mc-node-local")] fn connect_is_mc_node_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_node_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-node-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_mc_node_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-mc-org-local")] fn connect_is_mc_org_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_org_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-org-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_mc_org_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-mc-site-local")] fn connect_is_mc_site_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_mc_site_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-mc-site-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_mc_site_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-multicast")] fn connect_is_multicast_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_multicast_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-multicast\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_multicast_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "is-site-local")] fn connect_is_site_local_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_site_local_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-site-local\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_site_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> InetAddressExt for O {} gio-0.20.1/src/auto/inet_address_mask.rs000064400000000000000000000156531046102023000162600ustar 00000000000000// 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::{ffi, InetAddress, Initable, SocketFamily}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GInetAddressMask")] pub struct InetAddressMask(Object) @implements Initable; match fn { type_ => || ffi::g_inet_address_mask_get_type(), } } impl InetAddressMask { pub const NONE: Option<&'static InetAddressMask> = None; #[doc(alias = "g_inet_address_mask_new")] pub fn new(addr: &impl IsA, length: u32) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_inet_address_mask_new(addr.as_ref().to_glib_none().0, length, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_inet_address_mask_new_from_string")] #[doc(alias = "new_from_string")] pub fn from_string(mask_string: &str) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_inet_address_mask_new_from_string(mask_string.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } impl std::fmt::Display for InetAddressMask { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(&InetAddressMaskExt::to_str(self)) } } unsafe impl Send for InetAddressMask {} unsafe impl Sync for InetAddressMask {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InetAddressMaskExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_inet_address_mask_equal")] fn equal(&self, mask2: &impl IsA) -> bool { unsafe { from_glib(ffi::g_inet_address_mask_equal( self.as_ref().to_glib_none().0, mask2.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_mask_get_address")] #[doc(alias = "get_address")] fn address(&self) -> InetAddress { unsafe { from_glib_none(ffi::g_inet_address_mask_get_address( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_mask_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_inet_address_mask_get_family( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_mask_get_length")] #[doc(alias = "get_length")] fn length(&self) -> u32 { unsafe { ffi::g_inet_address_mask_get_length(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_inet_address_mask_matches")] fn matches(&self, address: &impl IsA) -> bool { unsafe { from_glib(ffi::g_inet_address_mask_matches( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_address_mask_to_string")] #[doc(alias = "to_string")] fn to_str(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_inet_address_mask_to_string( self.as_ref().to_glib_none().0, )) } } fn set_address>(&self, address: Option<&P>) { ObjectExt::set_property(self.as_ref(), "address", address) } fn set_length(&self, length: u32) { ObjectExt::set_property(self.as_ref(), "length", length) } #[doc(alias = "address")] fn connect_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_address_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddressMask, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddressMask::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::address\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddressMask, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddressMask::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "length")] fn connect_length_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_length_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GInetAddressMask, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(InetAddressMask::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::length\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_length_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> InetAddressMaskExt for O {} gio-0.20.1/src/auto/inet_socket_address.rs000064400000000000000000000052351046102023000166100ustar 00000000000000// 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::{ffi, InetAddress, SocketAddress, SocketConnectable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GInetSocketAddress")] pub struct InetSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; match fn { type_ => || ffi::g_inet_socket_address_get_type(), } } impl InetSocketAddress { pub const NONE: Option<&'static InetSocketAddress> = None; #[doc(alias = "g_inet_socket_address_new")] pub fn new(address: &impl IsA, port: u16) -> InetSocketAddress { unsafe { SocketAddress::from_glib_full(ffi::g_inet_socket_address_new( address.as_ref().to_glib_none().0, port, )) .unsafe_cast() } } #[doc(alias = "g_inet_socket_address_new_from_string")] #[doc(alias = "new_from_string")] pub fn from_string(address: &str, port: u32) -> Option { unsafe { Option::::from_glib_full(ffi::g_inet_socket_address_new_from_string( address.to_glib_none().0, port, )) .map(|o| o.unsafe_cast()) } } } unsafe impl Send for InetSocketAddress {} unsafe impl Sync for InetSocketAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InetSocketAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_inet_socket_address_get_address")] #[doc(alias = "get_address")] fn address(&self) -> InetAddress { unsafe { from_glib_none(ffi::g_inet_socket_address_get_address( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_inet_socket_address_get_flowinfo")] #[doc(alias = "get_flowinfo")] fn flowinfo(&self) -> u32 { unsafe { ffi::g_inet_socket_address_get_flowinfo(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_inet_socket_address_get_port")] #[doc(alias = "get_port")] fn port(&self) -> u16 { unsafe { ffi::g_inet_socket_address_get_port(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_inet_socket_address_get_scope_id")] #[doc(alias = "get_scope_id")] #[doc(alias = "scope-id")] fn scope_id(&self) -> u32 { unsafe { ffi::g_inet_socket_address_get_scope_id(self.as_ref().to_glib_none().0) } } } impl> InetSocketAddressExt for O {} gio-0.20.1/src/auto/initable.rs000064400000000000000000000023351046102023000143610ustar 00000000000000// 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::{ffi, Cancellable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GInitable")] pub struct Initable(Interface); match fn { type_ => || ffi::g_initable_get_type(), } } impl Initable { pub const NONE: Option<&'static Initable> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InitableExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_initable_init")] unsafe fn init(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_initable_init( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } impl> InitableExt for O {} gio-0.20.1/src/auto/input_stream.rs000064400000000000000000000263641046102023000153140ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GInputStream")] pub struct InputStream(Object); match fn { type_ => || ffi::g_input_stream_get_type(), } } impl InputStream { pub const NONE: Option<&'static InputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_input_stream_clear_pending")] fn clear_pending(&self) { unsafe { ffi::g_input_stream_clear_pending(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_input_stream_close")] fn close(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_input_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_input_stream_close_async")] fn close_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn close_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_input_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = close_async_trampoline::

; unsafe { ffi::g_input_stream_close_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn close_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.close_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_input_stream_has_pending")] fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_input_stream_has_pending( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_input_stream_is_closed")] fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_input_stream_is_closed( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_input_stream_read_bytes")] fn read_bytes( &self, count: usize, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_input_stream_read_bytes( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.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_input_stream_read_bytes_async")] fn read_bytes_async) + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_bytes_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_input_stream_read_bytes_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = read_bytes_async_trampoline::

; unsafe { ffi::g_input_stream_read_bytes_async( self.as_ref().to_glib_none().0, count, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn read_bytes_future( &self, count: usize, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_bytes_async(count, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_input_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_input_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_input_stream_skip")] fn skip( &self, count: usize, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_input_stream_skip( self.as_ref().to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_input_stream_skip_async")] fn skip_async) + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn skip_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_input_stream_skip_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = skip_async_trampoline::

; unsafe { ffi::g_input_stream_skip_async( self.as_ref().to_glib_none().0, count, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn skip_future( &self, count: usize, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.skip_async(count, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> InputStreamExt for O {} gio-0.20.1/src/auto/io_stream.rs000064400000000000000000000145551046102023000145630ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, InputStream, OutputStream}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GIOStream")] pub struct IOStream(Object); match fn { type_ => || ffi::g_io_stream_get_type(), } } impl IOStream { pub const NONE: Option<&'static IOStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait IOStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_io_stream_clear_pending")] fn clear_pending(&self) { unsafe { ffi::g_io_stream_clear_pending(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_io_stream_close")] fn close(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_io_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_io_stream_close_async")] fn close_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn close_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_io_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = close_async_trampoline::

; unsafe { ffi::g_io_stream_close_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn close_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.close_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_io_stream_get_input_stream")] #[doc(alias = "get_input_stream")] #[doc(alias = "input-stream")] fn input_stream(&self) -> InputStream { unsafe { from_glib_none(ffi::g_io_stream_get_input_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_io_stream_get_output_stream")] #[doc(alias = "get_output_stream")] #[doc(alias = "output-stream")] fn output_stream(&self) -> OutputStream { unsafe { from_glib_none(ffi::g_io_stream_get_output_stream( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_io_stream_has_pending")] fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_io_stream_has_pending(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_io_stream_is_closed")] #[doc(alias = "closed")] fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_io_stream_is_closed(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_io_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_io_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "closed")] fn connect_closed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_closed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GIOStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(IOStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::closed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> IOStreamExt for O {} gio-0.20.1/src/auto/list_model.rs000064400000000000000000000057531046102023000147340ustar 00000000000000// 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::ffi; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GListModel")] pub struct ListModel(Interface); match fn { type_ => || ffi::g_list_model_get_type(), } } impl ListModel { pub const NONE: Option<&'static ListModel> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ListModelExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_list_model_get_item_type")] #[doc(alias = "get_item_type")] fn item_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_list_model_get_item_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_list_model_get_n_items")] #[doc(alias = "get_n_items")] fn n_items(&self) -> u32 { unsafe { ffi::g_list_model_get_n_items(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_list_model_get_object")] #[doc(alias = "get_object")] fn item(&self, position: u32) -> Option { unsafe { from_glib_full(ffi::g_list_model_get_object( self.as_ref().to_glib_none().0, position, )) } } #[doc(alias = "g_list_model_items_changed")] fn items_changed(&self, position: u32, removed: u32, added: u32) { unsafe { ffi::g_list_model_items_changed( self.as_ref().to_glib_none().0, position, removed, added, ); } } #[doc(alias = "items-changed")] fn connect_items_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn items_changed_trampoline< P: IsA, F: Fn(&P, u32, u32, u32) + 'static, >( this: *mut ffi::GListModel, position: libc::c_uint, removed: libc::c_uint, added: libc::c_uint, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( ListModel::from_glib_borrow(this).unsafe_cast_ref(), position, removed, added, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"items-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( items_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ListModelExt for O {} gio-0.20.1/src/auto/list_store.rs000064400000000000000000000062331046102023000147620ustar 00000000000000// 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::{ffi, ListModel}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GListStore")] pub struct ListStore(Object) @implements ListModel; match fn { type_ => || ffi::g_list_store_get_type(), } } impl ListStore { // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`ListStore`] objects. /// /// This method returns an instance of [`ListStoreBuilder`](crate::builders::ListStoreBuilder) which can be used to create [`ListStore`] objects. pub fn builder() -> ListStoreBuilder { ListStoreBuilder::new() } #[doc(alias = "g_list_store_append")] pub fn append(&self, item: &impl IsA) { unsafe { ffi::g_list_store_append(self.to_glib_none().0, item.as_ref().to_glib_none().0); } } #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[doc(alias = "g_list_store_find")] pub fn find(&self, item: &impl IsA) -> Option { unsafe { let mut position = std::mem::MaybeUninit::uninit(); let ret = from_glib(ffi::g_list_store_find( self.to_glib_none().0, item.as_ref().to_glib_none().0, position.as_mut_ptr(), )); if ret { Some(position.assume_init()) } else { None } } } #[doc(alias = "g_list_store_insert")] pub fn insert(&self, position: u32, item: &impl IsA) { unsafe { ffi::g_list_store_insert( self.to_glib_none().0, position, item.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_list_store_remove")] pub fn remove(&self, position: u32) { unsafe { ffi::g_list_store_remove(self.to_glib_none().0, position); } } #[doc(alias = "g_list_store_remove_all")] pub fn remove_all(&self) { unsafe { ffi::g_list_store_remove_all(self.to_glib_none().0); } } } // rustdoc-stripper-ignore-next /// A [builder-pattern] type to construct [`ListStore`] objects. /// /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html #[must_use = "The builder must be built to be used"] pub struct ListStoreBuilder { builder: glib::object::ObjectBuilder<'static, ListStore>, } impl ListStoreBuilder { fn new() -> Self { Self { builder: glib::object::Object::builder(), } } pub fn item_type(self, item_type: glib::types::Type) -> Self { Self { builder: self.builder.property("item-type", item_type), } } // rustdoc-stripper-ignore-next /// Build the [`ListStore`]. #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> ListStore { self.builder.build() } } gio-0.20.1/src/auto/loadable_icon.rs000064400000000000000000000103151046102023000153420ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, Icon, InputStream}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GLoadableIcon")] pub struct LoadableIcon(Interface) @requires Icon; match fn { type_ => || ffi::g_loadable_icon_get_type(), } } impl LoadableIcon { pub const NONE: Option<&'static LoadableIcon> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait LoadableIconExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_loadable_icon_load")] fn load( &self, size: i32, cancellable: Option<&impl IsA>, ) -> Result<(InputStream, glib::GString), glib::Error> { unsafe { let mut type_ = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_loadable_icon_load( self.as_ref().to_glib_none().0, size, &mut type_, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_full(type_))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_loadable_icon_load_async")] fn load_async) + 'static>( &self, size: i32, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn load_async_trampoline< P: FnOnce(Result<(InputStream, glib::GString), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut type_ = std::ptr::null_mut(); let ret = ffi::g_loadable_icon_load_finish( _source_object as *mut _, res, &mut type_, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(type_))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = load_async_trampoline::

; unsafe { ffi::g_loadable_icon_load_async( self.as_ref().to_glib_none().0, size, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn load_future( &self, size: i32, ) -> Pin< Box_< dyn std::future::Future> + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.load_async(size, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> LoadableIconExt for O {} gio-0.20.1/src/auto/memory_input_stream.rs000064400000000000000000000034331046102023000166740ustar 00000000000000// 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::{ffi, InputStream, PollableInputStream, Seekable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GMemoryInputStream")] pub struct MemoryInputStream(Object) @extends InputStream, @implements PollableInputStream, Seekable; match fn { type_ => || ffi::g_memory_input_stream_get_type(), } } impl MemoryInputStream { pub const NONE: Option<&'static MemoryInputStream> = None; #[doc(alias = "g_memory_input_stream_new")] pub fn new() -> MemoryInputStream { unsafe { InputStream::from_glib_full(ffi::g_memory_input_stream_new()).unsafe_cast() } } #[doc(alias = "g_memory_input_stream_new_from_bytes")] #[doc(alias = "new_from_bytes")] pub fn from_bytes(bytes: &glib::Bytes) -> MemoryInputStream { unsafe { InputStream::from_glib_full(ffi::g_memory_input_stream_new_from_bytes( bytes.to_glib_none().0, )) .unsafe_cast() } } } impl Default for MemoryInputStream { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MemoryInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_memory_input_stream_add_bytes")] fn add_bytes(&self, bytes: &glib::Bytes) { unsafe { ffi::g_memory_input_stream_add_bytes( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, ); } } } impl> MemoryInputStreamExt for O {} gio-0.20.1/src/auto/memory_monitor.rs000064400000000000000000000043031046102023000156460ustar 00000000000000// 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::{ffi, Initable, MemoryMonitorWarningLevel}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GMemoryMonitor")] pub struct MemoryMonitor(Interface) @requires Initable; match fn { type_ => || ffi::g_memory_monitor_get_type(), } } impl MemoryMonitor { pub const NONE: Option<&'static MemoryMonitor> = None; #[doc(alias = "g_memory_monitor_dup_default")] pub fn dup_default() -> MemoryMonitor { unsafe { from_glib_full(ffi::g_memory_monitor_dup_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MemoryMonitorExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] #[doc(alias = "low-memory-warning")] fn connect_low_memory_warning( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn low_memory_warning_trampoline< P: IsA, F: Fn(&P, MemoryMonitorWarningLevel) + 'static, >( this: *mut ffi::GMemoryMonitor, level: ffi::GMemoryMonitorWarningLevel, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( MemoryMonitor::from_glib_borrow(this).unsafe_cast_ref(), from_glib(level), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"low-memory-warning\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( low_memory_warning_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MemoryMonitorExt for O {} gio-0.20.1/src/auto/memory_output_stream.rs000064400000000000000000000052501046102023000170740ustar 00000000000000// 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::{ffi, OutputStream, PollableOutputStream, Seekable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GMemoryOutputStream")] pub struct MemoryOutputStream(Object) @extends OutputStream, @implements PollableOutputStream, Seekable; match fn { type_ => || ffi::g_memory_output_stream_get_type(), } } impl MemoryOutputStream { pub const NONE: Option<&'static MemoryOutputStream> = None; #[doc(alias = "g_memory_output_stream_new_resizable")] pub fn new_resizable() -> MemoryOutputStream { unsafe { OutputStream::from_glib_full(ffi::g_memory_output_stream_new_resizable()).unsafe_cast() } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MemoryOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_memory_output_stream_get_data_size")] #[doc(alias = "get_data_size")] #[doc(alias = "data-size")] fn data_size(&self) -> usize { unsafe { ffi::g_memory_output_stream_get_data_size(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_memory_output_stream_steal_as_bytes")] fn steal_as_bytes(&self) -> glib::Bytes { unsafe { from_glib_full(ffi::g_memory_output_stream_steal_as_bytes( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "data-size")] fn connect_data_size_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_data_size_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMemoryOutputStream, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MemoryOutputStream::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::data-size\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_data_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MemoryOutputStreamExt for O {} gio-0.20.1/src/auto/menu.rs000064400000000000000000000116461046102023000135430ustar 00000000000000// 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::{ffi, MenuItem, MenuModel}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GMenu")] pub struct Menu(Object) @extends MenuModel; match fn { type_ => || ffi::g_menu_get_type(), } } impl Menu { #[doc(alias = "g_menu_new")] pub fn new() -> Menu { unsafe { from_glib_full(ffi::g_menu_new()) } } #[doc(alias = "g_menu_append")] pub fn append(&self, label: Option<&str>, detailed_action: Option<&str>) { unsafe { ffi::g_menu_append( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } #[doc(alias = "g_menu_append_item")] pub fn append_item(&self, item: &MenuItem) { unsafe { ffi::g_menu_append_item(self.to_glib_none().0, item.to_glib_none().0); } } #[doc(alias = "g_menu_append_section")] pub fn append_section(&self, label: Option<&str>, section: &impl IsA) { unsafe { ffi::g_menu_append_section( self.to_glib_none().0, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_append_submenu")] pub fn append_submenu(&self, label: Option<&str>, submenu: &impl IsA) { unsafe { ffi::g_menu_append_submenu( self.to_glib_none().0, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_freeze")] pub fn freeze(&self) { unsafe { ffi::g_menu_freeze(self.to_glib_none().0); } } #[doc(alias = "g_menu_insert")] pub fn insert(&self, position: i32, label: Option<&str>, detailed_action: Option<&str>) { unsafe { ffi::g_menu_insert( self.to_glib_none().0, position, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } #[doc(alias = "g_menu_insert_item")] pub fn insert_item(&self, position: i32, item: &MenuItem) { unsafe { ffi::g_menu_insert_item(self.to_glib_none().0, position, item.to_glib_none().0); } } #[doc(alias = "g_menu_insert_section")] pub fn insert_section( &self, position: i32, label: Option<&str>, section: &impl IsA, ) { unsafe { ffi::g_menu_insert_section( self.to_glib_none().0, position, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_insert_submenu")] pub fn insert_submenu( &self, position: i32, label: Option<&str>, submenu: &impl IsA, ) { unsafe { ffi::g_menu_insert_submenu( self.to_glib_none().0, position, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_prepend")] pub fn prepend(&self, label: Option<&str>, detailed_action: Option<&str>) { unsafe { ffi::g_menu_prepend( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } #[doc(alias = "g_menu_prepend_item")] pub fn prepend_item(&self, item: &MenuItem) { unsafe { ffi::g_menu_prepend_item(self.to_glib_none().0, item.to_glib_none().0); } } #[doc(alias = "g_menu_prepend_section")] pub fn prepend_section(&self, label: Option<&str>, section: &impl IsA) { unsafe { ffi::g_menu_prepend_section( self.to_glib_none().0, label.to_glib_none().0, section.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_prepend_submenu")] pub fn prepend_submenu(&self, label: Option<&str>, submenu: &impl IsA) { unsafe { ffi::g_menu_prepend_submenu( self.to_glib_none().0, label.to_glib_none().0, submenu.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_menu_remove")] pub fn remove(&self, position: i32) { unsafe { ffi::g_menu_remove(self.to_glib_none().0, position); } } #[doc(alias = "g_menu_remove_all")] pub fn remove_all(&self) { unsafe { ffi::g_menu_remove_all(self.to_glib_none().0); } } } impl Default for Menu { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/menu_attribute_iter.rs000064400000000000000000000025661046102023000166520ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GMenuAttributeIter")] pub struct MenuAttributeIter(Object); match fn { type_ => || ffi::g_menu_attribute_iter_get_type(), } } impl MenuAttributeIter { pub const NONE: Option<&'static MenuAttributeIter> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MenuAttributeIterExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_menu_attribute_iter_get_next")] #[doc(alias = "get_next")] fn next(&self) -> Option<(glib::GString, glib::Variant)> { unsafe { let mut out_name = std::ptr::null(); let mut value = std::ptr::null_mut(); let ret = from_glib(ffi::g_menu_attribute_iter_get_next( self.as_ref().to_glib_none().0, &mut out_name, &mut value, )); if ret { Some((from_glib_none(out_name), from_glib_full(value))) } else { None } } } } impl> MenuAttributeIterExt for O {} gio-0.20.1/src/auto/menu_item.rs000064400000000000000000000134021046102023000145510ustar 00000000000000// 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::{ffi, Icon, MenuModel}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GMenuItem")] pub struct MenuItem(Object); match fn { type_ => || ffi::g_menu_item_get_type(), } } impl MenuItem { #[doc(alias = "g_menu_item_new")] pub fn new(label: Option<&str>, detailed_action: Option<&str>) -> MenuItem { unsafe { from_glib_full(ffi::g_menu_item_new( label.to_glib_none().0, detailed_action.to_glib_none().0, )) } } #[doc(alias = "g_menu_item_new_from_model")] #[doc(alias = "new_from_model")] pub fn from_model(model: &impl IsA, item_index: i32) -> MenuItem { unsafe { from_glib_full(ffi::g_menu_item_new_from_model( model.as_ref().to_glib_none().0, item_index, )) } } #[doc(alias = "g_menu_item_new_section")] pub fn new_section(label: Option<&str>, section: &impl IsA) -> MenuItem { unsafe { from_glib_full(ffi::g_menu_item_new_section( label.to_glib_none().0, section.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_menu_item_new_submenu")] pub fn new_submenu(label: Option<&str>, submenu: &impl IsA) -> MenuItem { unsafe { from_glib_full(ffi::g_menu_item_new_submenu( label.to_glib_none().0, submenu.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_menu_item_get_attribute")] //#[doc(alias = "get_attribute")] //pub fn is_attribute(&self, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:g_menu_item_get_attribute() } //} #[doc(alias = "g_menu_item_get_attribute_value")] #[doc(alias = "get_attribute_value")] pub fn attribute_value( &self, attribute: &str, expected_type: Option<&glib::VariantTy>, ) -> Option { unsafe { from_glib_full(ffi::g_menu_item_get_attribute_value( self.to_glib_none().0, attribute.to_glib_none().0, expected_type.to_glib_none().0, )) } } #[doc(alias = "g_menu_item_get_link")] #[doc(alias = "get_link")] pub fn link(&self, link: &str) -> Option { unsafe { from_glib_full(ffi::g_menu_item_get_link( self.to_glib_none().0, link.to_glib_none().0, )) } } //#[doc(alias = "g_menu_item_set_action_and_target")] //pub fn set_action_and_target(&self, action: Option<&str>, format_string: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_menu_item_set_action_and_target() } //} #[doc(alias = "g_menu_item_set_action_and_target_value")] pub fn set_action_and_target_value( &self, action: Option<&str>, target_value: Option<&glib::Variant>, ) { unsafe { ffi::g_menu_item_set_action_and_target_value( self.to_glib_none().0, action.to_glib_none().0, target_value.to_glib_none().0, ); } } //#[doc(alias = "g_menu_item_set_attribute")] //pub fn set_attribute(&self, attribute: &str, format_string: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_menu_item_set_attribute() } //} #[doc(alias = "g_menu_item_set_attribute_value")] pub fn set_attribute_value(&self, attribute: &str, value: Option<&glib::Variant>) { unsafe { ffi::g_menu_item_set_attribute_value( self.to_glib_none().0, attribute.to_glib_none().0, value.to_glib_none().0, ); } } #[doc(alias = "g_menu_item_set_detailed_action")] pub fn set_detailed_action(&self, detailed_action: &str) { unsafe { ffi::g_menu_item_set_detailed_action( self.to_glib_none().0, detailed_action.to_glib_none().0, ); } } #[doc(alias = "g_menu_item_set_icon")] pub fn set_icon(&self, icon: &impl IsA) { unsafe { ffi::g_menu_item_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } #[doc(alias = "g_menu_item_set_label")] pub fn set_label(&self, label: Option<&str>) { unsafe { ffi::g_menu_item_set_label(self.to_glib_none().0, label.to_glib_none().0); } } #[doc(alias = "g_menu_item_set_link")] pub fn set_link(&self, link: &str, model: Option<&impl IsA>) { unsafe { ffi::g_menu_item_set_link( self.to_glib_none().0, link.to_glib_none().0, model.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_menu_item_set_section")] pub fn set_section(&self, section: Option<&impl IsA>) { unsafe { ffi::g_menu_item_set_section( self.to_glib_none().0, section.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_menu_item_set_submenu")] pub fn set_submenu(&self, submenu: Option<&impl IsA>) { unsafe { ffi::g_menu_item_set_submenu( self.to_glib_none().0, submenu.map(|p| p.as_ref()).to_glib_none().0, ); } } } gio-0.20.1/src/auto/menu_link_iter.rs000064400000000000000000000024711046102023000155770ustar 00000000000000// 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::{ffi, MenuModel}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GMenuLinkIter")] pub struct MenuLinkIter(Object); match fn { type_ => || ffi::g_menu_link_iter_get_type(), } } impl MenuLinkIter { pub const NONE: Option<&'static MenuLinkIter> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MenuLinkIterExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_menu_link_iter_get_next")] #[doc(alias = "get_next")] fn next(&self) -> Option<(glib::GString, MenuModel)> { unsafe { let mut out_link = std::ptr::null(); let mut value = std::ptr::null_mut(); let ret = from_glib(ffi::g_menu_link_iter_get_next( self.as_ref().to_glib_none().0, &mut out_link, &mut value, )); if ret { Some((from_glib_none(out_link), from_glib_full(value))) } else { None } } } } impl> MenuLinkIterExt for O {} gio-0.20.1/src/auto/menu_model.rs000064400000000000000000000107721046102023000147220ustar 00000000000000// 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::{ffi, MenuAttributeIter, MenuLinkIter}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GMenuModel")] pub struct MenuModel(Object); match fn { type_ => || ffi::g_menu_model_get_type(), } } impl MenuModel { pub const NONE: Option<&'static MenuModel> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MenuModelExt: IsA + sealed::Sealed + 'static { //#[doc(alias = "g_menu_model_get_item_attribute")] //#[doc(alias = "get_item_attribute")] //fn is_item_attribute(&self, item_index: i32, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:g_menu_model_get_item_attribute() } //} #[doc(alias = "g_menu_model_get_item_attribute_value")] #[doc(alias = "get_item_attribute_value")] fn item_attribute_value( &self, item_index: i32, attribute: &str, expected_type: Option<&glib::VariantTy>, ) -> Option { unsafe { from_glib_full(ffi::g_menu_model_get_item_attribute_value( self.as_ref().to_glib_none().0, item_index, attribute.to_glib_none().0, expected_type.to_glib_none().0, )) } } #[doc(alias = "g_menu_model_get_item_link")] #[doc(alias = "get_item_link")] #[must_use] fn item_link(&self, item_index: i32, link: &str) -> Option { unsafe { from_glib_full(ffi::g_menu_model_get_item_link( self.as_ref().to_glib_none().0, item_index, link.to_glib_none().0, )) } } #[doc(alias = "g_menu_model_get_n_items")] #[doc(alias = "get_n_items")] fn n_items(&self) -> i32 { unsafe { ffi::g_menu_model_get_n_items(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_menu_model_is_mutable")] fn is_mutable(&self) -> bool { unsafe { from_glib(ffi::g_menu_model_is_mutable(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_menu_model_items_changed")] fn items_changed(&self, position: i32, removed: i32, added: i32) { unsafe { ffi::g_menu_model_items_changed( self.as_ref().to_glib_none().0, position, removed, added, ); } } #[doc(alias = "g_menu_model_iterate_item_attributes")] fn iterate_item_attributes(&self, item_index: i32) -> MenuAttributeIter { unsafe { from_glib_full(ffi::g_menu_model_iterate_item_attributes( self.as_ref().to_glib_none().0, item_index, )) } } #[doc(alias = "g_menu_model_iterate_item_links")] fn iterate_item_links(&self, item_index: i32) -> MenuLinkIter { unsafe { from_glib_full(ffi::g_menu_model_iterate_item_links( self.as_ref().to_glib_none().0, item_index, )) } } #[doc(alias = "items-changed")] fn connect_items_changed( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn items_changed_trampoline< P: IsA, F: Fn(&P, i32, i32, i32) + 'static, >( this: *mut ffi::GMenuModel, position: libc::c_int, removed: libc::c_int, added: libc::c_int, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( MenuModel::from_glib_borrow(this).unsafe_cast_ref(), position, removed, added, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"items-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( items_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MenuModelExt for O {} gio-0.20.1/src/auto/mod.rs000064400000000000000000000736101046102023000133550ustar 00000000000000// 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 action; pub use self::action::Action; mod action_group; pub use self::action_group::ActionGroup; mod action_map; pub use self::action_map::ActionMap; mod app_info; pub use self::app_info::AppInfo; mod app_info_monitor; pub use self::app_info_monitor::AppInfoMonitor; mod app_launch_context; pub use self::app_launch_context::AppLaunchContext; mod application; pub use self::application::Application; mod application_command_line; pub use self::application_command_line::ApplicationCommandLine; mod async_initable; pub use self::async_initable::AsyncInitable; mod async_result; pub use self::async_result::AsyncResult; mod buffered_input_stream; pub use self::buffered_input_stream::BufferedInputStream; mod buffered_output_stream; pub use self::buffered_output_stream::BufferedOutputStream; mod bytes_icon; pub use self::bytes_icon::BytesIcon; mod cancellable; pub use self::cancellable::Cancellable; mod charset_converter; pub use self::charset_converter::CharsetConverter; mod converter; pub use self::converter::Converter; mod converter_input_stream; pub use self::converter_input_stream::ConverterInputStream; mod converter_output_stream; pub use self::converter_output_stream::ConverterOutputStream; mod credentials; pub use self::credentials::Credentials; mod dbus_action_group; pub use self::dbus_action_group::DBusActionGroup; mod dbus_auth_observer; pub use self::dbus_auth_observer::DBusAuthObserver; mod dbus_connection; pub use self::dbus_connection::DBusConnection; mod dbus_interface; pub use self::dbus_interface::DBusInterface; mod dbus_interface_skeleton; pub use self::dbus_interface_skeleton::DBusInterfaceSkeleton; mod dbus_menu_model; pub use self::dbus_menu_model::DBusMenuModel; mod dbus_message; pub use self::dbus_message::DBusMessage; mod dbus_method_invocation; pub use self::dbus_method_invocation::DBusMethodInvocation; mod dbus_object; pub use self::dbus_object::DBusObject; mod dbus_object_manager; pub use self::dbus_object_manager::DBusObjectManager; mod dbus_proxy; pub use self::dbus_proxy::DBusProxy; mod dbus_server; pub use self::dbus_server::DBusServer; mod data_input_stream; pub use self::data_input_stream::DataInputStream; mod data_output_stream; pub use self::data_output_stream::DataOutputStream; mod datagram_based; pub use self::datagram_based::DatagramBased; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] mod debug_controller; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use self::debug_controller::DebugController; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] mod debug_controller_dbus; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use self::debug_controller_dbus::DebugControllerDBus; #[cfg(all(not(windows), not(target_os = "macos")))] #[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] mod desktop_app_info; #[cfg(all(not(windows), not(target_os = "macos")))] #[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] pub use self::desktop_app_info::DesktopAppInfo; mod drive; pub use self::drive::Drive; mod emblem; pub use self::emblem::Emblem; mod emblemed_icon; pub use self::emblemed_icon::EmblemedIcon; mod file; pub use self::file::File; mod file_enumerator; pub use self::file_enumerator::FileEnumerator; mod file_io_stream; pub use self::file_io_stream::FileIOStream; mod file_icon; pub use self::file_icon::FileIcon; mod file_info; pub use self::file_info::FileInfo; mod file_input_stream; pub use self::file_input_stream::FileInputStream; mod file_monitor; pub use self::file_monitor::FileMonitor; mod file_output_stream; pub use self::file_output_stream::FileOutputStream; mod filename_completer; pub use self::filename_completer::FilenameCompleter; mod filter_input_stream; pub use self::filter_input_stream::FilterInputStream; mod filter_output_stream; pub use self::filter_output_stream::FilterOutputStream; mod io_stream; pub use self::io_stream::IOStream; mod icon; pub use self::icon::Icon; mod inet_address; pub use self::inet_address::InetAddress; mod inet_address_mask; pub use self::inet_address_mask::InetAddressMask; mod inet_socket_address; pub use self::inet_socket_address::InetSocketAddress; mod initable; pub use self::initable::Initable; mod input_stream; pub use self::input_stream::InputStream; mod list_model; pub use self::list_model::ListModel; mod list_store; pub use self::list_store::ListStore; mod loadable_icon; pub use self::loadable_icon::LoadableIcon; mod memory_input_stream; pub use self::memory_input_stream::MemoryInputStream; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] mod memory_monitor; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use self::memory_monitor::MemoryMonitor; mod memory_output_stream; pub use self::memory_output_stream::MemoryOutputStream; mod menu; pub use self::menu::Menu; mod menu_attribute_iter; pub use self::menu_attribute_iter::MenuAttributeIter; mod menu_item; pub use self::menu_item::MenuItem; mod menu_link_iter; pub use self::menu_link_iter::MenuLinkIter; mod menu_model; pub use self::menu_model::MenuModel; mod mount; pub use self::mount::Mount; mod mount_operation; pub use self::mount_operation::MountOperation; mod network_address; pub use self::network_address::NetworkAddress; mod network_monitor; pub use self::network_monitor::NetworkMonitor; mod network_service; pub use self::network_service::NetworkService; mod notification; pub use self::notification::Notification; mod output_stream; pub use self::output_stream::OutputStream; mod permission; pub use self::permission::Permission; mod pollable_input_stream; pub use self::pollable_input_stream::PollableInputStream; mod pollable_output_stream; pub use self::pollable_output_stream::PollableOutputStream; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] mod power_profile_monitor; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] pub use self::power_profile_monitor::PowerProfileMonitor; mod property_action; pub use self::property_action::PropertyAction; mod proxy; pub use self::proxy::Proxy; mod proxy_address; pub use self::proxy_address::ProxyAddress; mod proxy_resolver; pub use self::proxy_resolver::ProxyResolver; mod remote_action_group; pub use self::remote_action_group::RemoteActionGroup; mod resolver; pub use self::resolver::Resolver; mod seekable; pub use self::seekable::Seekable; mod settings; pub use self::settings::Settings; mod settings_backend; pub use self::settings_backend::SettingsBackend; mod simple_action; pub use self::simple_action::SimpleAction; mod simple_action_group; pub use self::simple_action_group::SimpleActionGroup; mod simple_io_stream; pub use self::simple_io_stream::SimpleIOStream; mod simple_permission; pub use self::simple_permission::SimplePermission; mod simple_proxy_resolver; pub use self::simple_proxy_resolver::SimpleProxyResolver; mod socket; pub use self::socket::Socket; mod socket_address; pub use self::socket_address::SocketAddress; mod socket_address_enumerator; pub use self::socket_address_enumerator::SocketAddressEnumerator; mod socket_client; pub use self::socket_client::SocketClient; mod socket_connectable; pub use self::socket_connectable::SocketConnectable; mod socket_connection; pub use self::socket_connection::SocketConnection; mod socket_control_message; pub use self::socket_control_message::SocketControlMessage; mod socket_listener; pub use self::socket_listener::SocketListener; mod socket_service; pub use self::socket_service::SocketService; mod subprocess; pub use self::subprocess::Subprocess; mod subprocess_launcher; pub use self::subprocess_launcher::SubprocessLauncher; mod tcp_connection; pub use self::tcp_connection::TcpConnection; mod themed_icon; pub use self::themed_icon::ThemedIcon; mod threaded_socket_service; pub use self::threaded_socket_service::ThreadedSocketService; mod tls_backend; pub use self::tls_backend::TlsBackend; mod tls_certificate; pub use self::tls_certificate::TlsCertificate; mod tls_client_connection; pub use self::tls_client_connection::TlsClientConnection; mod tls_connection; pub use self::tls_connection::TlsConnection; mod tls_database; pub use self::tls_database::TlsDatabase; mod tls_file_database; pub use self::tls_file_database::TlsFileDatabase; mod tls_interaction; pub use self::tls_interaction::TlsInteraction; mod tls_password; pub use self::tls_password::TlsPassword; mod tls_server_connection; pub use self::tls_server_connection::TlsServerConnection; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_credentials_message; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_credentials_message::UnixCredentialsMessage; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_fd_list; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_fd_list::UnixFDList; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_fd_message; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_fd_message::UnixFDMessage; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_input_stream; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_input_stream::UnixInputStream; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_output_stream; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_output_stream::UnixOutputStream; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_socket_address; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_socket_address::UnixSocketAddress; mod vfs; pub use self::vfs::Vfs; mod volume; pub use self::volume::Volume; mod volume_monitor; pub use self::volume_monitor::VolumeMonitor; mod zlib_compressor; pub use self::zlib_compressor::ZlibCompressor; mod zlib_decompressor; pub use self::zlib_decompressor::ZlibDecompressor; mod dbus_arg_info; pub use self::dbus_arg_info::DBusArgInfo; mod dbus_interface_info; pub use self::dbus_interface_info::DBusInterfaceInfo; mod dbus_method_info; pub use self::dbus_method_info::DBusMethodInfo; mod dbus_node_info; pub use self::dbus_node_info::DBusNodeInfo; mod dbus_property_info; pub use self::dbus_property_info::DBusPropertyInfo; mod dbus_signal_info; pub use self::dbus_signal_info::DBusSignalInfo; mod file_attribute_info_list; pub use self::file_attribute_info_list::FileAttributeInfoList; mod file_attribute_matcher; pub use self::file_attribute_matcher::FileAttributeMatcher; mod resource; pub use self::resource::Resource; mod settings_schema; pub use self::settings_schema::SettingsSchema; mod settings_schema_key; pub use self::settings_schema_key::SettingsSchemaKey; mod settings_schema_source; pub use self::settings_schema_source::SettingsSchemaSource; mod srv_target; pub use self::srv_target::SrvTarget; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_mount_entry; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_mount_entry::UnixMountEntry; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] mod unix_mount_point; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::unix_mount_point::UnixMountPoint; mod enums; pub use self::enums::BusType; pub use self::enums::ConverterResult; pub use self::enums::CredentialsType; pub use self::enums::DBusMessageByteOrder; pub use self::enums::DBusMessageHeaderField; pub use self::enums::DBusMessageType; pub use self::enums::DataStreamByteOrder; pub use self::enums::DataStreamNewlineType; pub use self::enums::DriveStartStopType; pub use self::enums::EmblemOrigin; pub use self::enums::FileAttributeStatus; pub use self::enums::FileAttributeType; pub use self::enums::FileMonitorEvent; pub use self::enums::FileType; pub use self::enums::IOErrorEnum; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use self::enums::MemoryMonitorWarningLevel; pub use self::enums::MountOperationResult; pub use self::enums::NetworkConnectivity; pub use self::enums::NotificationPriority; pub use self::enums::PasswordSave; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::enums::PollableReturn; pub use self::enums::ResolverError; pub use self::enums::ResolverRecordType; pub use self::enums::ResourceError; pub use self::enums::SocketClientEvent; pub use self::enums::SocketFamily; pub use self::enums::SocketListenerEvent; pub use self::enums::SocketProtocol; pub use self::enums::SocketType; pub use self::enums::TlsAuthenticationMode; pub use self::enums::TlsCertificateRequestFlags; #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] pub use self::enums::TlsChannelBindingType; pub use self::enums::TlsDatabaseLookupFlags; pub use self::enums::TlsError; pub use self::enums::TlsInteractionResult; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] pub use self::enums::TlsProtocolVersion; #[allow(deprecated)] pub use self::enums::TlsRehandshakeMode; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use self::enums::UnixSocketAddressType; pub use self::enums::ZlibCompressorFormat; mod flags; pub use self::flags::AppInfoCreateFlags; pub use self::flags::ApplicationFlags; pub use self::flags::AskPasswordFlags; pub use self::flags::BusNameOwnerFlags; pub use self::flags::BusNameWatcherFlags; pub use self::flags::ConverterFlags; pub use self::flags::DBusCallFlags; pub use self::flags::DBusCapabilityFlags; pub use self::flags::DBusConnectionFlags; pub use self::flags::DBusInterfaceSkeletonFlags; pub use self::flags::DBusMessageFlags; pub use self::flags::DBusObjectManagerClientFlags; pub use self::flags::DBusProxyFlags; pub use self::flags::DBusSendMessageFlags; pub use self::flags::DBusServerFlags; pub use self::flags::DBusSignalFlags; pub use self::flags::DriveStartFlags; pub use self::flags::FileAttributeInfoFlags; pub use self::flags::FileCopyFlags; pub use self::flags::FileCreateFlags; pub use self::flags::FileMeasureFlags; pub use self::flags::FileMonitorFlags; pub use self::flags::FileQueryInfoFlags; pub use self::flags::IOStreamSpliceFlags; pub use self::flags::MountMountFlags; pub use self::flags::MountUnmountFlags; pub use self::flags::OutputStreamSpliceFlags; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::flags::ResolverNameLookupFlags; pub use self::flags::ResourceLookupFlags; pub use self::flags::SettingsBindFlags; pub use self::flags::SubprocessFlags; pub use self::flags::TlsCertificateFlags; pub use self::flags::TlsDatabaseVerifyFlags; pub use self::flags::TlsPasswordFlags; pub(crate) mod functions; mod constants; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use self::constants::DEBUG_CONTROLLER_EXTENSION_POINT_NAME; #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] pub use self::constants::DRIVE_IDENTIFIER_KIND_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_DELETE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_READ; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_RENAME; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_TRASH; pub use self::constants::FILE_ATTRIBUTE_ACCESS_CAN_WRITE; pub use self::constants::FILE_ATTRIBUTE_DOS_IS_ARCHIVE; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::constants::FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT; pub use self::constants::FILE_ATTRIBUTE_DOS_IS_SYSTEM; #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] pub use self::constants::FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG; pub use self::constants::FILE_ATTRIBUTE_ETAG_VALUE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_FREE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_READONLY; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_REMOTE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_SIZE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_TYPE; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_USED; pub use self::constants::FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW; pub use self::constants::FILE_ATTRIBUTE_GVFS_BACKEND; pub use self::constants::FILE_ATTRIBUTE_ID_FILE; pub use self::constants::FILE_ATTRIBUTE_ID_FILESYSTEM; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_START; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE; pub use self::constants::FILE_ATTRIBUTE_OWNER_GROUP; pub use self::constants::FILE_ATTRIBUTE_OWNER_USER; pub use self::constants::FILE_ATTRIBUTE_OWNER_USER_REAL; pub use self::constants::FILE_ATTRIBUTE_PREVIEW_ICON; pub use self::constants::FILE_ATTRIBUTE_RECENT_MODIFIED; pub use self::constants::FILE_ATTRIBUTE_SELINUX_CONTEXT; pub use self::constants::FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_COPY_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_DESCRIPTION; pub use self::constants::FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_EDIT_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_ICON; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_BACKUP; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_HIDDEN; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_SYMLINK; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL; pub use self::constants::FILE_ATTRIBUTE_STANDARD_IS_VOLATILE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_NAME; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SIZE; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SORT_ORDER; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON; pub use self::constants::FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET; pub use self::constants::FILE_ATTRIBUTE_STANDARD_TARGET_URI; pub use self::constants::FILE_ATTRIBUTE_STANDARD_TYPE; pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED_LARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED_NORMAL; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED_XLARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAILING_FAILED_XXLARGE; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_LARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_NORMAL; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XLARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID_XXLARGE; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH_LARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH_NORMAL; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH_XLARGE; #[cfg(feature = "v2_76")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_76")))] pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH_XXLARGE; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS_NSEC; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED_NSEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED_NSEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED; #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED_NSEC; pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED_USEC; pub use self::constants::FILE_ATTRIBUTE_TRASH_DELETION_DATE; pub use self::constants::FILE_ATTRIBUTE_TRASH_ITEM_COUNT; pub use self::constants::FILE_ATTRIBUTE_TRASH_ORIG_PATH; pub use self::constants::FILE_ATTRIBUTE_UNIX_BLOCKS; pub use self::constants::FILE_ATTRIBUTE_UNIX_BLOCK_SIZE; pub use self::constants::FILE_ATTRIBUTE_UNIX_DEVICE; pub use self::constants::FILE_ATTRIBUTE_UNIX_GID; pub use self::constants::FILE_ATTRIBUTE_UNIX_INODE; pub use self::constants::FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT; pub use self::constants::FILE_ATTRIBUTE_UNIX_MODE; pub use self::constants::FILE_ATTRIBUTE_UNIX_NLINK; pub use self::constants::FILE_ATTRIBUTE_UNIX_RDEV; pub use self::constants::FILE_ATTRIBUTE_UNIX_UID; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use self::constants::MEMORY_MONITOR_EXTENSION_POINT_NAME; pub use self::constants::MENU_ATTRIBUTE_ACTION; pub use self::constants::MENU_ATTRIBUTE_ACTION_NAMESPACE; pub use self::constants::MENU_ATTRIBUTE_ICON; pub use self::constants::MENU_ATTRIBUTE_LABEL; pub use self::constants::MENU_ATTRIBUTE_TARGET; pub use self::constants::MENU_LINK_SECTION; pub use self::constants::MENU_LINK_SUBMENU; pub use self::constants::NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME; pub use self::constants::NETWORK_MONITOR_EXTENSION_POINT_NAME; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] pub use self::constants::POWER_PROFILE_MONITOR_EXTENSION_POINT_NAME; pub use self::constants::PROXY_EXTENSION_POINT_NAME; pub use self::constants::PROXY_RESOLVER_EXTENSION_POINT_NAME; pub use self::constants::SETTINGS_BACKEND_EXTENSION_POINT_NAME; pub use self::constants::TLS_BACKEND_EXTENSION_POINT_NAME; pub use self::constants::TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT; pub use self::constants::TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER; pub use self::constants::VFS_EXTENSION_POINT_NAME; pub use self::constants::VOLUME_IDENTIFIER_KIND_CLASS; #[allow(deprecated)] pub use self::constants::VOLUME_IDENTIFIER_KIND_HAL_UDI; pub use self::constants::VOLUME_IDENTIFIER_KIND_LABEL; pub use self::constants::VOLUME_IDENTIFIER_KIND_NFS_MOUNT; pub use self::constants::VOLUME_IDENTIFIER_KIND_UNIX_DEVICE; pub use self::constants::VOLUME_IDENTIFIER_KIND_UUID; pub use self::constants::VOLUME_MONITOR_EXTENSION_POINT_NAME; pub(crate) mod traits { pub use super::action::ActionExt; pub use super::action_group::ActionGroupExt; pub use super::action_map::ActionMapExt; pub use super::app_info::AppInfoExt; pub use super::app_launch_context::AppLaunchContextExt; pub use super::application::ApplicationExt; pub use super::application_command_line::ApplicationCommandLineExt; pub use super::async_initable::AsyncInitableExt; pub use super::async_result::AsyncResultExt; pub use super::buffered_input_stream::BufferedInputStreamExt; pub use super::buffered_output_stream::BufferedOutputStreamExt; pub use super::cancellable::CancellableExt; pub use super::converter::ConverterExt; pub use super::converter_input_stream::ConverterInputStreamExt; pub use super::converter_output_stream::ConverterOutputStreamExt; pub use super::data_input_stream::DataInputStreamExt; pub use super::data_output_stream::DataOutputStreamExt; pub use super::datagram_based::DatagramBasedExt; pub use super::dbus_interface::DBusInterfaceExt; pub use super::dbus_interface_skeleton::DBusInterfaceSkeletonExt; pub use super::dbus_object::DBusObjectExt; pub use super::dbus_object_manager::DBusObjectManagerExt; pub use super::dbus_proxy::DBusProxyExt; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use super::debug_controller::DebugControllerExt; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use super::debug_controller_dbus::DebugControllerDBusExt; pub use super::drive::DriveExt; pub use super::emblemed_icon::EmblemedIconExt; pub use super::file::FileExt; pub use super::file_enumerator::FileEnumeratorExt; pub use super::file_input_stream::FileInputStreamExt; pub use super::file_io_stream::FileIOStreamExt; pub use super::file_monitor::FileMonitorExt; pub use super::file_output_stream::FileOutputStreamExt; pub use super::filter_input_stream::FilterInputStreamExt; pub use super::filter_output_stream::FilterOutputStreamExt; pub use super::icon::IconExt; pub use super::inet_address::InetAddressExt; pub use super::inet_address_mask::InetAddressMaskExt; pub use super::inet_socket_address::InetSocketAddressExt; pub use super::initable::InitableExt; pub use super::input_stream::InputStreamExt; pub use super::io_stream::IOStreamExt; pub use super::list_model::ListModelExt; pub use super::loadable_icon::LoadableIconExt; pub use super::memory_input_stream::MemoryInputStreamExt; #[cfg(feature = "v2_64")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_64")))] pub use super::memory_monitor::MemoryMonitorExt; pub use super::memory_output_stream::MemoryOutputStreamExt; pub use super::menu_attribute_iter::MenuAttributeIterExt; pub use super::menu_link_iter::MenuLinkIterExt; pub use super::menu_model::MenuModelExt; pub use super::mount::MountExt; pub use super::mount_operation::MountOperationExt; pub use super::network_address::NetworkAddressExt; pub use super::network_monitor::NetworkMonitorExt; pub use super::network_service::NetworkServiceExt; pub use super::output_stream::OutputStreamExt; pub use super::permission::PermissionExt; pub use super::pollable_input_stream::PollableInputStreamExt; pub use super::pollable_output_stream::PollableOutputStreamExt; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] pub use super::power_profile_monitor::PowerProfileMonitorExt; pub use super::proxy::ProxyExt; pub use super::proxy_address::ProxyAddressExt; pub use super::proxy_resolver::ProxyResolverExt; pub use super::remote_action_group::RemoteActionGroupExt; pub use super::resolver::ResolverExt; pub use super::seekable::SeekableExt; pub use super::settings::SettingsExt; pub use super::settings_backend::SettingsBackendExt; pub use super::simple_proxy_resolver::SimpleProxyResolverExt; pub use super::socket::SocketExt; pub use super::socket_address::SocketAddressExt; pub use super::socket_address_enumerator::SocketAddressEnumeratorExt; pub use super::socket_client::SocketClientExt; pub use super::socket_connectable::SocketConnectableExt; pub use super::socket_connection::SocketConnectionExt; pub use super::socket_control_message::SocketControlMessageExt; pub use super::socket_listener::SocketListenerExt; pub use super::socket_service::SocketServiceExt; pub use super::tcp_connection::TcpConnectionExt; pub use super::threaded_socket_service::ThreadedSocketServiceExt; pub use super::tls_backend::TlsBackendExt; pub use super::tls_certificate::TlsCertificateExt; pub use super::tls_client_connection::TlsClientConnectionExt; pub use super::tls_connection::TlsConnectionExt; pub use super::tls_database::TlsDatabaseExt; pub use super::tls_file_database::TlsFileDatabaseExt; pub use super::tls_interaction::TlsInteractionExt; pub use super::tls_password::TlsPasswordExt; pub use super::tls_server_connection::TlsServerConnectionExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_credentials_message::UnixCredentialsMessageExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_fd_list::UnixFDListExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_fd_message::UnixFDMessageExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_input_stream::UnixInputStreamExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_output_stream::UnixOutputStreamExt; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] pub use super::unix_socket_address::UnixSocketAddressExt; pub use super::vfs::VfsExt; pub use super::volume::VolumeExt; pub use super::volume_monitor::VolumeMonitorExt; } pub(crate) mod builders { pub use super::application::ApplicationBuilder; pub use super::buffered_input_stream::BufferedInputStreamBuilder; pub use super::buffered_output_stream::BufferedOutputStreamBuilder; pub use super::charset_converter::CharsetConverterBuilder; pub use super::converter_input_stream::ConverterInputStreamBuilder; pub use super::converter_output_stream::ConverterOutputStreamBuilder; pub use super::data_input_stream::DataInputStreamBuilder; pub use super::data_output_stream::DataOutputStreamBuilder; pub use super::list_store::ListStoreBuilder; } gio-0.20.1/src/auto/mount.rs000064400000000000000000000436301046102023000137370ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, Drive, File, Icon, MountMountFlags, MountOperation, MountUnmountFlags, Volume, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GMount")] pub struct Mount(Interface); match fn { type_ => || ffi::g_mount_get_type(), } } impl Mount { pub const NONE: Option<&'static Mount> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MountExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_mount_can_eject")] fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_mount_can_eject(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_can_unmount")] fn can_unmount(&self) -> bool { unsafe { from_glib(ffi::g_mount_can_unmount(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_eject_with_operation")] fn eject_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn eject_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_mount_eject_with_operation_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = eject_with_operation_trampoline::

; unsafe { ffi::g_mount_eject_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn eject_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_mount_get_default_location")] #[doc(alias = "get_default_location")] fn default_location(&self) -> File { unsafe { from_glib_full(ffi::g_mount_get_default_location( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_get_drive")] #[doc(alias = "get_drive")] fn drive(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_drive(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_mount_get_icon(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_mount_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_root")] #[doc(alias = "get_root")] fn root(&self) -> File { unsafe { from_glib_full(ffi::g_mount_get_root(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_get_sort_key(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_mount_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_get_uuid")] #[doc(alias = "get_uuid")] fn uuid(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_uuid(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_get_volume")] #[doc(alias = "get_volume")] fn volume(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_volume(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_guess_content_type")] fn guess_content_type, glib::Error>) + 'static>( &self, force_rescan: bool, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn guess_content_type_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_mount_guess_content_type_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = guess_content_type_trampoline::

; unsafe { ffi::g_mount_guess_content_type( self.as_ref().to_glib_none().0, force_rescan.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn guess_content_type_future( &self, force_rescan: bool, ) -> Pin< Box_, glib::Error>> + 'static>, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.guess_content_type(force_rescan, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_mount_guess_content_type_sync")] fn guess_content_type_sync( &self, force_rescan: bool, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_mount_guess_content_type_sync( self.as_ref().to_glib_none().0, force_rescan.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_mount_is_shadowed")] fn is_shadowed(&self) -> bool { unsafe { from_glib(ffi::g_mount_is_shadowed(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_mount_remount")] fn remount) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn remount_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_mount_remount_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = remount_trampoline::

; unsafe { ffi::g_mount_remount( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn remount_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.remount( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_mount_shadow")] fn shadow(&self) { unsafe { ffi::g_mount_shadow(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_mount_unmount_with_operation")] fn unmount_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn unmount_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_mount_unmount_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = unmount_with_operation_trampoline::

; unsafe { ffi::g_mount_unmount_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn unmount_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.unmount_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_mount_unshadow")] fn unshadow(&self) { unsafe { ffi::g_mount_unshadow(self.as_ref().to_glib_none().0); } } #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Mount::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "pre-unmount")] fn connect_pre_unmount(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn pre_unmount_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Mount::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"pre-unmount\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( pre_unmount_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "unmounted")] fn connect_unmounted(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn unmounted_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Mount::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"unmounted\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( unmounted_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MountExt for O {} gio-0.20.1/src/auto/mount_operation.rs000064400000000000000000000514261046102023000160210ustar 00000000000000// 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::{ffi, AskPasswordFlags, MountOperationResult, PasswordSave}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GMountOperation")] pub struct MountOperation(Object); match fn { type_ => || ffi::g_mount_operation_get_type(), } } impl MountOperation { pub const NONE: Option<&'static MountOperation> = None; #[doc(alias = "g_mount_operation_new")] pub fn new() -> MountOperation { unsafe { from_glib_full(ffi::g_mount_operation_new()) } } } impl Default for MountOperation { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait MountOperationExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_mount_operation_get_anonymous")] #[doc(alias = "get_anonymous")] #[doc(alias = "anonymous")] fn is_anonymous(&self) -> bool { unsafe { from_glib(ffi::g_mount_operation_get_anonymous( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_operation_get_choice")] #[doc(alias = "get_choice")] fn choice(&self) -> i32 { unsafe { ffi::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_mount_operation_get_domain")] #[doc(alias = "get_domain")] fn domain(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_domain( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_is_tcrypt_hidden_volume")] #[doc(alias = "get_is_tcrypt_hidden_volume")] #[doc(alias = "is-tcrypt-hidden-volume")] fn is_tcrypt_hidden_volume(&self) -> bool { unsafe { from_glib(ffi::g_mount_operation_get_is_tcrypt_hidden_volume( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_is_tcrypt_system_volume")] #[doc(alias = "get_is_tcrypt_system_volume")] #[doc(alias = "is-tcrypt-system-volume")] fn is_tcrypt_system_volume(&self) -> bool { unsafe { from_glib(ffi::g_mount_operation_get_is_tcrypt_system_volume( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_operation_get_password")] #[doc(alias = "get_password")] fn password(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_password( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_operation_get_password_save")] #[doc(alias = "get_password_save")] #[doc(alias = "password-save")] fn password_save(&self) -> PasswordSave { unsafe { from_glib(ffi::g_mount_operation_get_password_save( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_pim")] #[doc(alias = "get_pim")] fn pim(&self) -> u32 { unsafe { ffi::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_mount_operation_get_username")] #[doc(alias = "get_username")] fn username(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_username( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_mount_operation_reply")] fn reply(&self, result: MountOperationResult) { unsafe { ffi::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.into_glib()); } } #[doc(alias = "g_mount_operation_set_anonymous")] #[doc(alias = "anonymous")] fn set_anonymous(&self, anonymous: bool) { unsafe { ffi::g_mount_operation_set_anonymous( self.as_ref().to_glib_none().0, anonymous.into_glib(), ); } } #[doc(alias = "g_mount_operation_set_choice")] #[doc(alias = "choice")] fn set_choice(&self, choice: i32) { unsafe { ffi::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice); } } #[doc(alias = "g_mount_operation_set_domain")] #[doc(alias = "domain")] fn set_domain(&self, domain: Option<&str>) { unsafe { ffi::g_mount_operation_set_domain( self.as_ref().to_glib_none().0, domain.to_glib_none().0, ); } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_is_tcrypt_hidden_volume")] #[doc(alias = "is-tcrypt-hidden-volume")] fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool) { unsafe { ffi::g_mount_operation_set_is_tcrypt_hidden_volume( self.as_ref().to_glib_none().0, hidden_volume.into_glib(), ); } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_is_tcrypt_system_volume")] #[doc(alias = "is-tcrypt-system-volume")] fn set_is_tcrypt_system_volume(&self, system_volume: bool) { unsafe { ffi::g_mount_operation_set_is_tcrypt_system_volume( self.as_ref().to_glib_none().0, system_volume.into_glib(), ); } } #[doc(alias = "g_mount_operation_set_password")] #[doc(alias = "password")] fn set_password(&self, password: Option<&str>) { unsafe { ffi::g_mount_operation_set_password( self.as_ref().to_glib_none().0, password.to_glib_none().0, ); } } #[doc(alias = "g_mount_operation_set_password_save")] #[doc(alias = "password-save")] fn set_password_save(&self, save: PasswordSave) { unsafe { ffi::g_mount_operation_set_password_save( self.as_ref().to_glib_none().0, save.into_glib(), ); } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_pim")] #[doc(alias = "pim")] fn set_pim(&self, pim: u32) { unsafe { ffi::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim); } } #[doc(alias = "g_mount_operation_set_username")] #[doc(alias = "username")] fn set_username(&self, username: Option<&str>) { unsafe { ffi::g_mount_operation_set_username( self.as_ref().to_glib_none().0, username.to_glib_none().0, ); } } #[doc(alias = "aborted")] fn connect_aborted(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn aborted_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GMountOperation, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"aborted\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( aborted_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "ask-password")] fn connect_ask_password( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn ask_password_trampoline< P: IsA, F: Fn(&P, &str, &str, &str, AskPasswordFlags) + 'static, >( this: *mut ffi::GMountOperation, message: *mut libc::c_char, default_user: *mut libc::c_char, default_domain: *mut libc::c_char, flags: ffi::GAskPasswordFlags, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( MountOperation::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(message), &glib::GString::from_glib_borrow(default_user), &glib::GString::from_glib_borrow(default_domain), from_glib(flags), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"ask-password\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( ask_password_trampoline:: as *const (), )), Box_::into_raw(f), ) } } //#[doc(alias = "ask-question")] //fn connect_ask_question(&self, f: F) -> SignalHandlerId { // Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 } //} #[doc(alias = "reply")] fn connect_reply(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn reply_trampoline< P: IsA, F: Fn(&P, MountOperationResult) + 'static, >( this: *mut ffi::GMountOperation, result: ffi::GMountOperationResult, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( MountOperation::from_glib_borrow(this).unsafe_cast_ref(), from_glib(result), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"reply\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( reply_trampoline:: as *const (), )), Box_::into_raw(f), ) } } //#[doc(alias = "show-processes")] //fn connect_show_processes(&self, f: F) -> SignalHandlerId { // Empty ctype processes: *.Array TypeId { ns_id: 2, id: 4 } // Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 } //} #[doc(alias = "show-unmount-progress")] fn connect_show_unmount_progress( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn show_unmount_progress_trampoline< P: IsA, F: Fn(&P, &str, i64, i64) + 'static, >( this: *mut ffi::GMountOperation, message: *mut libc::c_char, time_left: i64, bytes_left: i64, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( MountOperation::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(message), time_left, bytes_left, ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"show-unmount-progress\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( show_unmount_progress_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "anonymous")] fn connect_anonymous_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_anonymous_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::anonymous\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_anonymous_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "choice")] fn connect_choice_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_choice_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::choice\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_choice_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "domain")] fn connect_domain_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_domain_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::domain\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_domain_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "is-tcrypt-hidden-volume")] fn connect_is_tcrypt_hidden_volume_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_tcrypt_hidden_volume_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-tcrypt-hidden-volume\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_tcrypt_hidden_volume_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "is-tcrypt-system-volume")] fn connect_is_tcrypt_system_volume_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_is_tcrypt_system_volume_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::is-tcrypt-system-volume\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_is_tcrypt_system_volume_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "password")] fn connect_password_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_password_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::password\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_password_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "password-save")] fn connect_password_save_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_password_save_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::password-save\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_password_save_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "pim")] fn connect_pim_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_pim_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::pim\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_pim_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "username")] fn connect_username_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_username_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GMountOperation, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(MountOperation::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::username\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_username_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> MountOperationExt for O {} gio-0.20.1/src/auto/network_address.rs000064400000000000000000000060331046102023000157670ustar 00000000000000// 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::{ffi, SocketConnectable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GNetworkAddress")] pub struct NetworkAddress(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_network_address_get_type(), } } impl NetworkAddress { pub const NONE: Option<&'static NetworkAddress> = None; #[doc(alias = "g_network_address_new")] pub fn new(hostname: &str, port: u16) -> NetworkAddress { unsafe { from_glib_full(ffi::g_network_address_new(hostname.to_glib_none().0, port)) } } #[doc(alias = "g_network_address_new_loopback")] pub fn new_loopback(port: u16) -> NetworkAddress { unsafe { from_glib_full(ffi::g_network_address_new_loopback(port)) } } #[doc(alias = "g_network_address_parse")] pub fn parse(host_and_port: &str, default_port: u16) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_network_address_parse( host_and_port.to_glib_none().0, default_port, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_network_address_parse_uri")] pub fn parse_uri(uri: &str, default_port: u16) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_network_address_parse_uri(uri.to_glib_none().0, default_port, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } unsafe impl Send for NetworkAddress {} unsafe impl Sync for NetworkAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait NetworkAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_network_address_get_hostname")] #[doc(alias = "get_hostname")] fn hostname(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_address_get_hostname( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_address_get_port")] #[doc(alias = "get_port")] fn port(&self) -> u16 { unsafe { ffi::g_network_address_get_port(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_network_address_get_scheme")] #[doc(alias = "get_scheme")] fn scheme(&self) -> Option { unsafe { from_glib_none(ffi::g_network_address_get_scheme( self.as_ref().to_glib_none().0, )) } } } impl> NetworkAddressExt for O {} gio-0.20.1/src/auto/network_monitor.rs000064400000000000000000000225661046102023000160420ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, Initable, NetworkConnectivity, SocketConnectable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GNetworkMonitor")] pub struct NetworkMonitor(Interface) @requires Initable; match fn { type_ => || ffi::g_network_monitor_get_type(), } } impl NetworkMonitor { pub const NONE: Option<&'static NetworkMonitor> = None; #[doc(alias = "g_network_monitor_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> NetworkMonitor { unsafe { from_glib_none(ffi::g_network_monitor_get_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait NetworkMonitorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_network_monitor_can_reach")] fn can_reach( &self, connectable: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_network_monitor_can_reach( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_network_monitor_can_reach_async")] fn can_reach_async) + 'static>( &self, connectable: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn can_reach_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_network_monitor_can_reach_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = can_reach_async_trampoline::

; unsafe { ffi::g_network_monitor_can_reach_async( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn can_reach_future( &self, connectable: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let connectable = connectable.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.can_reach_async(&connectable, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_network_monitor_get_connectivity")] #[doc(alias = "get_connectivity")] fn connectivity(&self) -> NetworkConnectivity { unsafe { from_glib(ffi::g_network_monitor_get_connectivity( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_monitor_get_network_available")] #[doc(alias = "get_network_available")] #[doc(alias = "network-available")] fn is_network_available(&self) -> bool { unsafe { from_glib(ffi::g_network_monitor_get_network_available( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_monitor_get_network_metered")] #[doc(alias = "get_network_metered")] #[doc(alias = "network-metered")] fn is_network_metered(&self) -> bool { unsafe { from_glib(ffi::g_network_monitor_get_network_metered( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "network-changed")] fn connect_network_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn network_changed_trampoline< P: IsA, F: Fn(&P, bool) + 'static, >( this: *mut ffi::GNetworkMonitor, network_available: glib::ffi::gboolean, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( NetworkMonitor::from_glib_borrow(this).unsafe_cast_ref(), from_glib(network_available), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"network-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( network_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "connectivity")] fn connect_connectivity_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_connectivity_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GNetworkMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(NetworkMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::connectivity\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_connectivity_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "network-available")] fn connect_network_available_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_network_available_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GNetworkMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(NetworkMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::network-available\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_network_available_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "network-metered")] fn connect_network_metered_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_network_metered_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GNetworkMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(NetworkMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::network-metered\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_network_metered_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> NetworkMonitorExt for O {} gio-0.20.1/src/auto/network_service.rs000064400000000000000000000070351046102023000160050ustar 00000000000000// 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::{ffi, SocketConnectable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GNetworkService")] pub struct NetworkService(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_network_service_get_type(), } } impl NetworkService { pub const NONE: Option<&'static NetworkService> = None; #[doc(alias = "g_network_service_new")] pub fn new(service: &str, protocol: &str, domain: &str) -> NetworkService { unsafe { from_glib_full(ffi::g_network_service_new( service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait NetworkServiceExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_network_service_get_domain")] #[doc(alias = "get_domain")] fn domain(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_domain( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_service_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_protocol( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_service_get_scheme")] #[doc(alias = "get_scheme")] fn scheme(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_scheme( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_service_get_service")] #[doc(alias = "get_service")] fn service(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_service( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_network_service_set_scheme")] #[doc(alias = "scheme")] fn set_scheme(&self, scheme: &str) { unsafe { ffi::g_network_service_set_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, ); } } #[doc(alias = "scheme")] fn connect_scheme_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_scheme_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GNetworkService, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(NetworkService::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::scheme\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_scheme_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> NetworkServiceExt for O {} gio-0.20.1/src/auto/notification.rs000064400000000000000000000076651046102023000152730ustar 00000000000000// 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::{ffi, Icon, NotificationPriority}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GNotification")] pub struct Notification(Object); match fn { type_ => || ffi::g_notification_get_type(), } } impl Notification { #[doc(alias = "g_notification_new")] pub fn new(title: &str) -> Notification { unsafe { from_glib_full(ffi::g_notification_new(title.to_glib_none().0)) } } #[doc(alias = "g_notification_add_button")] pub fn add_button(&self, label: &str, detailed_action: &str) { unsafe { ffi::g_notification_add_button( self.to_glib_none().0, label.to_glib_none().0, detailed_action.to_glib_none().0, ); } } //#[doc(alias = "g_notification_add_button_with_target")] //pub fn add_button_with_target(&self, label: &str, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_notification_add_button_with_target() } //} #[doc(alias = "g_notification_add_button_with_target_value")] pub fn add_button_with_target_value( &self, label: &str, action: &str, target: Option<&glib::Variant>, ) { unsafe { ffi::g_notification_add_button_with_target_value( self.to_glib_none().0, label.to_glib_none().0, action.to_glib_none().0, target.to_glib_none().0, ); } } #[doc(alias = "g_notification_set_body")] pub fn set_body(&self, body: Option<&str>) { unsafe { ffi::g_notification_set_body(self.to_glib_none().0, body.to_glib_none().0); } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_notification_set_category")] pub fn set_category(&self, category: Option<&str>) { unsafe { ffi::g_notification_set_category(self.to_glib_none().0, category.to_glib_none().0); } } #[doc(alias = "g_notification_set_default_action")] pub fn set_default_action(&self, detailed_action: &str) { unsafe { ffi::g_notification_set_default_action( self.to_glib_none().0, detailed_action.to_glib_none().0, ); } } //#[doc(alias = "g_notification_set_default_action_and_target")] //pub fn set_default_action_and_target(&self, action: &str, target_format: Option<&str>, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_notification_set_default_action_and_target() } //} #[doc(alias = "g_notification_set_default_action_and_target_value")] pub fn set_default_action_and_target_value( &self, action: &str, target: Option<&glib::Variant>, ) { unsafe { ffi::g_notification_set_default_action_and_target_value( self.to_glib_none().0, action.to_glib_none().0, target.to_glib_none().0, ); } } #[doc(alias = "g_notification_set_icon")] pub fn set_icon(&self, icon: &impl IsA) { unsafe { ffi::g_notification_set_icon(self.to_glib_none().0, icon.as_ref().to_glib_none().0); } } #[doc(alias = "g_notification_set_priority")] pub fn set_priority(&self, priority: NotificationPriority) { unsafe { ffi::g_notification_set_priority(self.to_glib_none().0, priority.into_glib()); } } #[doc(alias = "g_notification_set_title")] pub fn set_title(&self, title: &str) { unsafe { ffi::g_notification_set_title(self.to_glib_none().0, title.to_glib_none().0); } } } gio-0.20.1/src/auto/output_stream.rs000064400000000000000000000404541046102023000155110ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, InputStream, OutputStreamSpliceFlags}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GOutputStream")] pub struct OutputStream(Object); match fn { type_ => || ffi::g_output_stream_get_type(), } } impl OutputStream { pub const NONE: Option<&'static OutputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait OutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_output_stream_clear_pending")] fn clear_pending(&self) { unsafe { ffi::g_output_stream_clear_pending(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_output_stream_close")] fn close(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_output_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_close_async")] fn close_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn close_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_output_stream_close_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = close_async_trampoline::

; unsafe { ffi::g_output_stream_close_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn close_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.close_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_output_stream_flush")] fn flush(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_output_stream_flush( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_flush_async")] fn flush_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn flush_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_output_stream_flush_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = flush_async_trampoline::

; unsafe { ffi::g_output_stream_flush_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn flush_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.flush_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_output_stream_has_pending")] fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_has_pending( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_output_stream_is_closed")] fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_is_closed( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_output_stream_is_closing")] fn is_closing(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_is_closing( self.as_ref().to_glib_none().0, )) } } //#[doc(alias = "g_output_stream_printf")] //fn printf(&self, cancellable: Option<&impl IsA>, error: &mut glib::Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Option { // unsafe { TODO: call ffi:g_output_stream_printf() } //} #[doc(alias = "g_output_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_output_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_splice")] fn splice( &self, source: &impl IsA, flags: OutputStreamSpliceFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_output_stream_splice( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_splice_async")] fn splice_async) + 'static>( &self, source: &impl IsA, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn splice_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_output_stream_splice_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = splice_async_trampoline::

; unsafe { ffi::g_output_stream_splice_async( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn splice_future( &self, source: &(impl IsA + Clone + 'static), flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let source = source.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.splice_async(&source, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } //#[doc(alias = "g_output_stream_vprintf")] //fn vprintf(&self, cancellable: Option<&impl IsA>, error: &mut glib::Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option { // unsafe { TODO: call ffi:g_output_stream_vprintf() } //} #[doc(alias = "g_output_stream_write")] fn write( &self, buffer: &[u8], cancellable: Option<&impl IsA>, ) -> Result { let count = buffer.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_output_stream_write( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_write_bytes")] fn write_bytes( &self, bytes: &glib::Bytes, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_output_stream_write_bytes( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_write_bytes_async")] fn write_bytes_async) + 'static>( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn write_bytes_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_output_stream_write_bytes_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = write_bytes_async_trampoline::

; unsafe { ffi::g_output_stream_write_bytes_async( self.as_ref().to_glib_none().0, bytes.to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn write_bytes_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Pin> + 'static>> { let bytes = bytes.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.write_bytes_async(&bytes, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> OutputStreamExt for O {} gio-0.20.1/src/auto/permission.rs000064400000000000000000000251721046102023000147660ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GPermission")] pub struct Permission(Object); match fn { type_ => || ffi::g_permission_get_type(), } } impl Permission { pub const NONE: Option<&'static Permission> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PermissionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_permission_acquire")] fn acquire(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_permission_acquire( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_permission_acquire_async")] fn acquire_async) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn acquire_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_permission_acquire_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = acquire_async_trampoline::

; unsafe { ffi::g_permission_acquire_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn acquire_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.acquire_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_permission_get_allowed")] #[doc(alias = "get_allowed")] #[doc(alias = "allowed")] fn is_allowed(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_allowed( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_permission_get_can_acquire")] #[doc(alias = "get_can_acquire")] #[doc(alias = "can-acquire")] fn can_acquire(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_can_acquire( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_permission_get_can_release")] #[doc(alias = "get_can_release")] #[doc(alias = "can-release")] fn can_release(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_can_release( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_permission_impl_update")] fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool) { unsafe { ffi::g_permission_impl_update( self.as_ref().to_glib_none().0, allowed.into_glib(), can_acquire.into_glib(), can_release.into_glib(), ); } } #[doc(alias = "g_permission_release")] fn release(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_permission_release( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_permission_release_async")] fn release_async) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn release_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_permission_release_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = release_async_trampoline::

; unsafe { ffi::g_permission_release_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn release_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.release_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "allowed")] fn connect_allowed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_allowed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GPermission, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Permission::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::allowed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_allowed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "can-acquire")] fn connect_can_acquire_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_can_acquire_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GPermission, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Permission::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::can-acquire\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_can_acquire_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "can-release")] fn connect_can_release_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_can_release_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GPermission, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Permission::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::can-release\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_can_release_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> PermissionExt for O {} gio-0.20.1/src/auto/pollable_input_stream.rs000064400000000000000000000025021046102023000171520ustar 00000000000000// 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::{ffi, InputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GPollableInputStream")] pub struct PollableInputStream(Interface) @requires InputStream; match fn { type_ => || ffi::g_pollable_input_stream_get_type(), } } impl PollableInputStream { pub const NONE: Option<&'static PollableInputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PollableInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_pollable_input_stream_can_poll")] fn can_poll(&self) -> bool { unsafe { from_glib(ffi::g_pollable_input_stream_can_poll( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_pollable_input_stream_is_readable")] fn is_readable(&self) -> bool { unsafe { from_glib(ffi::g_pollable_input_stream_is_readable( self.as_ref().to_glib_none().0, )) } } } impl> PollableInputStreamExt for O {} gio-0.20.1/src/auto/pollable_output_stream.rs000064400000000000000000000041431046102023000173560ustar 00000000000000// 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::{ffi, Cancellable, OutputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GPollableOutputStream")] pub struct PollableOutputStream(Interface) @requires OutputStream; match fn { type_ => || ffi::g_pollable_output_stream_get_type(), } } impl PollableOutputStream { pub const NONE: Option<&'static PollableOutputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PollableOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_pollable_output_stream_can_poll")] fn can_poll(&self) -> bool { unsafe { from_glib(ffi::g_pollable_output_stream_can_poll( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_pollable_output_stream_is_writable")] fn is_writable(&self) -> bool { unsafe { from_glib(ffi::g_pollable_output_stream_is_writable( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_pollable_output_stream_write_nonblocking")] fn write_nonblocking( &self, buffer: &[u8], cancellable: Option<&impl IsA>, ) -> Result { let count = buffer.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_pollable_output_stream_write_nonblocking( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } } impl> PollableOutputStreamExt for O {} gio-0.20.1/src/auto/power_profile_monitor.rs000064400000000000000000000051011046102023000172070ustar 00000000000000// 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::{ffi, Initable}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GPowerProfileMonitor")] pub struct PowerProfileMonitor(Interface) @requires Initable; match fn { type_ => || ffi::g_power_profile_monitor_get_type(), } } impl PowerProfileMonitor { pub const NONE: Option<&'static PowerProfileMonitor> = None; #[doc(alias = "g_power_profile_monitor_dup_default")] #[doc(alias = "dup_default")] pub fn get_default() -> PowerProfileMonitor { unsafe { from_glib_full(ffi::g_power_profile_monitor_dup_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PowerProfileMonitorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_power_profile_monitor_get_power_saver_enabled")] #[doc(alias = "get_power_saver_enabled")] #[doc(alias = "power-saver-enabled")] fn is_power_saver_enabled(&self) -> bool { unsafe { from_glib(ffi::g_power_profile_monitor_get_power_saver_enabled( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "power-saver-enabled")] fn connect_power_saver_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_power_saver_enabled_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GPowerProfileMonitor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(PowerProfileMonitor::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::power-saver-enabled\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_power_saver_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> PowerProfileMonitorExt for O {} gio-0.20.1/src/auto/property_action.rs000064400000000000000000000017071046102023000160150ustar 00000000000000// 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::{ffi, Action}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GPropertyAction")] pub struct PropertyAction(Object) @implements Action; match fn { type_ => || ffi::g_property_action_get_type(), } } impl PropertyAction { #[doc(alias = "g_property_action_new")] pub fn new(name: &str, object: &impl IsA, property_name: &str) -> PropertyAction { unsafe { from_glib_full(ffi::g_property_action_new( name.to_glib_none().0, object.as_ref().to_glib_none().0, property_name.to_glib_none().0, )) } } #[doc(alias = "invert-boolean")] pub fn inverts_boolean(&self) -> bool { ObjectExt::property(self, "invert-boolean") } } gio-0.20.1/src/auto/proxy.rs000064400000000000000000000114631046102023000137550ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, IOStream, ProxyAddress}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GProxy")] pub struct Proxy(Interface); match fn { type_ => || ffi::g_proxy_get_type(), } } impl Proxy { pub const NONE: Option<&'static Proxy> = None; #[doc(alias = "g_proxy_get_default_for_protocol")] #[doc(alias = "get_default_for_protocol")] pub fn default_for_protocol(protocol: &str) -> Option { unsafe { from_glib_full(ffi::g_proxy_get_default_for_protocol( protocol.to_glib_none().0, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ProxyExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_proxy_connect")] fn connect( &self, connection: &impl IsA, proxy_address: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_proxy_connect( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, proxy_address.as_ref().to_glib_none().0, cancellable.map(|p| p.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_proxy_connect_async")] fn connect_async) + 'static>( &self, connection: &impl IsA, proxy_address: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_proxy_connect_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_async_trampoline::

; unsafe { ffi::g_proxy_connect_async( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, proxy_address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_future( &self, connection: &(impl IsA + Clone + 'static), proxy_address: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let connection = connection.clone(); let proxy_address = proxy_address.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_async(&connection, &proxy_address, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_proxy_supports_hostname")] fn supports_hostname(&self) -> bool { unsafe { from_glib(ffi::g_proxy_supports_hostname( self.as_ref().to_glib_none().0, )) } } } impl> ProxyExt for O {} gio-0.20.1/src/auto/proxy_address.rs000064400000000000000000000073001046102023000154550ustar 00000000000000// 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::{ffi, InetAddress, InetSocketAddress, SocketAddress, SocketConnectable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GProxyAddress")] pub struct ProxyAddress(Object) @extends InetSocketAddress, SocketAddress, @implements SocketConnectable; match fn { type_ => || ffi::g_proxy_address_get_type(), } } impl ProxyAddress { pub const NONE: Option<&'static ProxyAddress> = None; #[doc(alias = "g_proxy_address_new")] pub fn new( inetaddr: &impl IsA, port: u16, protocol: &str, dest_hostname: &str, dest_port: u16, username: Option<&str>, password: Option<&str>, ) -> ProxyAddress { unsafe { SocketAddress::from_glib_full(ffi::g_proxy_address_new( inetaddr.as_ref().to_glib_none().0, port, protocol.to_glib_none().0, dest_hostname.to_glib_none().0, dest_port, username.to_glib_none().0, password.to_glib_none().0, )) .unsafe_cast() } } } unsafe impl Send for ProxyAddress {} unsafe impl Sync for ProxyAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ProxyAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_proxy_address_get_destination_hostname")] #[doc(alias = "get_destination_hostname")] #[doc(alias = "destination-hostname")] fn destination_hostname(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_destination_hostname( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_proxy_address_get_destination_port")] #[doc(alias = "get_destination_port")] #[doc(alias = "destination-port")] fn destination_port(&self) -> u16 { unsafe { ffi::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_proxy_address_get_destination_protocol")] #[doc(alias = "get_destination_protocol")] #[doc(alias = "destination-protocol")] fn destination_protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_destination_protocol( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_proxy_address_get_password")] #[doc(alias = "get_password")] fn password(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_password( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_proxy_address_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_protocol( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_proxy_address_get_uri")] #[doc(alias = "get_uri")] fn uri(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_uri(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_proxy_address_get_username")] #[doc(alias = "get_username")] fn username(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_username( self.as_ref().to_glib_none().0, )) } } } impl> ProxyAddressExt for O {} gio-0.20.1/src/auto/proxy_resolver.rs000064400000000000000000000107471046102023000157020ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GProxyResolver")] pub struct ProxyResolver(Interface); match fn { type_ => || ffi::g_proxy_resolver_get_type(), } } impl ProxyResolver { pub const NONE: Option<&'static ProxyResolver> = None; #[doc(alias = "g_proxy_resolver_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> ProxyResolver { unsafe { from_glib_none(ffi::g_proxy_resolver_get_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ProxyResolverExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_proxy_resolver_is_supported")] fn is_supported(&self) -> bool { unsafe { from_glib(ffi::g_proxy_resolver_is_supported( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_proxy_resolver_lookup")] fn lookup( &self, uri: &str, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_proxy_resolver_lookup( self.as_ref().to_glib_none().0, uri.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_proxy_resolver_lookup_async")] fn lookup_async, glib::Error>) + 'static>( &self, uri: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_proxy_resolver_lookup_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_async_trampoline::

; unsafe { ffi::g_proxy_resolver_lookup_async( self.as_ref().to_glib_none().0, uri.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_future( &self, uri: &str, ) -> Pin< Box_, glib::Error>> + 'static>, > { let uri = String::from(uri); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_async(&uri, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> ProxyResolverExt for O {} gio-0.20.1/src/auto/remote_action_group.rs000064400000000000000000000035051046102023000166360ustar 00000000000000// 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::{ffi, ActionGroup}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GRemoteActionGroup")] pub struct RemoteActionGroup(Interface) @requires ActionGroup; match fn { type_ => || ffi::g_remote_action_group_get_type(), } } impl RemoteActionGroup { pub const NONE: Option<&'static RemoteActionGroup> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait RemoteActionGroupExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_remote_action_group_activate_action_full")] fn activate_action_full( &self, action_name: &str, parameter: Option<&glib::Variant>, platform_data: &glib::Variant, ) { unsafe { ffi::g_remote_action_group_activate_action_full( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, parameter.to_glib_none().0, platform_data.to_glib_none().0, ); } } #[doc(alias = "g_remote_action_group_change_action_state_full")] fn change_action_state_full( &self, action_name: &str, value: &glib::Variant, platform_data: &glib::Variant, ) { unsafe { ffi::g_remote_action_group_change_action_state_full( self.as_ref().to_glib_none().0, action_name.to_glib_none().0, value.to_glib_none().0, platform_data.to_glib_none().0, ); } } } impl> RemoteActionGroupExt for O {} gio-0.20.1/src/auto/resolver.rs000064400000000000000000000537401046102023000144410ustar 00000000000000// 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_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] use crate::ResolverNameLookupFlags; use crate::{ffi, AsyncResult, Cancellable, InetAddress, ResolverRecordType, SrvTarget}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GResolver")] pub struct Resolver(Object); match fn { type_ => || ffi::g_resolver_get_type(), } } impl Resolver { pub const NONE: Option<&'static Resolver> = None; //#[doc(alias = "g_resolver_free_addresses")] //pub fn free_addresses(addresses: /*Unimplemented*/&[&Basic: Pointer]) { // unsafe { TODO: call ffi:g_resolver_free_addresses() } //} //#[doc(alias = "g_resolver_free_targets")] //pub fn free_targets(targets: /*Unimplemented*/&[&Basic: Pointer]) { // unsafe { TODO: call ffi:g_resolver_free_targets() } //} #[doc(alias = "g_resolver_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> Resolver { unsafe { from_glib_full(ffi::g_resolver_get_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ResolverExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "g_resolver_get_timeout")] #[doc(alias = "get_timeout")] fn timeout(&self) -> u32 { unsafe { ffi::g_resolver_get_timeout(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_resolver_lookup_by_address")] fn lookup_by_address( &self, address: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_address( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.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_resolver_lookup_by_address_async")] fn lookup_by_address_async) + 'static>( &self, address: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_by_address_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_address_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_by_address_async_trampoline::

; unsafe { ffi::g_resolver_lookup_by_address_async( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_by_address_future( &self, address: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let address = address.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_by_address_async(&address, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_resolver_lookup_by_name")] fn lookup_by_name( &self, hostname: &str, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_name( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resolver_lookup_by_name_async")] fn lookup_by_name_async, glib::Error>) + 'static>( &self, hostname: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_by_name_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_name_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_by_name_async_trampoline::

; unsafe { ffi::g_resolver_lookup_by_name_async( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_by_name_future( &self, hostname: &str, ) -> Pin, glib::Error>> + 'static>> { let hostname = String::from(hostname); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_by_name_async(&hostname, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_resolver_lookup_by_name_with_flags")] fn lookup_by_name_with_flags( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_name_with_flags( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_resolver_lookup_by_name_with_flags_async")] fn lookup_by_name_with_flags_async< P: FnOnce(Result, glib::Error>) + 'static, >( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_by_name_with_flags_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_by_name_with_flags_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_by_name_with_flags_async_trampoline::

; unsafe { ffi::g_resolver_lookup_by_name_with_flags_async( self.as_ref().to_glib_none().0, hostname.to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn lookup_by_name_with_flags_future( &self, hostname: &str, flags: ResolverNameLookupFlags, ) -> Pin, glib::Error>> + 'static>> { let hostname = String::from(hostname); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_by_name_with_flags_async( &hostname, flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_resolver_lookup_records")] fn lookup_records( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_records( self.as_ref().to_glib_none().0, rrname.to_glib_none().0, record_type.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resolver_lookup_records_async")] fn lookup_records_async, glib::Error>) + 'static>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_records_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_records_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_records_async_trampoline::

; unsafe { ffi::g_resolver_lookup_records_async( self.as_ref().to_glib_none().0, rrname.to_glib_none().0, record_type.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_records_future( &self, rrname: &str, record_type: ResolverRecordType, ) -> Pin< Box_, glib::Error>> + 'static>, > { let rrname = String::from(rrname); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_records_async(&rrname, record_type, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_resolver_lookup_service")] fn lookup_service( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_service( self.as_ref().to_glib_none().0, service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resolver_lookup_service_async")] fn lookup_service_async, glib::Error>) + 'static>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_service_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_resolver_lookup_service_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_service_async_trampoline::

; unsafe { ffi::g_resolver_lookup_service_async( self.as_ref().to_glib_none().0, service.to_glib_none().0, protocol.to_glib_none().0, domain.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_service_future( &self, service: &str, protocol: &str, domain: &str, ) -> Pin, glib::Error>> + 'static>> { let service = String::from(service); let protocol = String::from(protocol); let domain = String::from(domain); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_service_async( &service, &protocol, &domain, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_resolver_set_default")] fn set_default(&self) { unsafe { ffi::g_resolver_set_default(self.as_ref().to_glib_none().0); } } #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "g_resolver_set_timeout")] #[doc(alias = "timeout")] fn set_timeout(&self, timeout_ms: u32) { unsafe { ffi::g_resolver_set_timeout(self.as_ref().to_glib_none().0, timeout_ms); } } #[doc(alias = "reload")] fn connect_reload(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn reload_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GResolver, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Resolver::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"reload\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( reload_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_78")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_78")))] #[doc(alias = "timeout")] fn connect_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GResolver, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Resolver::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ResolverExt for O {} gio-0.20.1/src/auto/resource.rs000064400000000000000000000075001046102023000144200ustar 00000000000000// 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::{ffi, InputStream, ResourceLookupFlags}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Resource(Shared); match fn { ref => |ptr| ffi::g_resource_ref(ptr), unref => |ptr| ffi::g_resource_unref(ptr), type_ => || ffi::g_resource_get_type(), } } impl Resource { #[doc(alias = "g_resource_enumerate_children")] pub fn enumerate_children( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resource_enumerate_children( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resource_get_info")] #[doc(alias = "get_info")] pub fn info( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result<(usize, u32), glib::Error> { unsafe { let mut size = std::mem::MaybeUninit::uninit(); let mut flags = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_resource_get_info( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.into_glib(), size.as_mut_ptr(), flags.as_mut_ptr(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok((size.assume_init(), flags.assume_init())) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resource_lookup_data")] pub fn lookup_data( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resource_lookup_data( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resource_open_stream")] pub fn open_stream( &self, path: &str, lookup_flags: ResourceLookupFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resource_open_stream( self.to_glib_none().0, path.to_glib_none().0, lookup_flags.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_resource_load")] pub fn load(filename: impl AsRef) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_resource_load(filename.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } gio-0.20.1/src/auto/seekable.rs000064400000000000000000000051321046102023000143430ustar 00000000000000// 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::{ffi, Cancellable}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSeekable")] pub struct Seekable(Interface); match fn { type_ => || ffi::g_seekable_get_type(), } } impl Seekable { pub const NONE: Option<&'static Seekable> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SeekableExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_seekable_can_seek")] fn can_seek(&self) -> bool { unsafe { from_glib(ffi::g_seekable_can_seek(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_seekable_can_truncate")] fn can_truncate(&self) -> bool { unsafe { from_glib(ffi::g_seekable_can_truncate(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_seekable_seek")] fn seek( &self, offset: i64, type_: glib::SeekType, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_seekable_seek( self.as_ref().to_glib_none().0, offset, type_.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_seekable_tell")] fn tell(&self) -> i64 { unsafe { ffi::g_seekable_tell(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_seekable_truncate")] fn truncate( &self, offset: i64, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_seekable_truncate( self.as_ref().to_glib_none().0, offset, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl> SeekableExt for O {} gio-0.20.1/src/auto/settings.rs000064400000000000000000000517051046102023000144370ustar 00000000000000// 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_82")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] use crate::SettingsBindFlags; use crate::{ffi, Action, SettingsBackend, SettingsSchema}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSettings")] pub struct Settings(Object); match fn { type_ => || ffi::g_settings_get_type(), } } impl Settings { pub const NONE: Option<&'static Settings> = None; #[doc(alias = "g_settings_new")] pub fn new(schema_id: &str) -> Settings { unsafe { from_glib_full(ffi::g_settings_new(schema_id.to_glib_none().0)) } } #[doc(alias = "g_settings_new_full")] pub fn new_full( schema: &SettingsSchema, backend: Option<&impl IsA>, path: Option<&str>, ) -> Settings { unsafe { from_glib_full(ffi::g_settings_new_full( schema.to_glib_none().0, backend.map(|p| p.as_ref()).to_glib_none().0, path.to_glib_none().0, )) } } #[doc(alias = "g_settings_new_with_backend")] #[doc(alias = "new_with_backend")] pub fn with_backend(schema_id: &str, backend: &impl IsA) -> Settings { unsafe { from_glib_full(ffi::g_settings_new_with_backend( schema_id.to_glib_none().0, backend.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_settings_new_with_backend_and_path")] #[doc(alias = "new_with_backend_and_path")] pub fn with_backend_and_path( schema_id: &str, backend: &impl IsA, path: &str, ) -> Settings { unsafe { from_glib_full(ffi::g_settings_new_with_backend_and_path( schema_id.to_glib_none().0, backend.as_ref().to_glib_none().0, path.to_glib_none().0, )) } } #[doc(alias = "g_settings_new_with_path")] #[doc(alias = "new_with_path")] pub fn with_path(schema_id: &str, path: &str) -> Settings { unsafe { from_glib_full(ffi::g_settings_new_with_path( schema_id.to_glib_none().0, path.to_glib_none().0, )) } } #[doc(alias = "g_settings_sync")] pub fn sync() { unsafe { ffi::g_settings_sync(); } } #[doc(alias = "g_settings_unbind")] pub fn unbind(object: &impl IsA, property: &str) { unsafe { ffi::g_settings_unbind(object.as_ref().to_glib_none().0, property.to_glib_none().0); } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SettingsExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_settings_apply")] fn apply(&self) { unsafe { ffi::g_settings_apply(self.as_ref().to_glib_none().0); } } #[cfg(feature = "v2_82")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_82")))] #[doc(alias = "g_settings_bind_with_mapping_closures")] fn bind_with_mapping_closures( &self, key: &str, object: &impl IsA, property: &str, flags: SettingsBindFlags, get_mapping: Option<&glib::Closure>, set_mapping: Option<&glib::Closure>, ) { unsafe { ffi::g_settings_bind_with_mapping_closures( self.as_ref().to_glib_none().0, key.to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, flags.into_glib(), get_mapping.to_glib_none().0, set_mapping.to_glib_none().0, ); } } #[doc(alias = "g_settings_bind_writable")] fn bind_writable( &self, key: &str, object: &impl IsA, property: &str, inverted: bool, ) { unsafe { ffi::g_settings_bind_writable( self.as_ref().to_glib_none().0, key.to_glib_none().0, object.as_ref().to_glib_none().0, property.to_glib_none().0, inverted.into_glib(), ); } } #[doc(alias = "g_settings_create_action")] fn create_action(&self, key: &str) -> Action { unsafe { from_glib_full(ffi::g_settings_create_action( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_delay")] fn delay(&self) { unsafe { ffi::g_settings_delay(self.as_ref().to_glib_none().0); } } //#[doc(alias = "g_settings_get")] //fn get(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) { // unsafe { TODO: call ffi:g_settings_get() } //} #[doc(alias = "g_settings_get_boolean")] #[doc(alias = "get_boolean")] fn boolean(&self, key: &str) -> bool { unsafe { from_glib(ffi::g_settings_get_boolean( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_get_child")] #[doc(alias = "get_child")] #[must_use] fn child(&self, name: &str) -> Settings { unsafe { from_glib_full(ffi::g_settings_get_child( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_settings_get_default_value")] #[doc(alias = "get_default_value")] fn default_value(&self, key: &str) -> Option { unsafe { from_glib_full(ffi::g_settings_get_default_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_get_double")] #[doc(alias = "get_double")] fn double(&self, key: &str) -> f64 { unsafe { ffi::g_settings_get_double(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_enum")] #[doc(alias = "get_enum")] fn enum_(&self, key: &str) -> i32 { unsafe { ffi::g_settings_get_enum(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_flags")] #[doc(alias = "get_flags")] fn flags(&self, key: &str) -> u32 { unsafe { ffi::g_settings_get_flags(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_has_unapplied")] #[doc(alias = "get_has_unapplied")] #[doc(alias = "has-unapplied")] fn has_unapplied(&self) -> bool { unsafe { from_glib(ffi::g_settings_get_has_unapplied( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_settings_get_int")] #[doc(alias = "get_int")] fn int(&self, key: &str) -> i32 { unsafe { ffi::g_settings_get_int(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_int64")] #[doc(alias = "get_int64")] fn int64(&self, key: &str) -> i64 { unsafe { ffi::g_settings_get_int64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } //#[doc(alias = "g_settings_get_mapped")] //#[doc(alias = "get_mapped")] //fn mapped(&self, key: &str, mapping: /*Unimplemented*/FnMut(&glib::Variant, /*Unimplemented*/Option) -> bool, user_data: /*Unimplemented*/Option) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_settings_get_mapped() } //} #[doc(alias = "g_settings_get_string")] #[doc(alias = "get_string")] fn string(&self, key: &str) -> glib::GString { unsafe { from_glib_full(ffi::g_settings_get_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_get_uint")] #[doc(alias = "get_uint")] fn uint(&self, key: &str) -> u32 { unsafe { ffi::g_settings_get_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_uint64")] #[doc(alias = "get_uint64")] fn uint64(&self, key: &str) -> u64 { unsafe { ffi::g_settings_get_uint64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[doc(alias = "g_settings_get_user_value")] #[doc(alias = "get_user_value")] fn user_value(&self, key: &str) -> Option { unsafe { from_glib_full(ffi::g_settings_get_user_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_get_value")] #[doc(alias = "get_value")] fn value(&self, key: &str) -> glib::Variant { unsafe { from_glib_full(ffi::g_settings_get_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_is_writable")] fn is_writable(&self, name: &str) -> bool { unsafe { from_glib(ffi::g_settings_is_writable( self.as_ref().to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_settings_list_children")] fn list_children(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_list_children( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_settings_reset")] fn reset(&self, key: &str) { unsafe { ffi::g_settings_reset(self.as_ref().to_glib_none().0, key.to_glib_none().0); } } #[doc(alias = "g_settings_revert")] fn revert(&self) { unsafe { ffi::g_settings_revert(self.as_ref().to_glib_none().0); } } //#[doc(alias = "g_settings_set")] //fn set(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> bool { // unsafe { TODO: call ffi:g_settings_set() } //} #[doc(alias = "g_settings_set_boolean")] fn set_boolean(&self, key: &str, value: bool) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_boolean( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.into_glib() ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_double")] fn set_double(&self, key: &str, value: f64) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_double( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_enum")] fn set_enum(&self, key: &str, value: i32) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_enum( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_flags")] fn set_flags(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_flags( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_int")] fn set_int(&self, key: &str, value: i32) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_int( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_int64")] fn set_int64(&self, key: &str, value: i64) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_int64( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_string")] fn set_string(&self, key: &str, value: &str) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_string( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0 ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_uint")] fn set_uint(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_uint( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_uint64")] fn set_uint64(&self, key: &str, value: u64) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_uint64( self.as_ref().to_glib_none().0, key.to_glib_none().0, value ), "Can't set readonly key" ) } } #[doc(alias = "g_settings_set_value")] fn set_value(&self, key: &str, value: &glib::Variant) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_value( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0 ), "Can't set readonly key" ) } } fn backend(&self) -> Option { ObjectExt::property(self.as_ref(), "backend") } #[doc(alias = "delay-apply")] fn is_delay_apply(&self) -> bool { ObjectExt::property(self.as_ref(), "delay-apply") } fn path(&self) -> Option { ObjectExt::property(self.as_ref(), "path") } #[doc(alias = "schema-id")] fn schema_id(&self) -> Option { ObjectExt::property(self.as_ref(), "schema-id") } #[doc(alias = "settings-schema")] fn settings_schema(&self) -> Option { ObjectExt::property(self.as_ref(), "settings-schema") } //#[doc(alias = "change-event")] //fn connect_change_event(&self, f: F) -> SignalHandlerId { // Unimplemented keys: *.CArray TypeId { ns_id: 2, id: 5 } //} #[doc(alias = "changed")] fn connect_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline, F: Fn(&P, &str) + 'static>( this: *mut ffi::GSettings, key: *mut libc::c_char, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( Settings::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(key), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("changed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"changed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "writable-change-event")] fn connect_writable_change_event glib::Propagation + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn writable_change_event_trampoline< P: IsA, F: Fn(&P, u32) -> glib::Propagation + 'static, >( this: *mut ffi::GSettings, key: libc::c_uint, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f(Settings::from_glib_borrow(this).unsafe_cast_ref(), key).into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"writable-change-event\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( writable_change_event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "writable-changed")] fn connect_writable_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn writable_changed_trampoline< P: IsA, F: Fn(&P, &str) + 'static, >( this: *mut ffi::GSettings, key: *mut libc::c_char, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( Settings::from_glib_borrow(this).unsafe_cast_ref(), &glib::GString::from_glib_borrow(key), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("writable-changed::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"writable-changed\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( writable_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "delay-apply")] fn connect_delay_apply_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_delay_apply_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSettings, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Settings::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::delay-apply\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_delay_apply_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "has-unapplied")] fn connect_has_unapplied_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_has_unapplied_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSettings, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Settings::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::has-unapplied\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_has_unapplied_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SettingsExt for O {} gio-0.20.1/src/auto/settings_backend.rs000064400000000000000000000053571046102023000161100ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSettingsBackend")] pub struct SettingsBackend(Object); match fn { type_ => || ffi::g_settings_backend_get_type(), } } impl SettingsBackend { pub const NONE: Option<&'static SettingsBackend> = None; //#[doc(alias = "g_settings_backend_flatten_tree")] //pub fn flatten_tree(tree: /*Ignored*/&glib::Tree) -> (glib::GString, Vec, Vec) { // unsafe { TODO: call ffi:g_settings_backend_flatten_tree() } //} #[doc(alias = "g_settings_backend_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> SettingsBackend { unsafe { from_glib_full(ffi::g_settings_backend_get_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SettingsBackendExt: IsA + sealed::Sealed + 'static { //#[doc(alias = "g_settings_backend_changed")] //fn changed(&self, key: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_changed() } //} //#[doc(alias = "g_settings_backend_changed_tree")] //fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_changed_tree() } //} //#[doc(alias = "g_settings_backend_keys_changed")] //fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_keys_changed() } //} //#[doc(alias = "g_settings_backend_path_changed")] //fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_path_changed() } //} #[doc(alias = "g_settings_backend_path_writable_changed")] fn path_writable_changed(&self, path: &str) { unsafe { ffi::g_settings_backend_path_writable_changed( self.as_ref().to_glib_none().0, path.to_glib_none().0, ); } } #[doc(alias = "g_settings_backend_writable_changed")] fn writable_changed(&self, key: &str) { unsafe { ffi::g_settings_backend_writable_changed( self.as_ref().to_glib_none().0, key.to_glib_none().0, ); } } } impl> SettingsBackendExt for O {} gio-0.20.1/src/auto/settings_schema.rs000064400000000000000000000041421046102023000157500ustar 00000000000000// 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::{ffi, SettingsSchemaKey}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchema(Shared); match fn { ref => |ptr| ffi::g_settings_schema_ref(ptr), unref => |ptr| ffi::g_settings_schema_unref(ptr), type_ => || ffi::g_settings_schema_get_type(), } } impl SettingsSchema { #[doc(alias = "g_settings_schema_get_id")] #[doc(alias = "get_id")] pub fn id(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_settings_schema_get_id(self.to_glib_none().0)) } } #[doc(alias = "g_settings_schema_get_key")] #[doc(alias = "get_key")] pub fn key(&self, name: &str) -> SettingsSchemaKey { unsafe { from_glib_full(ffi::g_settings_schema_get_key( self.to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_get_path")] #[doc(alias = "get_path")] pub fn path(&self) -> Option { unsafe { from_glib_none(ffi::g_settings_schema_get_path(self.to_glib_none().0)) } } #[doc(alias = "g_settings_schema_has_key")] pub fn has_key(&self, name: &str) -> bool { unsafe { from_glib(ffi::g_settings_schema_has_key( self.to_glib_none().0, name.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_list_children")] pub fn list_children(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_schema_list_children( self.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_list_keys")] pub fn list_keys(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_schema_list_keys( self.to_glib_none().0, )) } } } gio-0.20.1/src/auto/settings_schema_key.rs000064400000000000000000000052441046102023000166240ustar 00000000000000// 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::ffi; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchemaKey(Shared); match fn { ref => |ptr| ffi::g_settings_schema_key_ref(ptr), unref => |ptr| ffi::g_settings_schema_key_unref(ptr), type_ => || ffi::g_settings_schema_key_get_type(), } } impl SettingsSchemaKey { #[doc(alias = "g_settings_schema_key_get_default_value")] #[doc(alias = "get_default_value")] pub fn default_value(&self) -> glib::Variant { unsafe { from_glib_full(ffi::g_settings_schema_key_get_default_value( self.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_key_get_description")] #[doc(alias = "get_description")] pub fn description(&self) -> Option { unsafe { from_glib_none(ffi::g_settings_schema_key_get_description( self.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_key_get_name")] #[doc(alias = "get_name")] pub fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_settings_schema_key_get_name(self.to_glib_none().0)) } } #[doc(alias = "g_settings_schema_key_get_range")] #[doc(alias = "get_range")] pub fn range(&self) -> glib::Variant { unsafe { from_glib_full(ffi::g_settings_schema_key_get_range(self.to_glib_none().0)) } } #[doc(alias = "g_settings_schema_key_get_summary")] #[doc(alias = "get_summary")] pub fn summary(&self) -> Option { unsafe { from_glib_none(ffi::g_settings_schema_key_get_summary( self.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_key_get_value_type")] #[doc(alias = "get_value_type")] pub fn value_type(&self) -> glib::VariantType { unsafe { from_glib_none(ffi::g_settings_schema_key_get_value_type( self.to_glib_none().0, )) } } #[doc(alias = "g_settings_schema_key_range_check")] pub fn range_check(&self, value: &glib::Variant) -> bool { unsafe { from_glib(ffi::g_settings_schema_key_range_check( self.to_glib_none().0, value.to_glib_none().0, )) } } } impl std::fmt::Display for SettingsSchemaKey { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { f.write_str(&self.name()) } } gio-0.20.1/src/auto/settings_schema_source.rs000064400000000000000000000052411046102023000173310ustar 00000000000000// 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::{ffi, SettingsSchema}; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SettingsSchemaSource(Shared); match fn { ref => |ptr| ffi::g_settings_schema_source_ref(ptr), unref => |ptr| ffi::g_settings_schema_source_unref(ptr), type_ => || ffi::g_settings_schema_source_get_type(), } } impl SettingsSchemaSource { #[doc(alias = "g_settings_schema_source_new_from_directory")] #[doc(alias = "new_from_directory")] pub fn from_directory( directory: impl AsRef, parent: Option<&SettingsSchemaSource>, trusted: bool, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_settings_schema_source_new_from_directory( directory.as_ref().to_glib_none().0, parent.to_glib_none().0, trusted.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_settings_schema_source_list_schemas")] pub fn list_schemas(&self, recursive: bool) -> (Vec, Vec) { unsafe { let mut non_relocatable = std::ptr::null_mut(); let mut relocatable = std::ptr::null_mut(); ffi::g_settings_schema_source_list_schemas( self.to_glib_none().0, recursive.into_glib(), &mut non_relocatable, &mut relocatable, ); ( FromGlibPtrContainer::from_glib_full(non_relocatable), FromGlibPtrContainer::from_glib_full(relocatable), ) } } #[doc(alias = "g_settings_schema_source_lookup")] pub fn lookup(&self, schema_id: &str, recursive: bool) -> Option { unsafe { from_glib_full(ffi::g_settings_schema_source_lookup( self.to_glib_none().0, schema_id.to_glib_none().0, recursive.into_glib(), )) } } #[doc(alias = "g_settings_schema_source_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> Option { unsafe { from_glib_none(ffi::g_settings_schema_source_get_default()) } } } gio-0.20.1/src/auto/simple_action.rs000064400000000000000000000102021046102023000154100ustar 00000000000000// 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::{ffi, Action}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSimpleAction")] pub struct SimpleAction(Object) @implements Action; match fn { type_ => || ffi::g_simple_action_get_type(), } } impl SimpleAction { #[doc(alias = "g_simple_action_new")] pub fn new(name: &str, parameter_type: Option<&glib::VariantTy>) -> SimpleAction { unsafe { from_glib_full(ffi::g_simple_action_new( name.to_glib_none().0, parameter_type.to_glib_none().0, )) } } #[doc(alias = "g_simple_action_new_stateful")] pub fn new_stateful( name: &str, parameter_type: Option<&glib::VariantTy>, state: &glib::Variant, ) -> SimpleAction { unsafe { from_glib_full(ffi::g_simple_action_new_stateful( name.to_glib_none().0, parameter_type.to_glib_none().0, state.to_glib_none().0, )) } } #[doc(alias = "g_simple_action_set_enabled")] #[doc(alias = "enabled")] pub fn set_enabled(&self, enabled: bool) { unsafe { ffi::g_simple_action_set_enabled(self.to_glib_none().0, enabled.into_glib()); } } #[doc(alias = "g_simple_action_set_state")] #[doc(alias = "state")] pub fn set_state(&self, value: &glib::Variant) { unsafe { ffi::g_simple_action_set_state(self.to_glib_none().0, value.to_glib_none().0); } } #[doc(alias = "g_simple_action_set_state_hint")] pub fn set_state_hint(&self, state_hint: Option<&glib::Variant>) { unsafe { ffi::g_simple_action_set_state_hint(self.to_glib_none().0, state_hint.to_glib_none().0); } } #[doc(alias = "activate")] pub fn connect_activate) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn activate_trampoline< F: Fn(&SimpleAction, Option<&glib::Variant>) + 'static, >( this: *mut ffi::GSimpleAction, parameter: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), Option::::from_glib_borrow(parameter) .as_ref() .as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"activate\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( activate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "change-state")] pub fn connect_change_state) + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn change_state_trampoline< F: Fn(&SimpleAction, Option<&glib::Variant>) + 'static, >( this: *mut ffi::GSimpleAction, value: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( &from_glib_borrow(this), Option::::from_glib_borrow(value) .as_ref() .as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"change-state\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( change_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/auto/simple_action_group.rs000064400000000000000000000014711046102023000166340ustar 00000000000000// 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::{ffi, ActionGroup, ActionMap}; use glib::translate::*; glib::wrapper! { #[doc(alias = "GSimpleActionGroup")] pub struct SimpleActionGroup(Object) @implements ActionGroup, ActionMap; match fn { type_ => || ffi::g_simple_action_group_get_type(), } } impl SimpleActionGroup { pub const NONE: Option<&'static SimpleActionGroup> = None; #[doc(alias = "g_simple_action_group_new")] pub fn new() -> SimpleActionGroup { unsafe { from_glib_full(ffi::g_simple_action_group_new()) } } } impl Default for SimpleActionGroup { fn default() -> Self { Self::new() } } gio-0.20.1/src/auto/simple_io_stream.rs000064400000000000000000000016121046102023000161220ustar 00000000000000// 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::{ffi, IOStream, InputStream, OutputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSimpleIOStream")] pub struct SimpleIOStream(Object) @extends IOStream; match fn { type_ => || ffi::g_simple_io_stream_get_type(), } } impl SimpleIOStream { #[doc(alias = "g_simple_io_stream_new")] pub fn new( input_stream: &impl IsA, output_stream: &impl IsA, ) -> SimpleIOStream { unsafe { IOStream::from_glib_full(ffi::g_simple_io_stream_new( input_stream.as_ref().to_glib_none().0, output_stream.as_ref().to_glib_none().0, )) .unsafe_cast() } } } gio-0.20.1/src/auto/simple_permission.rs000064400000000000000000000013051046102023000163270ustar 00000000000000// 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::{ffi, Permission}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSimplePermission")] pub struct SimplePermission(Object) @extends Permission; match fn { type_ => || ffi::g_simple_permission_get_type(), } } impl SimplePermission { #[doc(alias = "g_simple_permission_new")] pub fn new(allowed: bool) -> SimplePermission { unsafe { Permission::from_glib_full(ffi::g_simple_permission_new(allowed.into_glib())) .unsafe_cast() } } } gio-0.20.1/src/auto/simple_proxy_resolver.rs000064400000000000000000000075301046102023000172470ustar 00000000000000// 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::{ffi, ProxyResolver}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSimpleProxyResolver")] pub struct SimpleProxyResolver(Object) @implements ProxyResolver; match fn { type_ => || ffi::g_simple_proxy_resolver_get_type(), } } impl SimpleProxyResolver { pub const NONE: Option<&'static SimpleProxyResolver> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SimpleProxyResolverExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_simple_proxy_resolver_set_default_proxy")] #[doc(alias = "default-proxy")] fn set_default_proxy(&self, default_proxy: Option<&str>) { unsafe { ffi::g_simple_proxy_resolver_set_default_proxy( self.as_ref().to_glib_none().0, default_proxy.to_glib_none().0, ); } } #[doc(alias = "g_simple_proxy_resolver_set_uri_proxy")] fn set_uri_proxy(&self, uri_scheme: &str, proxy: &str) { unsafe { ffi::g_simple_proxy_resolver_set_uri_proxy( self.as_ref().to_glib_none().0, uri_scheme.to_glib_none().0, proxy.to_glib_none().0, ); } } #[doc(alias = "default-proxy")] fn default_proxy(&self) -> Option { ObjectExt::property(self.as_ref(), "default-proxy") } #[doc(alias = "ignore-hosts")] fn ignore_hosts(&self) -> Vec { ObjectExt::property(self.as_ref(), "ignore-hosts") } #[doc(alias = "default-proxy")] fn connect_default_proxy_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_default_proxy_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSimpleProxyResolver, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SimpleProxyResolver::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::default-proxy\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_default_proxy_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "ignore-hosts")] fn connect_ignore_hosts_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ignore_hosts_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSimpleProxyResolver, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SimpleProxyResolver::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ignore-hosts\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ignore_hosts_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SimpleProxyResolverExt for O {} gio-0.20.1/src/auto/socket.rs000064400000000000000000000703341046102023000140660ustar 00000000000000// 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::{ ffi, Cancellable, Credentials, DatagramBased, InetAddress, Initable, SocketAddress, SocketConnection, SocketFamily, SocketProtocol, SocketType, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSocket")] pub struct Socket(Object) @implements DatagramBased, Initable; match fn { type_ => || ffi::g_socket_get_type(), } } impl Socket { pub const NONE: Option<&'static Socket> = None; #[doc(alias = "g_socket_new")] pub fn new( family: SocketFamily, type_: SocketType, protocol: SocketProtocol, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_new( family.into_glib(), type_.into_glib(), protocol.into_glib(), &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_accept")] fn accept(&self, cancellable: Option<&impl IsA>) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_accept( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_socket_bind")] fn bind( &self, address: &impl IsA, allow_reuse: bool, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_bind( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, allow_reuse.into_glib(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_check_connect_result")] fn check_connect_result(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_check_connect_result(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_close")] fn close(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_close(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_condition_check")] fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition { unsafe { from_glib(ffi::g_socket_condition_check( self.as_ref().to_glib_none().0, condition.into_glib(), )) } } #[doc(alias = "g_socket_condition_timed_wait")] fn condition_timed_wait( &self, condition: glib::IOCondition, timeout_us: i64, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_condition_timed_wait( self.as_ref().to_glib_none().0, condition.into_glib(), timeout_us, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_condition_wait")] fn condition_wait( &self, condition: glib::IOCondition, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_condition_wait( self.as_ref().to_glib_none().0, condition.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_connect")] fn connect( &self, address: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_connect( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_connection_factory_create_connection")] fn connection_factory_create_connection(&self) -> SocketConnection { unsafe { from_glib_full(ffi::g_socket_connection_factory_create_connection( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_get_available_bytes")] #[doc(alias = "get_available_bytes")] fn available_bytes(&self) -> isize { unsafe { ffi::g_socket_get_available_bytes(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_get_blocking")] #[doc(alias = "get_blocking")] #[doc(alias = "blocking")] fn is_blocking(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_blocking(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_get_broadcast")] #[doc(alias = "get_broadcast")] #[doc(alias = "broadcast")] fn is_broadcast(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_broadcast(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_get_credentials")] #[doc(alias = "get_credentials")] fn credentials(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_get_credentials(self.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_socket_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_get_family(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_get_keepalive")] #[doc(alias = "get_keepalive")] #[doc(alias = "keepalive")] fn is_keepalive(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_keepalive(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_get_listen_backlog")] #[doc(alias = "get_listen_backlog")] #[doc(alias = "listen-backlog")] fn listen_backlog(&self) -> i32 { unsafe { ffi::g_socket_get_listen_backlog(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_get_local_address")] #[doc(alias = "get_local_address")] #[doc(alias = "local-address")] fn local_address(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_get_local_address(self.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_socket_get_multicast_loopback")] #[doc(alias = "get_multicast_loopback")] #[doc(alias = "multicast-loopback")] fn is_multicast_loopback(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_multicast_loopback( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_get_multicast_ttl")] #[doc(alias = "get_multicast_ttl")] #[doc(alias = "multicast-ttl")] fn multicast_ttl(&self) -> u32 { unsafe { ffi::g_socket_get_multicast_ttl(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_get_option")] #[doc(alias = "get_option")] fn option(&self, level: i32, optname: i32) -> Result { unsafe { let mut value = std::mem::MaybeUninit::uninit(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_get_option( self.as_ref().to_glib_none().0, level, optname, value.as_mut_ptr(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(value.assume_init()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> SocketProtocol { unsafe { from_glib(ffi::g_socket_get_protocol(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_get_remote_address")] #[doc(alias = "get_remote_address")] #[doc(alias = "remote-address")] fn remote_address(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_get_remote_address(self.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_socket_get_socket_type")] #[doc(alias = "get_socket_type")] fn socket_type(&self) -> SocketType { unsafe { from_glib(ffi::g_socket_get_socket_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_get_timeout")] #[doc(alias = "get_timeout")] fn timeout(&self) -> u32 { unsafe { ffi::g_socket_get_timeout(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_get_ttl")] #[doc(alias = "get_ttl")] fn ttl(&self) -> u32 { unsafe { ffi::g_socket_get_ttl(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_is_closed")] fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_socket_is_closed(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_is_connected")] fn is_connected(&self) -> bool { unsafe { from_glib(ffi::g_socket_is_connected(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_socket_join_multicast_group")] fn join_multicast_group( &self, group: &impl IsA, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_join_multicast_group( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.into_glib(), iface.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_join_multicast_group_ssm")] fn join_multicast_group_ssm( &self, group: &impl IsA, source_specific: Option<&impl IsA>, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_join_multicast_group_ssm( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.map(|p| p.as_ref()).to_glib_none().0, iface.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_leave_multicast_group")] fn leave_multicast_group( &self, group: &impl IsA, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_leave_multicast_group( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.into_glib(), iface.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_leave_multicast_group_ssm")] fn leave_multicast_group_ssm( &self, group: &impl IsA, source_specific: Option<&impl IsA>, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_leave_multicast_group_ssm( self.as_ref().to_glib_none().0, group.as_ref().to_glib_none().0, source_specific.map(|p| p.as_ref()).to_glib_none().0, iface.to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listen")] fn listen(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_listen(self.as_ref().to_glib_none().0, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_set_blocking")] #[doc(alias = "blocking")] fn set_blocking(&self, blocking: bool) { unsafe { ffi::g_socket_set_blocking(self.as_ref().to_glib_none().0, blocking.into_glib()); } } #[doc(alias = "g_socket_set_broadcast")] #[doc(alias = "broadcast")] fn set_broadcast(&self, broadcast: bool) { unsafe { ffi::g_socket_set_broadcast(self.as_ref().to_glib_none().0, broadcast.into_glib()); } } #[doc(alias = "g_socket_set_keepalive")] #[doc(alias = "keepalive")] fn set_keepalive(&self, keepalive: bool) { unsafe { ffi::g_socket_set_keepalive(self.as_ref().to_glib_none().0, keepalive.into_glib()); } } #[doc(alias = "g_socket_set_listen_backlog")] #[doc(alias = "listen-backlog")] fn set_listen_backlog(&self, backlog: i32) { unsafe { ffi::g_socket_set_listen_backlog(self.as_ref().to_glib_none().0, backlog); } } #[doc(alias = "g_socket_set_multicast_loopback")] #[doc(alias = "multicast-loopback")] fn set_multicast_loopback(&self, loopback: bool) { unsafe { ffi::g_socket_set_multicast_loopback( self.as_ref().to_glib_none().0, loopback.into_glib(), ); } } #[doc(alias = "g_socket_set_multicast_ttl")] #[doc(alias = "multicast-ttl")] fn set_multicast_ttl(&self, ttl: u32) { unsafe { ffi::g_socket_set_multicast_ttl(self.as_ref().to_glib_none().0, ttl); } } #[doc(alias = "g_socket_set_option")] fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_set_option( self.as_ref().to_glib_none().0, level, optname, value, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_set_timeout")] #[doc(alias = "timeout")] fn set_timeout(&self, timeout: u32) { unsafe { ffi::g_socket_set_timeout(self.as_ref().to_glib_none().0, timeout); } } #[doc(alias = "g_socket_set_ttl")] #[doc(alias = "ttl")] fn set_ttl(&self, ttl: u32) { unsafe { ffi::g_socket_set_ttl(self.as_ref().to_glib_none().0, ttl); } } #[doc(alias = "g_socket_shutdown")] fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_shutdown( self.as_ref().to_glib_none().0, shutdown_read.into_glib(), shutdown_write.into_glib(), &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_speaks_ipv4")] fn speaks_ipv4(&self) -> bool { unsafe { from_glib(ffi::g_socket_speaks_ipv4(self.as_ref().to_glib_none().0)) } } #[doc(alias = "type")] fn type_(&self) -> SocketType { ObjectExt::property(self.as_ref(), "type") } #[doc(alias = "blocking")] fn connect_blocking_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_blocking_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::blocking\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_blocking_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "broadcast")] fn connect_broadcast_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_broadcast_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::broadcast\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_broadcast_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "keepalive")] fn connect_keepalive_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_keepalive_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::keepalive\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_keepalive_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "listen-backlog")] fn connect_listen_backlog_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_listen_backlog_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::listen-backlog\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_listen_backlog_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "local-address")] fn connect_local_address_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_local_address_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::local-address\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_local_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "multicast-loopback")] fn connect_multicast_loopback_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_loopback_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::multicast-loopback\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_multicast_loopback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "multicast-ttl")] fn connect_multicast_ttl_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_ttl_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::multicast-ttl\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_multicast_ttl_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "remote-address")] fn connect_remote_address_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_remote_address_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::remote-address\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_remote_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "timeout")] fn connect_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "ttl")] fn connect_ttl_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ttl_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocket, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Socket::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ttl\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ttl_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SocketExt for O {} gio-0.20.1/src/auto/socket_address.rs000064400000000000000000000055631046102023000155750ustar 00000000000000// 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::{ffi, SocketConnectable, SocketFamily}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSocketAddress")] pub struct SocketAddress(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_socket_address_get_type(), } } impl SocketAddress { pub const NONE: Option<&'static SocketAddress> = None; //#[doc(alias = "g_socket_address_new_from_native")] //#[doc(alias = "new_from_native")] //pub fn from_native(native: /*Unimplemented*/Basic: Pointer, len: usize) -> SocketAddress { // unsafe { TODO: call ffi:g_socket_address_new_from_native() } //} } unsafe impl Send for SocketAddress {} unsafe impl Sync for SocketAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_address_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_address_get_family( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_address_get_native_size")] #[doc(alias = "get_native_size")] fn native_size(&self) -> isize { unsafe { ffi::g_socket_address_get_native_size(self.as_ref().to_glib_none().0) } } //#[doc(alias = "g_socket_address_to_native")] //fn to_native(&self, dest: /*Unimplemented*/Option, destlen: usize) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:g_socket_address_to_native() } //} #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GSocketAddress, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketAddress::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SocketAddressExt for O {} gio-0.20.1/src/auto/socket_address_enumerator.rs000064400000000000000000000100271046102023000200250ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, SocketAddress}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GSocketAddressEnumerator")] pub struct SocketAddressEnumerator(Object); match fn { type_ => || ffi::g_socket_address_enumerator_get_type(), } } impl SocketAddressEnumerator { pub const NONE: Option<&'static SocketAddressEnumerator> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketAddressEnumeratorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_address_enumerator_next")] fn next( &self, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_address_enumerator_next( self.as_ref().to_glib_none().0, cancellable.map(|p| p.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_socket_address_enumerator_next_async")] fn next_async, glib::Error>) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn next_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_address_enumerator_next_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = next_async_trampoline::

; unsafe { ffi::g_socket_address_enumerator_next_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn next_future( &self, ) -> Pin< Box_< dyn std::future::Future, glib::Error>> + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.next_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> SocketAddressEnumeratorExt for O {} gio-0.20.1/src/auto/socket_client.rs000064400000000000000000000754331046102023000154310ustar 00000000000000// 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(deprecated)] use crate::{ ffi, AsyncResult, Cancellable, IOStream, ProxyResolver, SocketAddress, SocketClientEvent, SocketConnectable, SocketConnection, SocketFamily, SocketProtocol, SocketType, TlsCertificateFlags, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GSocketClient")] pub struct SocketClient(Object); match fn { type_ => || ffi::g_socket_client_get_type(), } } impl SocketClient { pub const NONE: Option<&'static SocketClient> = None; #[doc(alias = "g_socket_client_new")] pub fn new() -> SocketClient { unsafe { from_glib_full(ffi::g_socket_client_new()) } } } impl Default for SocketClient { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketClientExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_client_add_application_proxy")] fn add_application_proxy(&self, protocol: &str) { unsafe { ffi::g_socket_client_add_application_proxy( self.as_ref().to_glib_none().0, protocol.to_glib_none().0, ); } } #[doc(alias = "g_socket_client_connect")] fn connect( &self, connectable: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.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_socket_client_connect_async")] fn connect_async) + 'static>( &self, connectable: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_async_trampoline::

; unsafe { ffi::g_socket_client_connect_async( self.as_ref().to_glib_none().0, connectable.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_future( &self, connectable: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let connectable = connectable.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_async(&connectable, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_client_connect_to_host")] fn connect_to_host( &self, host_and_port: &str, default_port: u16, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_host( self.as_ref().to_glib_none().0, host_and_port.to_glib_none().0, default_port, cancellable.map(|p| p.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_socket_client_connect_to_host_async")] fn connect_to_host_async) + 'static>( &self, host_and_port: &str, default_port: u16, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_to_host_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_host_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_to_host_async_trampoline::

; unsafe { ffi::g_socket_client_connect_to_host_async( self.as_ref().to_glib_none().0, host_and_port.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_to_host_future( &self, host_and_port: &str, default_port: u16, ) -> Pin> + 'static>> { let host_and_port = String::from(host_and_port); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_to_host_async( &host_and_port, default_port, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_socket_client_connect_to_service")] fn connect_to_service( &self, domain: &str, service: &str, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_service( self.as_ref().to_glib_none().0, domain.to_glib_none().0, service.to_glib_none().0, cancellable.map(|p| p.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_socket_client_connect_to_service_async")] fn connect_to_service_async) + 'static>( &self, domain: &str, service: &str, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_to_service_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_service_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_to_service_async_trampoline::

; unsafe { ffi::g_socket_client_connect_to_service_async( self.as_ref().to_glib_none().0, domain.to_glib_none().0, service.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_to_service_future( &self, domain: &str, service: &str, ) -> Pin> + 'static>> { let domain = String::from(domain); let service = String::from(service); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_to_service_async(&domain, &service, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_client_connect_to_uri")] fn connect_to_uri( &self, uri: &str, default_port: u16, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_uri( self.as_ref().to_glib_none().0, uri.to_glib_none().0, default_port, cancellable.map(|p| p.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_socket_client_connect_to_uri_async")] fn connect_to_uri_async) + 'static>( &self, uri: &str, default_port: u16, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_to_uri_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_client_connect_to_uri_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_to_uri_async_trampoline::

; unsafe { ffi::g_socket_client_connect_to_uri_async( self.as_ref().to_glib_none().0, uri.to_glib_none().0, default_port, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_to_uri_future( &self, uri: &str, default_port: u16, ) -> Pin> + 'static>> { let uri = String::from(uri); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_to_uri_async(&uri, default_port, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_client_get_enable_proxy")] #[doc(alias = "get_enable_proxy")] #[doc(alias = "enable-proxy")] fn enables_proxy(&self) -> bool { unsafe { from_glib(ffi::g_socket_client_get_enable_proxy( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_client_get_family( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_local_address")] #[doc(alias = "get_local_address")] #[doc(alias = "local-address")] fn local_address(&self) -> Option { unsafe { from_glib_none(ffi::g_socket_client_get_local_address( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> SocketProtocol { unsafe { from_glib(ffi::g_socket_client_get_protocol( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_proxy_resolver")] #[doc(alias = "get_proxy_resolver")] #[doc(alias = "proxy-resolver")] fn proxy_resolver(&self) -> ProxyResolver { unsafe { from_glib_none(ffi::g_socket_client_get_proxy_resolver( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_socket_type")] #[doc(alias = "get_socket_type")] fn socket_type(&self) -> SocketType { unsafe { from_glib(ffi::g_socket_client_get_socket_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_get_timeout")] #[doc(alias = "get_timeout")] fn timeout(&self) -> u32 { unsafe { ffi::g_socket_client_get_timeout(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_client_get_tls")] #[doc(alias = "get_tls")] #[doc(alias = "tls")] fn is_tls(&self) -> bool { unsafe { from_glib(ffi::g_socket_client_get_tls(self.as_ref().to_glib_none().0)) } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[allow(deprecated)] #[doc(alias = "g_socket_client_get_tls_validation_flags")] #[doc(alias = "get_tls_validation_flags")] #[doc(alias = "tls-validation-flags")] fn tls_validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_socket_client_get_tls_validation_flags( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_client_set_enable_proxy")] #[doc(alias = "enable-proxy")] fn set_enable_proxy(&self, enable: bool) { unsafe { ffi::g_socket_client_set_enable_proxy( self.as_ref().to_glib_none().0, enable.into_glib(), ); } } #[doc(alias = "g_socket_client_set_family")] #[doc(alias = "family")] fn set_family(&self, family: SocketFamily) { unsafe { ffi::g_socket_client_set_family(self.as_ref().to_glib_none().0, family.into_glib()); } } #[doc(alias = "g_socket_client_set_local_address")] #[doc(alias = "local-address")] fn set_local_address(&self, address: Option<&impl IsA>) { unsafe { ffi::g_socket_client_set_local_address( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_socket_client_set_protocol")] #[doc(alias = "protocol")] fn set_protocol(&self, protocol: SocketProtocol) { unsafe { ffi::g_socket_client_set_protocol(self.as_ref().to_glib_none().0, protocol.into_glib()); } } #[doc(alias = "g_socket_client_set_proxy_resolver")] #[doc(alias = "proxy-resolver")] fn set_proxy_resolver(&self, proxy_resolver: Option<&impl IsA>) { unsafe { ffi::g_socket_client_set_proxy_resolver( self.as_ref().to_glib_none().0, proxy_resolver.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_socket_client_set_socket_type")] fn set_socket_type(&self, type_: SocketType) { unsafe { ffi::g_socket_client_set_socket_type(self.as_ref().to_glib_none().0, type_.into_glib()); } } #[doc(alias = "g_socket_client_set_timeout")] #[doc(alias = "timeout")] fn set_timeout(&self, timeout: u32) { unsafe { ffi::g_socket_client_set_timeout(self.as_ref().to_glib_none().0, timeout); } } #[doc(alias = "g_socket_client_set_tls")] #[doc(alias = "tls")] fn set_tls(&self, tls: bool) { unsafe { ffi::g_socket_client_set_tls(self.as_ref().to_glib_none().0, tls.into_glib()); } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[allow(deprecated)] #[doc(alias = "g_socket_client_set_tls_validation_flags")] #[doc(alias = "tls-validation-flags")] fn set_tls_validation_flags(&self, flags: TlsCertificateFlags) { unsafe { ffi::g_socket_client_set_tls_validation_flags( self.as_ref().to_glib_none().0, flags.into_glib(), ); } } #[doc(alias = "type")] fn type_(&self) -> SocketType { ObjectExt::property(self.as_ref(), "type") } #[doc(alias = "type")] fn set_type(&self, type_: SocketType) { ObjectExt::set_property(self.as_ref(), "type", type_) } #[doc(alias = "event")] fn connect_event< F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn event_trampoline< P: IsA, F: Fn(&P, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( this: *mut ffi::GSocketClient, event: ffi::GSocketClientEvent, connectable: *mut ffi::GSocketConnectable, connection: *mut ffi::GIOStream, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( SocketClient::from_glib_borrow(this).unsafe_cast_ref(), from_glib(event), &from_glib_borrow(connectable), Option::::from_glib_borrow(connection) .as_ref() .as_ref(), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"event\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "enable-proxy")] fn connect_enable_proxy_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_enable_proxy_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::enable-proxy\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_enable_proxy_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_family_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::family\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "local-address")] fn connect_local_address_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_local_address_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::local-address\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_local_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "protocol")] fn connect_protocol_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_protocol_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::protocol\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_protocol_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "proxy-resolver")] fn connect_proxy_resolver_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_proxy_resolver_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::proxy-resolver\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_proxy_resolver_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "timeout")] fn connect_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "tls")] fn connect_tls_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_tls_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::tls\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_tls_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[doc(alias = "tls-validation-flags")] fn connect_tls_validation_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_tls_validation_flags_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::tls-validation-flags\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_tls_validation_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "type")] fn connect_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_type_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GSocketClient, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketClient::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::type\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SocketClientExt for O {} gio-0.20.1/src/auto/socket_connectable.rs000064400000000000000000000031171046102023000164160ustar 00000000000000// 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::{ffi, SocketAddressEnumerator}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSocketConnectable")] pub struct SocketConnectable(Interface); match fn { type_ => || ffi::g_socket_connectable_get_type(), } } impl SocketConnectable { pub const NONE: Option<&'static SocketConnectable> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketConnectableExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_connectable_enumerate")] fn enumerate(&self) -> SocketAddressEnumerator { unsafe { from_glib_full(ffi::g_socket_connectable_enumerate( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_connectable_proxy_enumerate")] fn proxy_enumerate(&self) -> SocketAddressEnumerator { unsafe { from_glib_full(ffi::g_socket_connectable_proxy_enumerate( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_connectable_to_string")] fn to_string(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_socket_connectable_to_string( self.as_ref().to_glib_none().0, )) } } } impl> SocketConnectableExt for O {} gio-0.20.1/src/auto/socket_connection.rs000064400000000000000000000152351046102023000163040ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, IOStream, Socket, SocketAddress, SocketFamily, SocketType, }; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GSocketConnection")] pub struct SocketConnection(Object) @extends IOStream; match fn { type_ => || ffi::g_socket_connection_get_type(), } } impl SocketConnection { pub const NONE: Option<&'static SocketConnection> = None; #[doc(alias = "g_socket_connection_factory_lookup_type")] pub fn factory_lookup_type( family: SocketFamily, type_: SocketType, protocol_id: i32, ) -> glib::types::Type { unsafe { from_glib(ffi::g_socket_connection_factory_lookup_type( family.into_glib(), type_.into_glib(), protocol_id, )) } } #[doc(alias = "g_socket_connection_factory_register_type")] pub fn factory_register_type( g_type: glib::types::Type, family: SocketFamily, type_: SocketType, protocol: i32, ) { unsafe { ffi::g_socket_connection_factory_register_type( g_type.into_glib(), family.into_glib(), type_.into_glib(), protocol, ); } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketConnectionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_connection_connect")] fn connect( &self, address: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_connection_connect( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_connection_connect_async")] fn connect_async) + 'static>( &self, address: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn connect_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_socket_connection_connect_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = connect_async_trampoline::

; unsafe { ffi::g_socket_connection_connect_async( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn connect_future( &self, address: &(impl IsA + Clone + 'static), ) -> Pin> + 'static>> { let address = address.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.connect_async(&address, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_connection_get_local_address")] #[doc(alias = "get_local_address")] fn local_address(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_connection_get_local_address( self.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_socket_connection_get_remote_address")] #[doc(alias = "get_remote_address")] fn remote_address(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_connection_get_remote_address( self.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_socket_connection_get_socket")] #[doc(alias = "get_socket")] fn socket(&self) -> Socket { unsafe { from_glib_none(ffi::g_socket_connection_get_socket( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_connection_is_connected")] fn is_connected(&self) -> bool { unsafe { from_glib(ffi::g_socket_connection_is_connected( self.as_ref().to_glib_none().0, )) } } } impl> SocketConnectionExt for O {} gio-0.20.1/src/auto/socket_control_message.rs000064400000000000000000000035651046102023000173340ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GSocketControlMessage")] pub struct SocketControlMessage(Object); match fn { type_ => || ffi::g_socket_control_message_get_type(), } } impl SocketControlMessage { pub const NONE: Option<&'static SocketControlMessage> = None; #[doc(alias = "g_socket_control_message_deserialize")] pub fn deserialize(level: i32, type_: i32, data: &[u8]) -> Option { let size = data.len() as _; unsafe { from_glib_full(ffi::g_socket_control_message_deserialize( level, type_, size, data.to_glib_none().0 as glib::ffi::gpointer, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketControlMessageExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_control_message_get_level")] #[doc(alias = "get_level")] fn level(&self) -> i32 { unsafe { ffi::g_socket_control_message_get_level(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_control_message_get_msg_type")] #[doc(alias = "get_msg_type")] fn msg_type(&self) -> i32 { unsafe { ffi::g_socket_control_message_get_msg_type(self.as_ref().to_glib_none().0) } } #[doc(alias = "g_socket_control_message_get_size")] #[doc(alias = "get_size")] fn size(&self) -> usize { unsafe { ffi::g_socket_control_message_get_size(self.as_ref().to_glib_none().0) } } } impl> SocketControlMessageExt for O {} gio-0.20.1/src/auto/socket_listener.rs000064400000000000000000000340031046102023000157640ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, Socket, SocketAddress, SocketConnection, SocketListenerEvent, SocketProtocol, SocketType, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GSocketListener")] pub struct SocketListener(Object); match fn { type_ => || ffi::g_socket_listener_get_type(), } } impl SocketListener { pub const NONE: Option<&'static SocketListener> = None; #[doc(alias = "g_socket_listener_new")] pub fn new() -> SocketListener { unsafe { from_glib_full(ffi::g_socket_listener_new()) } } } impl Default for SocketListener { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketListenerExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_listener_accept")] fn accept( &self, cancellable: Option<&impl IsA>, ) -> Result<(SocketConnection, Option), glib::Error> { unsafe { let mut source_object = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_listener_accept( self.as_ref().to_glib_none().0, &mut source_object, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_accept_async")] fn accept_async< P: FnOnce(Result<(SocketConnection, Option), glib::Error>) + 'static, >( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn accept_async_trampoline< P: FnOnce(Result<(SocketConnection, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut source_object = std::ptr::null_mut(); let ret = ffi::g_socket_listener_accept_finish( _source_object as *mut _, res, &mut source_object, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = accept_async_trampoline::

; unsafe { ffi::g_socket_listener_accept_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn accept_future( &self, ) -> Pin< Box_< dyn std::future::Future< Output = Result<(SocketConnection, Option), glib::Error>, > + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.accept_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_listener_accept_socket")] fn accept_socket( &self, cancellable: Option<&impl IsA>, ) -> Result<(Socket, Option), glib::Error> { unsafe { let mut source_object = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_listener_accept_socket( self.as_ref().to_glib_none().0, &mut source_object, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_accept_socket_async")] fn accept_socket_async< P: FnOnce(Result<(Socket, Option), glib::Error>) + 'static, >( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn accept_socket_async_trampoline< P: FnOnce(Result<(Socket, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut source_object = std::ptr::null_mut(); let ret = ffi::g_socket_listener_accept_socket_finish( _source_object as *mut _, res, &mut source_object, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_none(source_object))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = accept_socket_async_trampoline::

; unsafe { ffi::g_socket_listener_accept_socket_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn accept_socket_future( &self, ) -> Pin< Box_< dyn std::future::Future), glib::Error>> + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.accept_socket_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_socket_listener_add_address")] fn add_address( &self, address: &impl IsA, type_: SocketType, protocol: SocketProtocol, source_object: Option<&impl IsA>, ) -> Result { unsafe { let mut effective_address = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_listener_add_address( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, type_.into_glib(), protocol.into_glib(), source_object.map(|p| p.as_ref()).to_glib_none().0, &mut effective_address, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(from_glib_full(effective_address)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_add_any_inet_port")] fn add_any_inet_port( &self, source_object: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_socket_listener_add_any_inet_port( self.as_ref().to_glib_none().0, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_add_inet_port")] fn add_inet_port( &self, port: u16, source_object: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_listener_add_inet_port( self.as_ref().to_glib_none().0, port, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_add_socket")] fn add_socket( &self, socket: &impl IsA, source_object: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_socket_listener_add_socket( self.as_ref().to_glib_none().0, socket.as_ref().to_glib_none().0, source_object.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_listener_close")] fn close(&self) { unsafe { ffi::g_socket_listener_close(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_socket_listener_set_backlog")] fn set_backlog(&self, listen_backlog: i32) { unsafe { ffi::g_socket_listener_set_backlog(self.as_ref().to_glib_none().0, listen_backlog); } } #[doc(alias = "listen-backlog")] fn listen_backlog(&self) -> i32 { ObjectExt::property(self.as_ref(), "listen-backlog") } #[doc(alias = "listen-backlog")] fn set_listen_backlog(&self, listen_backlog: i32) { ObjectExt::set_property(self.as_ref(), "listen-backlog", listen_backlog) } #[doc(alias = "event")] fn connect_event( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn event_trampoline< P: IsA, F: Fn(&P, SocketListenerEvent, &Socket) + 'static, >( this: *mut ffi::GSocketListener, event: ffi::GSocketListenerEvent, socket: *mut ffi::GSocket, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( SocketListener::from_glib_borrow(this).unsafe_cast_ref(), from_glib(event), &from_glib_borrow(socket), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"event\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "listen-backlog")] fn connect_listen_backlog_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_listen_backlog_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketListener, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketListener::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::listen-backlog\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_listen_backlog_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SocketListenerExt for O {} gio-0.20.1/src/auto/socket_service.rs000064400000000000000000000100531046102023000155760ustar 00000000000000// 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::{ffi, SocketConnection, SocketListener}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSocketService")] pub struct SocketService(Object) @extends SocketListener; match fn { type_ => || ffi::g_socket_service_get_type(), } } impl SocketService { pub const NONE: Option<&'static SocketService> = None; #[doc(alias = "g_socket_service_new")] pub fn new() -> SocketService { unsafe { from_glib_full(ffi::g_socket_service_new()) } } } impl Default for SocketService { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketServiceExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_socket_service_is_active")] #[doc(alias = "active")] fn is_active(&self) -> bool { unsafe { from_glib(ffi::g_socket_service_is_active( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_socket_service_start")] fn start(&self) { unsafe { ffi::g_socket_service_start(self.as_ref().to_glib_none().0); } } #[doc(alias = "g_socket_service_stop")] fn stop(&self) { unsafe { ffi::g_socket_service_stop(self.as_ref().to_glib_none().0); } } fn set_active(&self, active: bool) { ObjectExt::set_property(self.as_ref(), "active", active) } #[doc(alias = "incoming")] fn connect_incoming< F: Fn(&Self, &SocketConnection, Option<&glib::Object>) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn incoming_trampoline< P: IsA, F: Fn(&P, &SocketConnection, Option<&glib::Object>) -> bool + 'static, >( this: *mut ffi::GSocketService, connection: *mut ffi::GSocketConnection, source_object: *mut glib::gobject_ffi::GObject, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( SocketService::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(connection), Option::::from_glib_borrow(source_object) .as_ref() .as_ref(), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"incoming\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( incoming_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "active")] fn connect_active_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_active_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GSocketService, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(SocketService::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::active\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_active_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> SocketServiceExt for O {} gio-0.20.1/src/auto/srv_target.rs000064400000000000000000000035661046102023000147610ustar 00000000000000// 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::ffi; use glib::translate::*; glib::wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct SrvTarget(Boxed); match fn { copy => |ptr| ffi::g_srv_target_copy(mut_override(ptr)), free => |ptr| ffi::g_srv_target_free(ptr), type_ => || ffi::g_srv_target_get_type(), } } impl SrvTarget { #[doc(alias = "g_srv_target_new")] pub fn new(hostname: &str, port: u16, priority: u16, weight: u16) -> SrvTarget { unsafe { from_glib_full(ffi::g_srv_target_new( hostname.to_glib_none().0, port, priority, weight, )) } } #[doc(alias = "g_srv_target_get_hostname")] #[doc(alias = "get_hostname")] pub fn hostname(&mut self) -> glib::GString { unsafe { from_glib_none(ffi::g_srv_target_get_hostname(self.to_glib_none_mut().0)) } } #[doc(alias = "g_srv_target_get_port")] #[doc(alias = "get_port")] pub fn port(&mut self) -> u16 { unsafe { ffi::g_srv_target_get_port(self.to_glib_none_mut().0) } } #[doc(alias = "g_srv_target_get_priority")] #[doc(alias = "get_priority")] pub fn priority(&mut self) -> u16 { unsafe { ffi::g_srv_target_get_priority(self.to_glib_none_mut().0) } } #[doc(alias = "g_srv_target_get_weight")] #[doc(alias = "get_weight")] pub fn weight(&mut self) -> u16 { unsafe { ffi::g_srv_target_get_weight(self.to_glib_none_mut().0) } } //#[doc(alias = "g_srv_target_list_sort")] //pub fn list_sort(targets: /*Unimplemented*/&[&Basic: Pointer]) -> /*Unimplemented*/Vec { // unsafe { TODO: call ffi:g_srv_target_list_sort() } //} } gio-0.20.1/src/auto/subprocess.rs000064400000000000000000000355471046102023000147750ustar 00000000000000// 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::{ffi, AsyncResult, Cancellable, Initable, InputStream, OutputStream, SubprocessFlags}; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GSubprocess")] pub struct Subprocess(Object) @implements Initable; match fn { type_ => || ffi::g_subprocess_get_type(), } } impl Subprocess { //#[doc(alias = "g_subprocess_new")] //pub fn new(flags: SubprocessFlags, error: Option<&mut glib::Error>, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Subprocess { // unsafe { TODO: call ffi:g_subprocess_new() } //} #[doc(alias = "g_subprocess_newv")] pub fn newv( argv: &[&std::ffi::OsStr], flags: SubprocessFlags, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_subprocess_newv(argv.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_subprocess_communicate")] pub fn communicate( &self, stdin_buf: Option<&glib::Bytes>, cancellable: Option<&impl IsA>, ) -> Result<(Option, Option), glib::Error> { unsafe { let mut stdout_buf = std::ptr::null_mut(); let mut stderr_buf = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_subprocess_communicate( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut stdout_buf, &mut stderr_buf, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_communicate_async")] pub fn communicate_async< P: FnOnce(Result<(Option, Option), glib::Error>) + 'static, >( &self, stdin_buf: Option<&glib::Bytes>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn communicate_async_trampoline< P: FnOnce(Result<(Option, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut stdout_buf = std::ptr::null_mut(); let mut stderr_buf = std::ptr::null_mut(); let _ = ffi::g_subprocess_communicate_finish( _source_object as *mut _, res, &mut stdout_buf, &mut stderr_buf, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = communicate_async_trampoline::

; unsafe { ffi::g_subprocess_communicate_async( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn communicate_future( &self, stdin_buf: Option<&glib::Bytes>, ) -> Pin< Box_< dyn std::future::Future< Output = Result<(Option, Option), glib::Error>, > + 'static, >, > { let stdin_buf = stdin_buf.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.communicate_async( stdin_buf.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_subprocess_communicate_utf8")] pub fn communicate_utf8( &self, stdin_buf: Option<&str>, cancellable: Option<&impl IsA>, ) -> Result<(Option, Option), glib::Error> { unsafe { let mut stdout_buf = std::ptr::null_mut(); let mut stderr_buf = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_subprocess_communicate_utf8( self.to_glib_none().0, stdin_buf.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut stdout_buf, &mut stderr_buf, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_force_exit")] pub fn force_exit(&self) { unsafe { ffi::g_subprocess_force_exit(self.to_glib_none().0); } } #[doc(alias = "g_subprocess_get_exit_status")] #[doc(alias = "get_exit_status")] pub fn exit_status(&self) -> i32 { unsafe { ffi::g_subprocess_get_exit_status(self.to_glib_none().0) } } #[doc(alias = "g_subprocess_get_identifier")] #[doc(alias = "get_identifier")] pub fn identifier(&self) -> Option { unsafe { from_glib_none(ffi::g_subprocess_get_identifier(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_if_exited")] #[doc(alias = "get_if_exited")] pub fn has_exited(&self) -> bool { unsafe { from_glib(ffi::g_subprocess_get_if_exited(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_if_signaled")] #[doc(alias = "get_if_signaled")] pub fn has_signaled(&self) -> bool { unsafe { from_glib(ffi::g_subprocess_get_if_signaled(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_status")] #[doc(alias = "get_status")] pub fn status(&self) -> i32 { unsafe { ffi::g_subprocess_get_status(self.to_glib_none().0) } } #[doc(alias = "g_subprocess_get_stderr_pipe")] #[doc(alias = "get_stderr_pipe")] pub fn stderr_pipe(&self) -> Option { unsafe { from_glib_none(ffi::g_subprocess_get_stderr_pipe(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_stdin_pipe")] #[doc(alias = "get_stdin_pipe")] pub fn stdin_pipe(&self) -> Option { unsafe { from_glib_none(ffi::g_subprocess_get_stdin_pipe(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_stdout_pipe")] #[doc(alias = "get_stdout_pipe")] pub fn stdout_pipe(&self) -> Option { unsafe { from_glib_none(ffi::g_subprocess_get_stdout_pipe(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_successful")] #[doc(alias = "get_successful")] pub fn is_successful(&self) -> bool { unsafe { from_glib(ffi::g_subprocess_get_successful(self.to_glib_none().0)) } } #[doc(alias = "g_subprocess_get_term_sig")] #[doc(alias = "get_term_sig")] pub fn term_sig(&self) -> i32 { unsafe { ffi::g_subprocess_get_term_sig(self.to_glib_none().0) } } #[cfg(not(windows))] #[cfg_attr(docsrs, doc(cfg(not(windows))))] #[doc(alias = "g_subprocess_send_signal")] pub fn send_signal(&self, signal_num: i32) { unsafe { ffi::g_subprocess_send_signal(self.to_glib_none().0, signal_num); } } #[doc(alias = "g_subprocess_wait")] pub fn wait(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_subprocess_wait( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_wait_async")] pub fn wait_async) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn wait_async_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_subprocess_wait_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = wait_async_trampoline::

; unsafe { ffi::g_subprocess_wait_async( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn wait_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.wait_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_subprocess_wait_check")] pub fn wait_check( &self, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_subprocess_wait_check( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_wait_check_async")] pub fn wait_check_async) + 'static>( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn wait_check_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_subprocess_wait_check_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = wait_check_async_trampoline::

; unsafe { ffi::g_subprocess_wait_check_async( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } pub fn wait_check_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.wait_check_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } } gio-0.20.1/src/auto/subprocess_launcher.rs000064400000000000000000000137501046102023000166460ustar 00000000000000// 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::{ffi, Subprocess, SubprocessFlags}; use glib::translate::*; #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GSubprocessLauncher")] pub struct SubprocessLauncher(Object); match fn { type_ => || ffi::g_subprocess_launcher_get_type(), } } impl SubprocessLauncher { #[doc(alias = "g_subprocess_launcher_new")] pub fn new(flags: SubprocessFlags) -> SubprocessLauncher { unsafe { from_glib_full(ffi::g_subprocess_launcher_new(flags.into_glib())) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "g_subprocess_launcher_close")] pub fn close(&self) { unsafe { ffi::g_subprocess_launcher_close(self.to_glib_none().0); } } #[doc(alias = "g_subprocess_launcher_getenv")] pub fn getenv(&self, variable: impl AsRef) -> Option { unsafe { from_glib_none(ffi::g_subprocess_launcher_getenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, )) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_child_setup")] pub fn set_child_setup(&self, child_setup: P) { let child_setup_data: Box_

= Box_::new(child_setup); unsafe extern "C" fn child_setup_func(data: glib::ffi::gpointer) { let callback = &*(data as *mut P); (*callback)() } let child_setup = Some(child_setup_func::

as _); unsafe extern "C" fn destroy_notify_func(data: glib::ffi::gpointer) { let _callback = Box_::from_raw(data as *mut P); } let destroy_call3 = Some(destroy_notify_func::

as _); let super_callback0: Box_

= child_setup_data; unsafe { ffi::g_subprocess_launcher_set_child_setup( self.to_glib_none().0, child_setup, Box_::into_raw(super_callback0) as *mut _, destroy_call3, ); } } #[doc(alias = "g_subprocess_launcher_set_cwd")] pub fn set_cwd(&self, cwd: impl AsRef) { unsafe { ffi::g_subprocess_launcher_set_cwd( self.to_glib_none().0, cwd.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_subprocess_launcher_set_environ")] pub fn set_environ(&self, env: &[&std::path::Path]) { unsafe { ffi::g_subprocess_launcher_set_environ(self.to_glib_none().0, env.to_glib_none().0); } } #[doc(alias = "g_subprocess_launcher_set_flags")] pub fn set_flags(&self, flags: SubprocessFlags) { unsafe { ffi::g_subprocess_launcher_set_flags(self.to_glib_none().0, flags.into_glib()); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stderr_file_path")] pub fn set_stderr_file_path(&self, path: Option>) { unsafe { ffi::g_subprocess_launcher_set_stderr_file_path( self.to_glib_none().0, path.as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stdin_file_path")] pub fn set_stdin_file_path(&self, path: Option>) { unsafe { ffi::g_subprocess_launcher_set_stdin_file_path( self.to_glib_none().0, path.as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stdout_file_path")] pub fn set_stdout_file_path(&self, path: Option>) { unsafe { ffi::g_subprocess_launcher_set_stdout_file_path( self.to_glib_none().0, path.as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_subprocess_launcher_setenv")] pub fn setenv( &self, variable: impl AsRef, value: impl AsRef, overwrite: bool, ) { unsafe { ffi::g_subprocess_launcher_setenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, value.as_ref().to_glib_none().0, overwrite.into_glib(), ); } } //#[doc(alias = "g_subprocess_launcher_spawn")] //pub fn spawn(&self, error: &mut glib::Error, argv0: &str, : /*Unknown conversion*//*Unimplemented*/Basic: VarArgs) -> Subprocess { // unsafe { TODO: call ffi:g_subprocess_launcher_spawn() } //} #[doc(alias = "g_subprocess_launcher_spawnv")] #[doc(alias = "spawnv")] pub fn spawn(&self, argv: &[&std::ffi::OsStr]) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_subprocess_launcher_spawnv( self.to_glib_none().0, argv.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_launcher_unsetenv")] pub fn unsetenv(&self, variable: impl AsRef) { unsafe { ffi::g_subprocess_launcher_unsetenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } } gio-0.20.1/src/auto/tcp_connection.rs000064400000000000000000000050671046102023000156040ustar 00000000000000// 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::{ffi, IOStream, SocketConnection}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTcpConnection")] pub struct TcpConnection(Object) @extends SocketConnection, IOStream; match fn { type_ => || ffi::g_tcp_connection_get_type(), } } impl TcpConnection { pub const NONE: Option<&'static TcpConnection> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TcpConnectionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tcp_connection_get_graceful_disconnect")] #[doc(alias = "get_graceful_disconnect")] #[doc(alias = "graceful-disconnect")] fn is_graceful_disconnect(&self) -> bool { unsafe { from_glib(ffi::g_tcp_connection_get_graceful_disconnect( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tcp_connection_set_graceful_disconnect")] #[doc(alias = "graceful-disconnect")] fn set_graceful_disconnect(&self, graceful_disconnect: bool) { unsafe { ffi::g_tcp_connection_set_graceful_disconnect( self.as_ref().to_glib_none().0, graceful_disconnect.into_glib(), ); } } #[doc(alias = "graceful-disconnect")] fn connect_graceful_disconnect_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_graceful_disconnect_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTcpConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TcpConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::graceful-disconnect\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_graceful_disconnect_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TcpConnectionExt for O {} gio-0.20.1/src/auto/themed_icon.rs000064400000000000000000000061221046102023000150460ustar 00000000000000// 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::{ffi, Icon}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GThemedIcon")] pub struct ThemedIcon(Object) @implements Icon; match fn { type_ => || ffi::g_themed_icon_get_type(), } } impl ThemedIcon { #[doc(alias = "g_themed_icon_new")] pub fn new(iconname: &str) -> ThemedIcon { unsafe { from_glib_full(ffi::g_themed_icon_new(iconname.to_glib_none().0)) } } #[doc(alias = "g_themed_icon_new_from_names")] #[doc(alias = "new_from_names")] pub fn from_names(iconnames: &[&str]) -> ThemedIcon { let len = iconnames.len() as _; unsafe { from_glib_full(ffi::g_themed_icon_new_from_names( iconnames.to_glib_none().0, len, )) } } #[doc(alias = "g_themed_icon_new_with_default_fallbacks")] #[doc(alias = "new_with_default_fallbacks")] pub fn with_default_fallbacks(iconname: &str) -> ThemedIcon { unsafe { from_glib_full(ffi::g_themed_icon_new_with_default_fallbacks( iconname.to_glib_none().0, )) } } #[doc(alias = "g_themed_icon_append_name")] pub fn append_name(&self, iconname: &str) { unsafe { ffi::g_themed_icon_append_name(self.to_glib_none().0, iconname.to_glib_none().0); } } #[doc(alias = "g_themed_icon_get_names")] #[doc(alias = "get_names")] pub fn names(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_themed_icon_get_names( self.to_glib_none().0, )) } } #[doc(alias = "g_themed_icon_prepend_name")] pub fn prepend_name(&self, iconname: &str) { unsafe { ffi::g_themed_icon_prepend_name(self.to_glib_none().0, iconname.to_glib_none().0); } } #[doc(alias = "use-default-fallbacks")] pub fn uses_default_fallbacks(&self) -> bool { ObjectExt::property(self, "use-default-fallbacks") } #[doc(alias = "names")] pub fn connect_names_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_names_trampoline( this: *mut ffi::GThemedIcon, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::names\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_names_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/auto/threaded_socket_service.rs000064400000000000000000000046751046102023000174530ustar 00000000000000// 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::{ffi, SocketConnection, SocketListener, SocketService}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GThreadedSocketService")] pub struct ThreadedSocketService(Object) @extends SocketService, SocketListener; match fn { type_ => || ffi::g_threaded_socket_service_get_type(), } } impl ThreadedSocketService { pub const NONE: Option<&'static ThreadedSocketService> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ThreadedSocketServiceExt: IsA + sealed::Sealed + 'static { #[doc(alias = "max-threads")] fn max_threads(&self) -> i32 { ObjectExt::property(self.as_ref(), "max-threads") } #[doc(alias = "run")] fn connect_run) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn run_trampoline< P: IsA, F: Fn(&P, &SocketConnection, Option<&glib::Object>) -> bool + 'static, >( this: *mut ffi::GThreadedSocketService, connection: *mut ffi::GSocketConnection, source_object: *mut glib::gobject_ffi::GObject, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( ThreadedSocketService::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(connection), Option::::from_glib_borrow(source_object) .as_ref() .as_ref(), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"run\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( run_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> ThreadedSocketServiceExt for O {} gio-0.20.1/src/auto/tls_backend.rs000064400000000000000000000101551046102023000150420ustar 00000000000000// 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::{ffi, TlsDatabase}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GTlsBackend")] pub struct TlsBackend(Interface); match fn { type_ => || ffi::g_tls_backend_get_type(), } } impl TlsBackend { pub const NONE: Option<&'static TlsBackend> = None; #[doc(alias = "g_tls_backend_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> TlsBackend { unsafe { from_glib_none(ffi::g_tls_backend_get_default()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsBackendExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_backend_get_certificate_type")] #[doc(alias = "get_certificate_type")] fn certificate_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_certificate_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_client_connection_type")] #[doc(alias = "get_client_connection_type")] fn client_connection_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_client_connection_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_default_database")] #[doc(alias = "get_default_database")] fn default_database(&self) -> TlsDatabase { unsafe { from_glib_full(ffi::g_tls_backend_get_default_database( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_dtls_client_connection_type")] #[doc(alias = "get_dtls_client_connection_type")] fn dtls_client_connection_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_dtls_client_connection_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_dtls_server_connection_type")] #[doc(alias = "get_dtls_server_connection_type")] fn dtls_server_connection_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_dtls_server_connection_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_file_database_type")] #[doc(alias = "get_file_database_type")] fn file_database_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_file_database_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_get_server_connection_type")] #[doc(alias = "get_server_connection_type")] fn server_connection_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_server_connection_type( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_backend_set_default_database")] fn set_default_database(&self, database: Option<&impl IsA>) { unsafe { ffi::g_tls_backend_set_default_database( self.as_ref().to_glib_none().0, database.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_tls_backend_supports_dtls")] fn supports_dtls(&self) -> bool { unsafe { from_glib(ffi::g_tls_backend_supports_dtls( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_backend_supports_tls")] fn supports_tls(&self) -> bool { unsafe { from_glib(ffi::g_tls_backend_supports_tls( self.as_ref().to_glib_none().0, )) } } } impl> TlsBackendExt for O {} gio-0.20.1/src/auto/tls_certificate.rs000064400000000000000000000412001046102023000157300ustar 00000000000000// 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_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] use crate::InetAddress; use crate::{ffi, SocketConnectable, TlsCertificateFlags}; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] use glib::signal::{connect_raw, SignalHandlerId}; use glib::{prelude::*, translate::*}; #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTlsCertificate")] pub struct TlsCertificate(Object); match fn { type_ => || ffi::g_tls_certificate_get_type(), } } impl TlsCertificate { pub const NONE: Option<&'static TlsCertificate> = None; #[doc(alias = "g_tls_certificate_new_from_file")] #[doc(alias = "new_from_file")] pub fn from_file(file: impl AsRef) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_file(file.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "g_tls_certificate_new_from_file_with_password")] #[doc(alias = "new_from_file_with_password")] pub fn from_file_with_password( file: impl AsRef, password: &str, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_file_with_password( file.as_ref().to_glib_none().0, password.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_certificate_new_from_files")] #[doc(alias = "new_from_files")] pub fn from_files( cert_file: impl AsRef, key_file: impl AsRef, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_files( cert_file.as_ref().to_glib_none().0, key_file.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_tls_certificate_new_from_pem")] #[doc(alias = "new_from_pem")] pub fn from_pem(data: &str) -> Result { let length = data.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_pem(data.to_glib_none().0, length, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "g_tls_certificate_new_from_pkcs11_uris")] #[doc(alias = "new_from_pkcs11_uris")] pub fn from_pkcs11_uris( pkcs11_uri: &str, private_key_pkcs11_uri: Option<&str>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_pkcs11_uris( pkcs11_uri.to_glib_none().0, private_key_pkcs11_uri.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "g_tls_certificate_new_from_pkcs12")] #[doc(alias = "new_from_pkcs12")] pub fn from_pkcs12(data: &[u8], password: Option<&str>) -> Result { let length = data.len() as _; unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_new_from_pkcs12( data.to_glib_none().0, length, password.to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_certificate_list_new_from_file")] pub fn list_new_from_file( file: impl AsRef, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_certificate_list_new_from_file( file.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsCertificateExt: IsA + sealed::Sealed + 'static { #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_dns_names")] #[doc(alias = "get_dns_names")] #[doc(alias = "dns-names")] fn dns_names(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::g_tls_certificate_get_dns_names( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_ip_addresses")] #[doc(alias = "get_ip_addresses")] #[doc(alias = "ip-addresses")] fn ip_addresses(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_container(ffi::g_tls_certificate_get_ip_addresses( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_certificate_get_issuer")] #[doc(alias = "get_issuer")] #[must_use] fn issuer(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_certificate_get_issuer( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_issuer_name")] #[doc(alias = "get_issuer_name")] #[doc(alias = "issuer-name")] fn issuer_name(&self) -> Option { unsafe { from_glib_full(ffi::g_tls_certificate_get_issuer_name( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_not_valid_after")] #[doc(alias = "get_not_valid_after")] #[doc(alias = "not-valid-after")] fn not_valid_after(&self) -> Option { unsafe { from_glib_full(ffi::g_tls_certificate_get_not_valid_after( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_not_valid_before")] #[doc(alias = "get_not_valid_before")] #[doc(alias = "not-valid-before")] fn not_valid_before(&self) -> Option { unsafe { from_glib_full(ffi::g_tls_certificate_get_not_valid_before( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_certificate_get_subject_name")] #[doc(alias = "get_subject_name")] #[doc(alias = "subject-name")] fn subject_name(&self) -> Option { unsafe { from_glib_full(ffi::g_tls_certificate_get_subject_name( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_certificate_is_same")] fn is_same(&self, cert_two: &impl IsA) -> bool { unsafe { from_glib(ffi::g_tls_certificate_is_same( self.as_ref().to_glib_none().0, cert_two.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_certificate_verify")] fn verify( &self, identity: Option<&impl IsA>, trusted_ca: Option<&impl IsA>, ) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_tls_certificate_verify( self.as_ref().to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, trusted_ca.map(|p| p.as_ref()).to_glib_none().0, )) } } fn certificate(&self) -> Option { ObjectExt::property(self.as_ref(), "certificate") } #[doc(alias = "certificate-pem")] fn certificate_pem(&self) -> Option { ObjectExt::property(self.as_ref(), "certificate-pem") } #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "pkcs11-uri")] fn pkcs11_uri(&self) -> Option { ObjectExt::property(self.as_ref(), "pkcs11-uri") } #[doc(alias = "private-key")] fn private_key(&self) -> Option { ObjectExt::property(self.as_ref(), "private-key") } #[doc(alias = "private-key-pem")] fn private_key_pem(&self) -> Option { ObjectExt::property(self.as_ref(), "private-key-pem") } #[cfg(feature = "v2_68")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_68")))] #[doc(alias = "private-key-pkcs11-uri")] fn private_key_pkcs11_uri(&self) -> Option { ObjectExt::property(self.as_ref(), "private-key-pkcs11-uri") } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "dns-names")] fn connect_dns_names_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_dns_names_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::dns-names\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_dns_names_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "ip-addresses")] fn connect_ip_addresses_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ip_addresses_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ip-addresses\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ip_addresses_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "issuer-name")] fn connect_issuer_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_issuer_name_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::issuer-name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_issuer_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "not-valid-after")] fn connect_not_valid_after_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_not_valid_after_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::not-valid-after\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_not_valid_after_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "not-valid-before")] fn connect_not_valid_before_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_not_valid_before_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::not-valid-before\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_not_valid_before_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "subject-name")] fn connect_subject_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_subject_name_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsCertificate, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsCertificate::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::subject-name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_subject_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsCertificateExt for O {} gio-0.20.1/src/auto/tls_client_connection.rs000064400000000000000000000157631046102023000171620ustar 00000000000000// 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(deprecated)] use crate::{ffi, IOStream, SocketConnectable, TlsCertificateFlags, TlsConnection}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTlsClientConnection")] pub struct TlsClientConnection(Interface) @requires TlsConnection, IOStream; match fn { type_ => || ffi::g_tls_client_connection_get_type(), } } impl TlsClientConnection { pub const NONE: Option<&'static TlsClientConnection> = None; #[doc(alias = "g_tls_client_connection_new")] pub fn new( base_io_stream: &impl IsA, server_identity: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_client_connection_new( base_io_stream.as_ref().to_glib_none().0, server_identity.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsClientConnectionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_client_connection_copy_session_state")] fn copy_session_state(&self, source: &impl IsA) { unsafe { ffi::g_tls_client_connection_copy_session_state( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_tls_client_connection_get_accepted_cas")] #[doc(alias = "get_accepted_cas")] #[doc(alias = "accepted-cas")] fn accepted_cas(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_tls_client_connection_get_accepted_cas( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_client_connection_get_server_identity")] #[doc(alias = "get_server_identity")] #[doc(alias = "server-identity")] fn server_identity(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_client_connection_get_server_identity( self.as_ref().to_glib_none().0, )) } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[allow(deprecated)] #[doc(alias = "g_tls_client_connection_get_validation_flags")] #[doc(alias = "get_validation_flags")] #[doc(alias = "validation-flags")] fn validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_tls_client_connection_get_validation_flags( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_client_connection_set_server_identity")] #[doc(alias = "server-identity")] fn set_server_identity(&self, identity: &impl IsA) { unsafe { ffi::g_tls_client_connection_set_server_identity( self.as_ref().to_glib_none().0, identity.as_ref().to_glib_none().0, ); } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[allow(deprecated)] #[doc(alias = "g_tls_client_connection_set_validation_flags")] #[doc(alias = "validation-flags")] fn set_validation_flags(&self, flags: TlsCertificateFlags) { unsafe { ffi::g_tls_client_connection_set_validation_flags( self.as_ref().to_glib_none().0, flags.into_glib(), ); } } #[doc(alias = "accepted-cas")] fn connect_accepted_cas_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_accepted_cas_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsClientConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::accepted-cas\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_accepted_cas_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "server-identity")] fn connect_server_identity_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_server_identity_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsClientConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::server-identity\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_server_identity_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg_attr(feature = "v2_72", deprecated = "Since 2.72")] #[doc(alias = "validation-flags")] fn connect_validation_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_validation_flags_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsClientConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsClientConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::validation-flags\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_validation_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsClientConnectionExt for O {} gio-0.20.1/src/auto/tls_connection.rs000064400000000000000000000556251046102023000156250ustar 00000000000000// 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(deprecated)] #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] use crate::TlsProtocolVersion; use crate::{ ffi, AsyncResult, Cancellable, IOStream, TlsCertificate, TlsCertificateFlags, TlsDatabase, TlsInteraction, TlsRehandshakeMode, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GTlsConnection")] pub struct TlsConnection(Object) @extends IOStream; match fn { type_ => || ffi::g_tls_connection_get_type(), } } impl TlsConnection { pub const NONE: Option<&'static TlsConnection> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsConnectionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_connection_emit_accept_certificate")] fn emit_accept_certificate( &self, peer_cert: &impl IsA, errors: TlsCertificateFlags, ) -> bool { unsafe { from_glib(ffi::g_tls_connection_emit_accept_certificate( self.as_ref().to_glib_none().0, peer_cert.as_ref().to_glib_none().0, errors.into_glib(), )) } } #[doc(alias = "g_tls_connection_get_certificate")] #[doc(alias = "get_certificate")] fn certificate(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_certificate( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_connection_get_ciphersuite_name")] #[doc(alias = "get_ciphersuite_name")] #[doc(alias = "ciphersuite-name")] fn ciphersuite_name(&self) -> Option { unsafe { from_glib_full(ffi::g_tls_connection_get_ciphersuite_name( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_get_database")] #[doc(alias = "get_database")] fn database(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_database( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_get_interaction")] #[doc(alias = "get_interaction")] fn interaction(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_interaction( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_connection_get_negotiated_protocol")] #[doc(alias = "get_negotiated_protocol")] #[doc(alias = "negotiated-protocol")] fn negotiated_protocol(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_negotiated_protocol( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_get_peer_certificate")] #[doc(alias = "get_peer_certificate")] #[doc(alias = "peer-certificate")] fn peer_certificate(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_peer_certificate( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_get_peer_certificate_errors")] #[doc(alias = "get_peer_certificate_errors")] #[doc(alias = "peer-certificate-errors")] fn peer_certificate_errors(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_tls_connection_get_peer_certificate_errors( self.as_ref().to_glib_none().0, )) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "g_tls_connection_get_protocol_version")] #[doc(alias = "get_protocol_version")] #[doc(alias = "protocol-version")] fn protocol_version(&self) -> TlsProtocolVersion { unsafe { from_glib(ffi::g_tls_connection_get_protocol_version( self.as_ref().to_glib_none().0, )) } } #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[allow(deprecated)] #[doc(alias = "g_tls_connection_get_rehandshake_mode")] #[doc(alias = "get_rehandshake_mode")] #[doc(alias = "rehandshake-mode")] fn rehandshake_mode(&self) -> TlsRehandshakeMode { unsafe { from_glib(ffi::g_tls_connection_get_rehandshake_mode( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_get_require_close_notify")] #[doc(alias = "get_require_close_notify")] #[doc(alias = "require-close-notify")] fn requires_close_notify(&self) -> bool { unsafe { from_glib(ffi::g_tls_connection_get_require_close_notify( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_connection_handshake")] fn handshake(&self, cancellable: Option<&impl IsA>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_tls_connection_handshake( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_connection_handshake_async")] fn handshake_async) + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn handshake_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_tls_connection_handshake_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = handshake_async_trampoline::

; unsafe { ffi::g_tls_connection_handshake_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn handshake_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.handshake_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_tls_connection_set_certificate")] #[doc(alias = "certificate")] fn set_certificate(&self, certificate: &impl IsA) { unsafe { ffi::g_tls_connection_set_certificate( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_tls_connection_set_database")] #[doc(alias = "database")] fn set_database(&self, database: Option<&impl IsA>) { unsafe { ffi::g_tls_connection_set_database( self.as_ref().to_glib_none().0, database.map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "g_tls_connection_set_interaction")] #[doc(alias = "interaction")] fn set_interaction(&self, interaction: Option<&impl IsA>) { unsafe { ffi::g_tls_connection_set_interaction( self.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, ); } } #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[allow(deprecated)] #[doc(alias = "g_tls_connection_set_rehandshake_mode")] #[doc(alias = "rehandshake-mode")] fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode) { unsafe { ffi::g_tls_connection_set_rehandshake_mode( self.as_ref().to_glib_none().0, mode.into_glib(), ); } } #[doc(alias = "g_tls_connection_set_require_close_notify")] #[doc(alias = "require-close-notify")] fn set_require_close_notify(&self, require_close_notify: bool) { unsafe { ffi::g_tls_connection_set_require_close_notify( self.as_ref().to_glib_none().0, require_close_notify.into_glib(), ); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "advertised-protocols")] fn advertised_protocols(&self) -> Vec { ObjectExt::property(self.as_ref(), "advertised-protocols") } #[doc(alias = "base-io-stream")] fn base_io_stream(&self) -> Option { ObjectExt::property(self.as_ref(), "base-io-stream") } #[doc(alias = "accept-certificate")] fn connect_accept_certificate< F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn accept_certificate_trampoline< P: IsA, F: Fn(&P, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( this: *mut ffi::GTlsConnection, peer_cert: *mut ffi::GTlsCertificate, errors: ffi::GTlsCertificateFlags, f: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let f: &F = &*(f as *const F); f( TlsConnection::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(peer_cert), from_glib(errors), ) .into_glib() } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"accept-certificate\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( accept_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "advertised-protocols")] fn connect_advertised_protocols_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_advertised_protocols_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::advertised-protocols\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_advertised_protocols_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "certificate")] fn connect_certificate_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_certificate_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::certificate\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "ciphersuite-name")] fn connect_ciphersuite_name_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ciphersuite_name_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::ciphersuite-name\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_ciphersuite_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "database")] fn connect_database_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_database_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::database\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_database_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "interaction")] fn connect_interaction_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_interaction_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::interaction\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_interaction_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "negotiated-protocol")] fn connect_negotiated_protocol_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_negotiated_protocol_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::negotiated-protocol\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_negotiated_protocol_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "peer-certificate")] fn connect_peer_certificate_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_peer_certificate_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::peer-certificate\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_peer_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "peer-certificate-errors")] fn connect_peer_certificate_errors_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_peer_certificate_errors_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::peer-certificate-errors\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_peer_certificate_errors_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(feature = "v2_70")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_70")))] #[doc(alias = "protocol-version")] fn connect_protocol_version_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_protocol_version_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::protocol-version\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_protocol_version_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[doc(alias = "rehandshake-mode")] fn connect_rehandshake_mode_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_rehandshake_mode_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::rehandshake-mode\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_rehandshake_mode_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "require-close-notify")] fn connect_require_close_notify_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_require_close_notify_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::require-close-notify\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_require_close_notify_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsConnectionExt for O {} gio-0.20.1/src/auto/tls_database.rs000064400000000000000000000455671046102023000152360ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, SocketConnectable, TlsCertificate, TlsCertificateFlags, TlsDatabaseLookupFlags, TlsDatabaseVerifyFlags, TlsInteraction, }; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GTlsDatabase")] pub struct TlsDatabase(Object); match fn { type_ => || ffi::g_tls_database_get_type(), } } impl TlsDatabase { pub const NONE: Option<&'static TlsDatabase> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsDatabaseExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_database_create_certificate_handle")] fn create_certificate_handle( &self, certificate: &impl IsA, ) -> Option { unsafe { from_glib_full(ffi::g_tls_database_create_certificate_handle( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_database_lookup_certificate_for_handle")] fn lookup_certificate_for_handle( &self, handle: &str, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificate_for_handle( self.as_ref().to_glib_none().0, handle.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_tls_database_lookup_certificate_for_handle_async")] fn lookup_certificate_for_handle_async< P: FnOnce(Result) + 'static, >( &self, handle: &str, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_certificate_for_handle_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificate_for_handle_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_certificate_for_handle_async_trampoline::

; unsafe { ffi::g_tls_database_lookup_certificate_for_handle_async( self.as_ref().to_glib_none().0, handle.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_certificate_for_handle_future( &self, handle: &str, interaction: Option<&(impl IsA + Clone + 'static)>, flags: TlsDatabaseLookupFlags, ) -> Pin> + 'static>> { let handle = String::from(handle); let interaction = interaction.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_certificate_for_handle_async( &handle, interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_tls_database_lookup_certificate_issuer")] fn lookup_certificate_issuer( &self, certificate: &impl IsA, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificate_issuer( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.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_tls_database_lookup_certificate_issuer_async")] fn lookup_certificate_issuer_async) + 'static>( &self, certificate: &impl IsA, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_certificate_issuer_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificate_issuer_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_certificate_issuer_async_trampoline::

; unsafe { ffi::g_tls_database_lookup_certificate_issuer_async( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_certificate_issuer_future( &self, certificate: &(impl IsA + Clone + 'static), interaction: Option<&(impl IsA + Clone + 'static)>, flags: TlsDatabaseLookupFlags, ) -> Pin> + 'static>> { let certificate = certificate.clone(); let interaction = interaction.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_certificate_issuer_async( &certificate, interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_tls_database_lookup_certificates_issued_by")] fn lookup_certificates_issued_by( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificates_issued_by( self.as_ref().to_glib_none().0, issuer_raw_dn.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_database_lookup_certificates_issued_by_async")] fn lookup_certificates_issued_by_async< P: FnOnce(Result, glib::Error>) + 'static, >( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&impl IsA>, flags: TlsDatabaseLookupFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn lookup_certificates_issued_by_async_trampoline< P: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_lookup_certificates_issued_by_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = lookup_certificates_issued_by_async_trampoline::

; unsafe { ffi::g_tls_database_lookup_certificates_issued_by_async( self.as_ref().to_glib_none().0, issuer_raw_dn.to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn lookup_certificates_issued_by_future( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&(impl IsA + Clone + 'static)>, flags: TlsDatabaseLookupFlags, ) -> Pin< Box_, glib::Error>> + 'static>, > { let issuer_raw_dn = issuer_raw_dn.clone(); let interaction = interaction.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.lookup_certificates_issued_by_async( &issuer_raw_dn, interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_tls_database_verify_chain")] fn verify_chain( &self, chain: &impl IsA, purpose: &str, identity: Option<&impl IsA>, interaction: Option<&impl IsA>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_verify_chain( self.as_ref().to_glib_none().0, chain.as_ref().to_glib_none().0, purpose.to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_database_verify_chain_async")] fn verify_chain_async) + 'static>( &self, chain: &impl IsA, purpose: &str, identity: Option<&impl IsA>, interaction: Option<&impl IsA>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn verify_chain_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_database_verify_chain_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = verify_chain_async_trampoline::

; unsafe { ffi::g_tls_database_verify_chain_async( self.as_ref().to_glib_none().0, chain.as_ref().to_glib_none().0, purpose.to_glib_none().0, identity.map(|p| p.as_ref()).to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn verify_chain_future( &self, chain: &(impl IsA + Clone + 'static), purpose: &str, identity: Option<&(impl IsA + Clone + 'static)>, interaction: Option<&(impl IsA + Clone + 'static)>, flags: TlsDatabaseVerifyFlags, ) -> Pin< Box_> + 'static>, > { let chain = chain.clone(); let purpose = String::from(purpose); let identity = identity.map(ToOwned::to_owned); let interaction = interaction.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.verify_chain_async( &chain, &purpose, identity.as_ref().map(::std::borrow::Borrow::borrow), interaction.as_ref().map(::std::borrow::Borrow::borrow), flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } } impl> TlsDatabaseExt for O {} gio-0.20.1/src/auto/tls_file_database.rs000064400000000000000000000047451046102023000162260ustar 00000000000000// 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::{ffi, TlsDatabase}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTlsFileDatabase")] pub struct TlsFileDatabase(Interface) @requires TlsDatabase; match fn { type_ => || ffi::g_tls_file_database_get_type(), } } impl TlsFileDatabase { pub const NONE: Option<&'static TlsFileDatabase> = None; #[doc(alias = "g_tls_file_database_new")] pub fn new(anchors: impl AsRef) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_file_database_new(anchors.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsFileDatabaseExt: IsA + sealed::Sealed + 'static { fn anchors(&self) -> Option { ObjectExt::property(self.as_ref(), "anchors") } fn set_anchors(&self, anchors: Option<&str>) { ObjectExt::set_property(self.as_ref(), "anchors", anchors) } #[doc(alias = "anchors")] fn connect_anchors_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_anchors_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsFileDatabase, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsFileDatabase::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::anchors\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_anchors_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsFileDatabaseExt for O {} gio-0.20.1/src/auto/tls_interaction.rs000064400000000000000000000230761046102023000160000ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, TlsCertificateRequestFlags, TlsConnection, TlsInteractionResult, TlsPassword, }; use glib::{prelude::*, translate::*}; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GTlsInteraction")] pub struct TlsInteraction(Object); match fn { type_ => || ffi::g_tls_interaction_get_type(), } } impl TlsInteraction { pub const NONE: Option<&'static TlsInteraction> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsInteractionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_interaction_ask_password")] fn ask_password( &self, password: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_ask_password( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_interaction_ask_password_async")] fn ask_password_async) + 'static>( &self, password: &impl IsA, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn ask_password_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_ask_password_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = ask_password_async_trampoline::

; unsafe { ffi::g_tls_interaction_ask_password_async( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn ask_password_future( &self, password: &(impl IsA + Clone + 'static), ) -> Pin< Box_> + 'static>, > { let password = password.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.ask_password_async(&password, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_tls_interaction_invoke_ask_password")] fn invoke_ask_password( &self, password: &impl IsA, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_invoke_ask_password( self.as_ref().to_glib_none().0, password.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_interaction_invoke_request_certificate")] fn invoke_request_certificate( &self, connection: &impl IsA, flags: TlsCertificateRequestFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_invoke_request_certificate( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_interaction_request_certificate")] fn request_certificate( &self, connection: &impl IsA, flags: TlsCertificateRequestFlags, cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_request_certificate( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_tls_interaction_request_certificate_async")] fn request_certificate_async) + 'static>( &self, connection: &impl IsA, flags: TlsCertificateRequestFlags, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn request_certificate_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_interaction_request_certificate_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = request_certificate_async_trampoline::

; unsafe { ffi::g_tls_interaction_request_certificate_async( self.as_ref().to_glib_none().0, connection.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn request_certificate_future( &self, connection: &(impl IsA + Clone + 'static), flags: TlsCertificateRequestFlags, ) -> Pin< Box_> + 'static>, > { let connection = connection.clone(); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.request_certificate_async(&connection, flags, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> TlsInteractionExt for O {} gio-0.20.1/src/auto/tls_password.rs000064400000000000000000000131721046102023000153170ustar 00000000000000// 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::{ffi, TlsPasswordFlags}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTlsPassword")] pub struct TlsPassword(Object); match fn { type_ => || ffi::g_tls_password_get_type(), } } impl TlsPassword { pub const NONE: Option<&'static TlsPassword> = None; #[doc(alias = "g_tls_password_new")] pub fn new(flags: TlsPasswordFlags, description: &str) -> TlsPassword { unsafe { from_glib_full(ffi::g_tls_password_new( flags.into_glib(), description.to_glib_none().0, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsPasswordExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_tls_password_get_description")] #[doc(alias = "get_description")] fn description(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_tls_password_get_description( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_password_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> TlsPasswordFlags { unsafe { from_glib(ffi::g_tls_password_get_flags( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_password_get_warning")] #[doc(alias = "get_warning")] fn warning(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_tls_password_get_warning( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_tls_password_set_description")] #[doc(alias = "description")] fn set_description(&self, description: &str) { unsafe { ffi::g_tls_password_set_description( self.as_ref().to_glib_none().0, description.to_glib_none().0, ); } } #[doc(alias = "g_tls_password_set_flags")] #[doc(alias = "flags")] fn set_flags(&self, flags: TlsPasswordFlags) { unsafe { ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib()); } } //#[doc(alias = "g_tls_password_set_value_full")] //fn set_value_full(&self, value: &[u8]) { // unsafe { TODO: call ffi:g_tls_password_set_value_full() } //} #[doc(alias = "g_tls_password_set_warning")] #[doc(alias = "warning")] fn set_warning(&self, warning: &str) { unsafe { ffi::g_tls_password_set_warning( self.as_ref().to_glib_none().0, warning.to_glib_none().0, ); } } #[doc(alias = "description")] fn connect_description_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_description_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsPassword, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::description\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_description_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "flags")] fn connect_flags_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_flags_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GTlsPassword, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::flags\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "warning")] fn connect_warning_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_warning_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GTlsPassword, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsPassword::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::warning\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_warning_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsPasswordExt for O {} gio-0.20.1/src/auto/tls_server_connection.rs000064400000000000000000000060131046102023000171760ustar 00000000000000// 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::{ffi, IOStream, TlsAuthenticationMode, TlsCertificate, TlsConnection}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GTlsServerConnection")] pub struct TlsServerConnection(Interface) @requires TlsConnection, IOStream; match fn { type_ => || ffi::g_tls_server_connection_get_type(), } } impl TlsServerConnection { pub const NONE: Option<&'static TlsServerConnection> = None; #[doc(alias = "g_tls_server_connection_new")] pub fn new( base_io_stream: &impl IsA, certificate: Option<&impl IsA>, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_tls_server_connection_new( base_io_stream.as_ref().to_glib_none().0, certificate.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsServerConnectionExt: IsA + sealed::Sealed + 'static { #[doc(alias = "authentication-mode")] fn authentication_mode(&self) -> TlsAuthenticationMode { ObjectExt::property(self.as_ref(), "authentication-mode") } #[doc(alias = "authentication-mode")] fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode) { ObjectExt::set_property(self.as_ref(), "authentication-mode", authentication_mode) } #[doc(alias = "authentication-mode")] fn connect_authentication_mode_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_authentication_mode_trampoline< P: IsA, F: Fn(&P) + 'static, >( this: *mut ffi::GTlsServerConnection, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(TlsServerConnection::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::authentication-mode\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_authentication_mode_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> TlsServerConnectionExt for O {} gio-0.20.1/src/auto/unix_credentials_message.rs000064400000000000000000000042031046102023000176320ustar 00000000000000// 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::{ffi, Credentials, SocketControlMessage}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixCredentialsMessage")] pub struct UnixCredentialsMessage(Object) @extends SocketControlMessage; match fn { type_ => || ffi::g_unix_credentials_message_get_type(), } } impl UnixCredentialsMessage { pub const NONE: Option<&'static UnixCredentialsMessage> = None; #[doc(alias = "g_unix_credentials_message_new")] pub fn new() -> UnixCredentialsMessage { unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_credentials_message_new()) .unsafe_cast() } } #[doc(alias = "g_unix_credentials_message_new_with_credentials")] #[doc(alias = "new_with_credentials")] pub fn with_credentials(credentials: &Credentials) -> UnixCredentialsMessage { unsafe { SocketControlMessage::from_glib_full( ffi::g_unix_credentials_message_new_with_credentials(credentials.to_glib_none().0), ) .unsafe_cast() } } #[doc(alias = "g_unix_credentials_message_is_supported")] pub fn is_supported() -> bool { unsafe { from_glib(ffi::g_unix_credentials_message_is_supported()) } } } impl Default for UnixCredentialsMessage { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixCredentialsMessageExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_credentials_message_get_credentials")] #[doc(alias = "get_credentials")] fn credentials(&self) -> Credentials { unsafe { from_glib_none(ffi::g_unix_credentials_message_get_credentials( self.as_ref().to_glib_none().0, )) } } } impl> UnixCredentialsMessageExt for O {} gio-0.20.1/src/auto/unix_fd_list.rs000064400000000000000000000021411046102023000152540ustar 00000000000000// 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::ffi; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixFDList")] pub struct UnixFDList(Object); match fn { type_ => || ffi::g_unix_fd_list_get_type(), } } impl UnixFDList { pub const NONE: Option<&'static UnixFDList> = None; #[doc(alias = "g_unix_fd_list_new")] pub fn new() -> UnixFDList { unsafe { from_glib_full(ffi::g_unix_fd_list_new()) } } } impl Default for UnixFDList { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixFDListExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_fd_list_get_length")] #[doc(alias = "get_length")] fn length(&self) -> i32 { unsafe { ffi::g_unix_fd_list_get_length(self.as_ref().to_glib_none().0) } } } impl> UnixFDListExt for O {} gio-0.20.1/src/auto/unix_fd_message.rs000064400000000000000000000033551046102023000157350ustar 00000000000000// 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::{ffi, SocketControlMessage, UnixFDList}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixFDMessage")] pub struct UnixFDMessage(Object) @extends SocketControlMessage; match fn { type_ => || ffi::g_unix_fd_message_get_type(), } } impl UnixFDMessage { pub const NONE: Option<&'static UnixFDMessage> = None; #[doc(alias = "g_unix_fd_message_new")] pub fn new() -> UnixFDMessage { unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new()).unsafe_cast() } } #[doc(alias = "g_unix_fd_message_new_with_fd_list")] #[doc(alias = "new_with_fd_list")] pub fn with_fd_list(fd_list: &impl IsA) -> UnixFDMessage { unsafe { SocketControlMessage::from_glib_full(ffi::g_unix_fd_message_new_with_fd_list( fd_list.as_ref().to_glib_none().0, )) .unsafe_cast() } } } impl Default for UnixFDMessage { fn default() -> Self { Self::new() } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixFDMessageExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_fd_message_get_fd_list")] #[doc(alias = "get_fd_list")] #[doc(alias = "fd-list")] fn fd_list(&self) -> UnixFDList { unsafe { from_glib_none(ffi::g_unix_fd_message_get_fd_list( self.as_ref().to_glib_none().0, )) } } } impl> UnixFDMessageExt for O {} gio-0.20.1/src/auto/unix_input_stream.rs000064400000000000000000000022561046102023000163510ustar 00000000000000// 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::{ffi, FileDescriptorBased, InputStream, PollableInputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixInputStream")] pub struct UnixInputStream(Object) @extends InputStream, @implements FileDescriptorBased, PollableInputStream; match fn { type_ => || ffi::g_unix_input_stream_get_type(), } } impl UnixInputStream { pub const NONE: Option<&'static UnixInputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixInputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_input_stream_get_close_fd")] #[doc(alias = "get_close_fd")] #[doc(alias = "close-fd")] fn closes_fd(&self) -> bool { unsafe { from_glib(ffi::g_unix_input_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl> UnixInputStreamExt for O {} gio-0.20.1/src/auto/unix_mount_entry.rs000064400000000000000000000012151046102023000162140ustar 00000000000000// 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::ffi; glib::wrapper! { #[derive(Debug)] pub struct UnixMountEntry(Boxed); match fn { copy => |ptr| glib::gobject_ffi::g_boxed_copy(ffi::g_unix_mount_entry_get_type(), ptr as *mut _) as *mut ffi::GUnixMountEntry, free => |ptr| glib::gobject_ffi::g_boxed_free(ffi::g_unix_mount_entry_get_type(), ptr as *mut _), type_ => || ffi::g_unix_mount_entry_get_type(), } } unsafe impl Send for UnixMountEntry {} unsafe impl Sync for UnixMountEntry {} gio-0.20.1/src/auto/unix_mount_point.rs000064400000000000000000000116031046102023000162060ustar 00000000000000// 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::{ffi, Icon}; use glib::translate::*; glib::wrapper! { #[derive(Debug)] pub struct UnixMountPoint(Boxed); match fn { copy => |ptr| ffi::g_unix_mount_point_copy(mut_override(ptr)), free => |ptr| ffi::g_unix_mount_point_free(ptr), type_ => || ffi::g_unix_mount_point_get_type(), } } impl UnixMountPoint { #[doc(alias = "g_unix_mount_point_compare")] fn compare(&self, mount2: &UnixMountPoint) -> i32 { unsafe { ffi::g_unix_mount_point_compare( mut_override(self.to_glib_none().0), mut_override(mount2.to_glib_none().0), ) } } #[doc(alias = "g_unix_mount_point_get_device_path")] #[doc(alias = "get_device_path")] pub fn device_path(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_unix_mount_point_get_device_path(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_get_fs_type")] #[doc(alias = "get_fs_type")] pub fn fs_type(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_unix_mount_point_get_fs_type(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_get_mount_path")] #[doc(alias = "get_mount_path")] pub fn mount_path(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_unix_mount_point_get_mount_path(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_get_options")] #[doc(alias = "get_options")] pub fn options(&self) -> Option { unsafe { from_glib_none(ffi::g_unix_mount_point_get_options(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_guess_can_eject")] pub fn guess_can_eject(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_point_guess_can_eject(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_guess_icon")] pub fn guess_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_unix_mount_point_guess_icon(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_guess_name")] pub fn guess_name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_unix_mount_point_guess_name(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_guess_symbolic_icon")] pub fn guess_symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_unix_mount_point_guess_symbolic_icon(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_is_loopback")] pub fn is_loopback(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_point_is_loopback(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_is_readonly")] pub fn is_readonly(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_point_is_readonly(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_point_is_user_mountable")] pub fn is_user_mountable(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_point_is_user_mountable(mut_override( self.to_glib_none().0, ))) } } #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[doc(alias = "g_unix_mount_point_at")] pub fn at(mount_path: impl AsRef) -> (Option, u64) { unsafe { let mut time_read = std::mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_unix_mount_point_at( mount_path.as_ref().to_glib_none().0, time_read.as_mut_ptr(), )); (ret, time_read.assume_init()) } } } impl PartialEq for UnixMountPoint { #[inline] fn eq(&self, other: &Self) -> bool { self.compare(other) == 0 } } impl Eq for UnixMountPoint {} impl PartialOrd for UnixMountPoint { #[inline] fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for UnixMountPoint { #[inline] fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.compare(other).cmp(&0) } } unsafe impl Send for UnixMountPoint {} unsafe impl Sync for UnixMountPoint {} gio-0.20.1/src/auto/unix_output_stream.rs000064400000000000000000000023001046102023000165400ustar 00000000000000// 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::{ffi, FileDescriptorBased, OutputStream, PollableOutputStream}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixOutputStream")] pub struct UnixOutputStream(Object) @extends OutputStream, @implements FileDescriptorBased, PollableOutputStream; match fn { type_ => || ffi::g_unix_output_stream_get_type(), } } impl UnixOutputStream { pub const NONE: Option<&'static UnixOutputStream> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixOutputStreamExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_output_stream_get_close_fd")] #[doc(alias = "get_close_fd")] #[doc(alias = "close-fd")] fn closes_fd(&self) -> bool { unsafe { from_glib(ffi::g_unix_output_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl> UnixOutputStreamExt for O {} gio-0.20.1/src/auto/unix_socket_address.rs000064400000000000000000000053401046102023000166310ustar 00000000000000// 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::{ffi, SocketAddress, SocketConnectable, UnixSocketAddressType}; use glib::{prelude::*, translate::*}; glib::wrapper! { #[doc(alias = "GUnixSocketAddress")] pub struct UnixSocketAddress(Object) @extends SocketAddress, @implements SocketConnectable; match fn { type_ => || ffi::g_unix_socket_address_get_type(), } } impl UnixSocketAddress { pub const NONE: Option<&'static UnixSocketAddress> = None; //#[doc(alias = "g_unix_socket_address_new_abstract")] //pub fn new_abstract(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }) -> UnixSocketAddress { // unsafe { TODO: call ffi:g_unix_socket_address_new_abstract() } //} //#[doc(alias = "g_unix_socket_address_new_with_type")] //#[doc(alias = "new_with_type")] //pub fn with_type(path: /*Unimplemented*/&CArray TypeId { ns_id: 0, id: 10 }, type_: UnixSocketAddressType) -> UnixSocketAddress { // unsafe { TODO: call ffi:g_unix_socket_address_new_with_type() } //} #[doc(alias = "g_unix_socket_address_abstract_names_supported")] pub fn abstract_names_supported() -> bool { unsafe { from_glib(ffi::g_unix_socket_address_abstract_names_supported()) } } } unsafe impl Send for UnixSocketAddress {} unsafe impl Sync for UnixSocketAddress {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixSocketAddressExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_unix_socket_address_get_address_type")] #[doc(alias = "get_address_type")] #[doc(alias = "address-type")] fn address_type(&self) -> UnixSocketAddressType { unsafe { from_glib(ffi::g_unix_socket_address_get_address_type( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_unix_socket_address_get_is_abstract")] #[doc(alias = "get_is_abstract")] fn is_abstract(&self) -> bool { unsafe { from_glib(ffi::g_unix_socket_address_get_is_abstract( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_unix_socket_address_get_path_len")] #[doc(alias = "get_path_len")] fn path_len(&self) -> usize { unsafe { ffi::g_unix_socket_address_get_path_len(self.as_ref().to_glib_none().0) } } #[doc(alias = "path-as-array")] fn path_as_array(&self) -> Option { ObjectExt::property(self.as_ref(), "path-as-array") } } impl> UnixSocketAddressExt for O {} gio-0.20.1/src/auto/versions.txt000064400000000000000000000002041046102023000146260ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ 8c3ba91da566) from gir-files (https://github.com/gtk-rs/gir-files @ 4d1189172a70) gio-0.20.1/src/auto/vfs.rs000064400000000000000000000140341046102023000133670ustar 00000000000000// 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::{ffi, File}; use glib::{prelude::*, translate::*}; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GVfs")] pub struct Vfs(Object); match fn { type_ => || ffi::g_vfs_get_type(), } } impl Vfs { pub const NONE: Option<&'static Vfs> = None; #[doc(alias = "g_vfs_get_default")] #[doc(alias = "get_default")] #[allow(clippy::should_implement_trait)] pub fn default() -> Vfs { unsafe { from_glib_none(ffi::g_vfs_get_default()) } } #[doc(alias = "g_vfs_get_local")] #[doc(alias = "get_local")] pub fn local() -> Vfs { unsafe { from_glib_none(ffi::g_vfs_get_local()) } } } unsafe impl Send for Vfs {} unsafe impl Sync for Vfs {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait VfsExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_vfs_get_file_for_path")] #[doc(alias = "get_file_for_path")] fn file_for_path(&self, path: &str) -> File { unsafe { from_glib_full(ffi::g_vfs_get_file_for_path( self.as_ref().to_glib_none().0, path.to_glib_none().0, )) } } #[doc(alias = "g_vfs_get_file_for_uri")] #[doc(alias = "get_file_for_uri")] fn file_for_uri(&self, uri: &str) -> File { unsafe { from_glib_full(ffi::g_vfs_get_file_for_uri( self.as_ref().to_glib_none().0, uri.to_glib_none().0, )) } } #[doc(alias = "g_vfs_get_supported_uri_schemes")] #[doc(alias = "get_supported_uri_schemes")] fn supported_uri_schemes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_vfs_get_supported_uri_schemes( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_vfs_is_active")] fn is_active(&self) -> bool { unsafe { from_glib(ffi::g_vfs_is_active(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_vfs_parse_name")] fn parse_name(&self, parse_name: &str) -> File { unsafe { from_glib_full(ffi::g_vfs_parse_name( self.as_ref().to_glib_none().0, parse_name.to_glib_none().0, )) } } #[doc(alias = "g_vfs_register_uri_scheme")] fn register_uri_scheme( &self, scheme: &str, uri_func: Option File + 'static>>, parse_name_func: Option File + 'static>>, ) -> bool { let uri_func_data: Box_ File + 'static>>> = Box_::new(uri_func); unsafe extern "C" fn uri_func_func( vfs: *mut ffi::GVfs, identifier: *const libc::c_char, user_data: glib::ffi::gpointer, ) -> *mut ffi::GFile { let vfs = from_glib_borrow(vfs); let identifier: Borrowed = from_glib_borrow(identifier); let callback = &*(user_data as *mut Option File + 'static>>); if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") } .to_glib_full() } let uri_func = if uri_func_data.is_some() { Some(uri_func_func as _) } else { None }; let parse_name_func_data: Box_ File + 'static>>> = Box_::new(parse_name_func); unsafe extern "C" fn parse_name_func_func( vfs: *mut ffi::GVfs, identifier: *const libc::c_char, user_data: glib::ffi::gpointer, ) -> *mut ffi::GFile { let vfs = from_glib_borrow(vfs); let identifier: Borrowed = from_glib_borrow(identifier); let callback = &*(user_data as *mut Option File + 'static>>); if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") } .to_glib_full() } let parse_name_func = if parse_name_func_data.is_some() { Some(parse_name_func_func as _) } else { None }; unsafe extern "C" fn uri_destroy_func(data: glib::ffi::gpointer) { let _callback = Box_::from_raw(data as *mut Option File + 'static>>); } let destroy_call4 = Some(uri_destroy_func as _); unsafe extern "C" fn parse_name_destroy_func(data: glib::ffi::gpointer) { let _callback = Box_::from_raw(data as *mut Option File + 'static>>); } let destroy_call7 = Some(parse_name_destroy_func as _); let super_callback0: Box_ File + 'static>>> = uri_func_data; let super_callback1: Box_ File + 'static>>> = parse_name_func_data; unsafe { from_glib(ffi::g_vfs_register_uri_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, uri_func, Box_::into_raw(super_callback0) as *mut _, destroy_call4, parse_name_func, Box_::into_raw(super_callback1) as *mut _, destroy_call7, )) } } #[doc(alias = "g_vfs_unregister_uri_scheme")] fn unregister_uri_scheme(&self, scheme: &str) -> bool { unsafe { from_glib(ffi::g_vfs_unregister_uri_scheme( self.as_ref().to_glib_none().0, scheme.to_glib_none().0, )) } } } impl> VfsExt for O {} gio-0.20.1/src/auto/volume.rs000064400000000000000000000261021046102023000140770ustar 00000000000000// 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::{ ffi, AsyncResult, Cancellable, Drive, File, Icon, Mount, MountMountFlags, MountOperation, MountUnmountFlags, }; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::{boxed::Box as Box_, pin::Pin}; glib::wrapper! { #[doc(alias = "GVolume")] pub struct Volume(Interface); match fn { type_ => || ffi::g_volume_get_type(), } } impl Volume { pub const NONE: Option<&'static Volume> = None; } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait VolumeExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_volume_can_eject")] fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_volume_can_eject(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_can_mount")] fn can_mount(&self) -> bool { unsafe { from_glib(ffi::g_volume_can_mount(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_eject_with_operation")] fn eject_with_operation) + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn eject_with_operation_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_volume_eject_with_operation_finish( _source_object as *mut _, res, &mut error, ); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = eject_with_operation_trampoline::

; unsafe { ffi::g_volume_eject_with_operation( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn eject_with_operation_future( &self, flags: MountUnmountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.eject_with_operation( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_volume_enumerate_identifiers")] fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_volume_get_activation_root")] #[doc(alias = "get_activation_root")] fn activation_root(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_activation_root( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_volume_get_drive")] #[doc(alias = "get_drive")] fn drive(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_drive(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_volume_get_icon(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_get_identifier")] #[doc(alias = "get_identifier")] fn identifier(&self, kind: &str) -> Option { unsafe { from_glib_full(ffi::g_volume_get_identifier( self.as_ref().to_glib_none().0, kind.to_glib_none().0, )) } } #[doc(alias = "g_volume_get_mount")] fn get_mount(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_mount(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_volume_get_name(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_volume_get_sort_key(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_volume_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_volume_get_uuid")] #[doc(alias = "get_uuid")] fn uuid(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_uuid(self.as_ref().to_glib_none().0)) } } #[doc(alias = "g_volume_mount")] fn mount) + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&impl IsA>, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn mount_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let _ = ffi::g_volume_mount_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = mount_trampoline::

; unsafe { ffi::g_volume_mount( self.as_ref().to_glib_none().0, flags.into_glib(), mount_operation.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn mount_future( &self, flags: MountMountFlags, mount_operation: Option<&(impl IsA + Clone + 'static)>, ) -> Pin> + 'static>> { let mount_operation = mount_operation.map(ToOwned::to_owned); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.mount( flags, mount_operation.as_ref().map(::std::borrow::Borrow::borrow), Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_volume_should_automount")] fn should_automount(&self) -> bool { unsafe { from_glib(ffi::g_volume_should_automount( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn changed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GVolume, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Volume::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "removed")] fn connect_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn removed_trampoline, F: Fn(&P) + 'static>( this: *mut ffi::GVolume, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Volume::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> VolumeExt for O {} gio-0.20.1/src/auto/volume_monitor.rs000064400000000000000000000352011046102023000156460ustar 00000000000000// 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::{ffi, Drive, Mount, Volume}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GVolumeMonitor")] pub struct VolumeMonitor(Object); match fn { type_ => || ffi::g_volume_monitor_get_type(), } } impl VolumeMonitor { pub const NONE: Option<&'static VolumeMonitor> = None; #[doc(alias = "g_volume_monitor_get")] pub fn get() -> VolumeMonitor { unsafe { from_glib_full(ffi::g_volume_monitor_get()) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait VolumeMonitorExt: IsA + sealed::Sealed + 'static { #[doc(alias = "g_volume_monitor_get_connected_drives")] #[doc(alias = "get_connected_drives")] fn connected_drives(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_connected_drives( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_volume_monitor_get_mount_for_uuid")] #[doc(alias = "get_mount_for_uuid")] fn mount_for_uuid(&self, uuid: &str) -> Option { unsafe { from_glib_full(ffi::g_volume_monitor_get_mount_for_uuid( self.as_ref().to_glib_none().0, uuid.to_glib_none().0, )) } } #[doc(alias = "g_volume_monitor_get_mounts")] #[doc(alias = "get_mounts")] fn mounts(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_mounts( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_volume_monitor_get_volume_for_uuid")] #[doc(alias = "get_volume_for_uuid")] fn volume_for_uuid(&self, uuid: &str) -> Option { unsafe { from_glib_full(ffi::g_volume_monitor_get_volume_for_uuid( self.as_ref().to_glib_none().0, uuid.to_glib_none().0, )) } } #[doc(alias = "g_volume_monitor_get_volumes")] #[doc(alias = "get_volumes")] fn volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_volumes( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "drive-changed")] fn connect_drive_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_changed_trampoline< P: IsA, F: Fn(&P, &Drive) + 'static, >( this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( drive_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "drive-connected")] fn connect_drive_connected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_connected_trampoline< P: IsA, F: Fn(&P, &Drive) + 'static, >( this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-connected\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( drive_connected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "drive-disconnected")] fn connect_drive_disconnected(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_disconnected_trampoline< P: IsA, F: Fn(&P, &Drive) + 'static, >( this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-disconnected\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( drive_disconnected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "drive-eject-button")] fn connect_drive_eject_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_eject_button_trampoline< P: IsA, F: Fn(&P, &Drive) + 'static, >( this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-eject-button\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( drive_eject_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "drive-stop-button")] fn connect_drive_stop_button(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn drive_stop_button_trampoline< P: IsA, F: Fn(&P, &Drive) + 'static, >( this: *mut ffi::GVolumeMonitor, drive: *mut ffi::GDrive, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(drive), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"drive-stop-button\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( drive_stop_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "mount-added")] fn connect_mount_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_added_trampoline< P: IsA, F: Fn(&P, &Mount) + 'static, >( this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-added\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( mount_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "mount-changed")] fn connect_mount_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_changed_trampoline< P: IsA, F: Fn(&P, &Mount) + 'static, >( this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( mount_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "mount-pre-unmount")] fn connect_mount_pre_unmount(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_pre_unmount_trampoline< P: IsA, F: Fn(&P, &Mount) + 'static, >( this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-pre-unmount\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( mount_pre_unmount_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "mount-removed")] fn connect_mount_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn mount_removed_trampoline< P: IsA, F: Fn(&P, &Mount) + 'static, >( this: *mut ffi::GVolumeMonitor, mount: *mut ffi::GMount, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(mount), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"mount-removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( mount_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "volume-added")] fn connect_volume_added(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_added_trampoline< P: IsA, F: Fn(&P, &Volume) + 'static, >( this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-added\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( volume_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "volume-changed")] fn connect_volume_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_changed_trampoline< P: IsA, F: Fn(&P, &Volume) + 'static, >( this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-changed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( volume_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "volume-removed")] fn connect_volume_removed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn volume_removed_trampoline< P: IsA, F: Fn(&P, &Volume) + 'static, >( this: *mut ffi::GVolumeMonitor, volume: *mut ffi::GVolume, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( VolumeMonitor::from_glib_borrow(this).unsafe_cast_ref(), &from_glib_borrow(volume), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"volume-removed\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( volume_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> VolumeMonitorExt for O {} gio-0.20.1/src/auto/zlib_compressor.rs000064400000000000000000000045631046102023000160130ustar 00000000000000// 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::{ffi, Converter, FileInfo, ZlibCompressorFormat}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GZlibCompressor")] pub struct ZlibCompressor(Object) @implements Converter; match fn { type_ => || ffi::g_zlib_compressor_get_type(), } } impl ZlibCompressor { #[doc(alias = "g_zlib_compressor_new")] pub fn new(format: ZlibCompressorFormat, level: i32) -> ZlibCompressor { unsafe { from_glib_full(ffi::g_zlib_compressor_new(format.into_glib(), level)) } } #[doc(alias = "g_zlib_compressor_get_file_info")] #[doc(alias = "get_file_info")] #[doc(alias = "file-info")] pub fn file_info(&self) -> Option { unsafe { from_glib_none(ffi::g_zlib_compressor_get_file_info(self.to_glib_none().0)) } } #[doc(alias = "g_zlib_compressor_set_file_info")] #[doc(alias = "file-info")] pub fn set_file_info(&self, file_info: Option<&FileInfo>) { unsafe { ffi::g_zlib_compressor_set_file_info(self.to_glib_none().0, file_info.to_glib_none().0); } } pub fn format(&self) -> ZlibCompressorFormat { ObjectExt::property(self, "format") } pub fn level(&self) -> i32 { ObjectExt::property(self, "level") } #[doc(alias = "file-info")] pub fn connect_file_info_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_file_info_trampoline( this: *mut ffi::GZlibCompressor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::file-info\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_file_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/auto/zlib_decompressor.rs000064400000000000000000000040751046102023000163220ustar 00000000000000// 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::{ffi, Converter, FileInfo, ZlibCompressorFormat}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use std::boxed::Box as Box_; glib::wrapper! { #[doc(alias = "GZlibDecompressor")] pub struct ZlibDecompressor(Object) @implements Converter; match fn { type_ => || ffi::g_zlib_decompressor_get_type(), } } impl ZlibDecompressor { #[doc(alias = "g_zlib_decompressor_new")] pub fn new(format: ZlibCompressorFormat) -> ZlibDecompressor { unsafe { from_glib_full(ffi::g_zlib_decompressor_new(format.into_glib())) } } #[doc(alias = "g_zlib_decompressor_get_file_info")] #[doc(alias = "get_file_info")] #[doc(alias = "file-info")] pub fn file_info(&self) -> Option { unsafe { from_glib_none(ffi::g_zlib_decompressor_get_file_info( self.to_glib_none().0, )) } } pub fn format(&self) -> ZlibCompressorFormat { ObjectExt::property(self, "format") } #[doc(alias = "file-info")] pub fn connect_file_info_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_file_info_trampoline( this: *mut ffi::GZlibDecompressor, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::file-info\0".as_ptr() as *const _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( notify_file_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.20.1/src/cancellable.rs000064400000000000000000000173741046102023000140600ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::num::NonZeroU64; use futures_channel::oneshot; use futures_core::Future; use glib::{prelude::*, translate::*}; use crate::{ffi, Cancellable}; // rustdoc-stripper-ignore-next /// The id of a cancelled handler that is returned by `CancellableExtManual::connect`. This type is /// analogous to [`glib::SignalHandlerId`]. #[derive(Debug, Eq, PartialEq)] #[repr(transparent)] pub struct CancelledHandlerId(NonZeroU64); impl CancelledHandlerId { // rustdoc-stripper-ignore-next /// Returns the internal signal handler ID. #[allow(clippy::missing_safety_doc)] pub unsafe fn as_raw(&self) -> libc::c_ulong { self.0.get() as libc::c_ulong } } impl TryFromGlib for CancelledHandlerId { type Error = GlibNoneError; #[inline] unsafe fn try_from_glib(val: libc::c_ulong) -> Result { NonZeroU64::new(val as _).map(Self).ok_or(GlibNoneError) } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait CancellableExtManual: sealed::Sealed + IsA { // rustdoc-stripper-ignore-next /// Convenience function to connect to the `signal::Cancellable::cancelled` signal. Also /// handles the race condition that may happen if the cancellable is cancelled right before /// connecting. If the operation is cancelled from another thread, `callback` will be called /// in the thread that cancelled the operation, not the thread that is running the operation. /// This may be the main thread, so the callback should not do something that can block. /// /// `callback` is called at most once, either directly at the time of the connect if `self` is /// already cancelled, or when `self` is cancelled in some thread. /// /// Since GLib 2.40, the lock protecting `self` is not held when `callback` is invoked. This /// lifts a restriction in place for earlier GLib versions which now makes it easier to write /// cleanup code that unconditionally invokes e.g. /// [`CancellableExt::cancel()`][crate::prelude::CancellableExt::cancel()]. /// /// # Returns /// /// The id of the signal handler or `None` if `self` has already been cancelled. #[doc(alias = "g_cancellable_connect")] fn connect_cancelled( &self, callback: F, ) -> Option { unsafe extern "C" fn connect_trampoline, F: FnOnce(&P)>( this: *mut ffi::GCancellable, callback: glib::ffi::gpointer, ) { let callback: &mut Option = &mut *(callback as *mut Option); let callback = callback .take() .expect("Cancellable::cancel() closure called multiple times"); callback(Cancellable::from_glib_borrow(this).unsafe_cast_ref()) } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { let _ = Box::>::from_raw(ptr as *mut _); } let callback: Box> = Box::new(Some(callback)); unsafe { from_glib(ffi::g_cancellable_connect( self.as_ptr() as *mut _, Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( connect_trampoline:: as *const (), )), Box::into_raw(callback) as *mut _, Some(destroy_closure::), )) } } // rustdoc-stripper-ignore-next /// Local variant of [`Self::connect_cancelled`]. #[doc(alias = "g_cancellable_connect")] fn connect_cancelled_local( &self, callback: F, ) -> Option { let callback = glib::thread_guard::ThreadGuard::new(callback); self.connect_cancelled(move |obj| (callback.into_inner())(obj)) } // rustdoc-stripper-ignore-next /// Disconnects a handler from a cancellable instance. Additionally, in the event that a signal /// handler is currently running, this call will block until the handler has finished. Calling /// this function from a callback registered with [`Self::connect_cancelled`] will therefore /// result in a deadlock. /// /// This avoids a race condition where a thread cancels at the same time as the cancellable /// operation is finished and the signal handler is removed. #[doc(alias = "g_cancellable_disconnect")] fn disconnect_cancelled(&self, id: CancelledHandlerId) { unsafe { ffi::g_cancellable_disconnect(self.as_ptr() as *mut _, id.as_raw()) }; } // rustdoc-stripper-ignore-next /// Returns a `Future` that completes when the cancellable becomes cancelled. Completes /// immediately if the cancellable is already cancelled. fn future(&self) -> std::pin::Pin + Send + Sync + 'static>> { let cancellable = self.as_ref().clone(); let (tx, rx) = oneshot::channel(); let id = cancellable.connect_cancelled(move |_| { let _ = tx.send(()); }); Box::pin(async move { rx.await.unwrap(); if let Some(id) = id { cancellable.disconnect_cancelled(id); } }) } // rustdoc-stripper-ignore-next /// Set an error if the cancellable is already cancelled. #[doc(alias = "g_cancellable_set_error_if_cancelled")] fn set_error_if_cancelled(&self) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_cancellable_set_error_if_cancelled( self.as_ref().to_glib_none().0, &mut error, ); // Here's the special case, this function has an inverted // return value for the error case. debug_assert_eq!(is_ok == glib::ffi::GFALSE, error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl> CancellableExtManual for O {} #[cfg(test)] mod tests { use super::*; use crate::prelude::*; #[test] fn cancellable_callback() { let c = Cancellable::new(); let id = c.connect_cancelled(|_| {}); c.cancel(); // if it doesn't crash at this point, then we're good to go! c.disconnect_cancelled(id.unwrap()); } #[test] fn cancellable_callback_local() { let c = Cancellable::new(); let id = c.connect_cancelled_local(|_| {}); c.cancel(); // if it doesn't crash at this point, then we're good to go! c.disconnect_cancelled(id.unwrap()); } #[test] fn cancellable_error_if_cancelled() { let c = Cancellable::new(); c.cancel(); assert!(c.set_error_if_cancelled().is_err()); } #[test] fn cancellable_future() { let c = Cancellable::new(); c.cancel(); glib::MainContext::new().block_on(c.future()); } #[test] fn cancellable_future_thread() { let cancellable = Cancellable::new(); let c = cancellable.clone(); std::thread::spawn(move || c.cancel()).join().unwrap(); glib::MainContext::new().block_on(cancellable.future()); } #[test] fn cancellable_future_delayed() { let ctx = glib::MainContext::new(); let c = Cancellable::new(); let (tx, rx) = oneshot::channel(); { let c = c.clone(); ctx.spawn_local(async move { c.future().await; tx.send(()).unwrap(); }); } std::thread::spawn(move || c.cancel()).join().unwrap(); ctx.block_on(rx).unwrap(); } } gio-0.20.1/src/cancellable_future.rs000064400000000000000000000124521046102023000154420ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ fmt::{Debug, Display}, future::Future, pin::Pin, task::{Context, Poll}, }; use pin_project_lite::pin_project; use crate::{cancellable::CancelledHandlerId, prelude::*, Cancellable, IOErrorEnum}; // rustdoc-stripper-ignore-next /// Indicator that the [`CancellableFuture`] was cancelled. pub struct Cancelled; pin_project! { // rustdoc-stripper-ignore-next /// A future which can be cancelled via [`Cancellable`]. /// /// # Examples /// /// ``` /// # use futures::FutureExt; /// # use gio::prelude::*; /// # use gio::CancellableFuture; /// let l = glib::MainLoop::new(None, false); /// let c = gio::Cancellable::new(); /// /// l.context().spawn_local(CancellableFuture::new(async { 42 }, c.clone()).map(|_| ())); /// c.cancel(); /// /// ``` pub struct CancellableFuture { #[pin] future: F, #[pin] waker_handler_cb: Option, cancellable: Cancellable, } } impl CancellableFuture { // rustdoc-stripper-ignore-next /// Creates a new `CancellableFuture` using a [`Cancellable`]. /// /// When [`cancel`](CancellableExt::cancel) is called, the future will complete /// immediately without making any further progress. In such a case, an error /// will be returned by this future (i.e., [`Cancelled`]). pub fn new(future: F, cancellable: Cancellable) -> Self { Self { future, waker_handler_cb: None, cancellable, } } // rustdoc-stripper-ignore-next /// Checks whether the future has been cancelled. /// /// This is a shortcut for `self.cancellable().is_cancelled()` /// /// Note that all this method indicates is whether [`cancel`](CancellableExt::cancel) /// was called. This means that it will return true even if: /// * `cancel` was called after the future had completed. /// * `cancel` was called while the future was being polled. #[inline] pub fn is_cancelled(&self) -> bool { self.cancellable.is_cancelled() } // rustdoc-stripper-ignore-next /// Returns the inner [`Cancellable`] associated during creation. #[inline] pub fn cancellable(&self) -> &Cancellable { &self.cancellable } } impl Future for CancellableFuture where F: Future, { type Output = Result<::Output, Cancelled>; fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll { if self.is_cancelled() { return Poll::Ready(Err(Cancelled)); } let mut this = self.as_mut().project(); match this.future.poll(cx) { Poll::Ready(out) => Poll::Ready(Ok(out)), Poll::Pending => { if let Some(prev_handler) = this.waker_handler_cb.take() { this.cancellable.disconnect_cancelled(prev_handler); } let canceller_handler_id = this.cancellable.connect_cancelled({ let w = cx.waker().clone(); move |_| w.wake() }); match canceller_handler_id { Some(canceller_handler_id) => { *this.waker_handler_cb = Some(canceller_handler_id); Poll::Pending } None => Poll::Ready(Err(Cancelled)), } } } } } impl From for glib::Error { fn from(_: Cancelled) -> Self { glib::Error::new(IOErrorEnum::Cancelled, "Task cancelled") } } impl std::error::Error for Cancelled {} impl Debug for Cancelled { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "Task cancelled") } } impl Display for Cancelled { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Debug::fmt(self, f) } } #[cfg(test)] mod tests { use futures_channel::oneshot; use super::{Cancellable, CancellableFuture, Cancelled}; use crate::prelude::*; #[test] fn cancellable_future_ok() { let ctx = glib::MainContext::new(); let c = Cancellable::new(); let (tx, rx) = oneshot::channel(); { ctx.spawn_local(async { let cancellable_future = CancellableFuture::new(async { 42 }, c); assert!(!cancellable_future.is_cancelled()); let result = cancellable_future.await; assert!(matches!(result, Ok(42))); tx.send(()).unwrap(); }); } ctx.block_on(rx).unwrap() } #[test] fn cancellable_future_cancel() { let ctx = glib::MainContext::new(); let c = Cancellable::new(); let (tx, rx) = oneshot::channel(); { let c = c.clone(); ctx.spawn_local(async move { let cancellable_future = CancellableFuture::new(std::future::pending::<()>(), c); let result = cancellable_future.await; assert!(matches!(result, Err(Cancelled))); tx.send(()).unwrap(); }); } std::thread::spawn(move || c.cancel()).join().unwrap(); ctx.block_on(rx).unwrap(); } } gio-0.20.1/src/converter.rs000064400000000000000000000035631046102023000136350ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use glib::{prelude::*, translate::*}; use crate::{ffi, Converter, ConverterFlags, ConverterResult}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ConverterExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "g_converter_convert")] fn convert, OUT: AsMut<[u8]>>( &self, inbuf: IN, outbuf: OUT, flags: ConverterFlags, ) -> Result<(ConverterResult, usize, usize), glib::Error> { let inbuf: Box = Box::new(inbuf); let (inbuf_size, inbuf) = { let slice = (*inbuf).as_ref(); (slice.len(), slice.as_ptr()) }; let mut outbuf: Box = Box::new(outbuf); let (outbuf_size, outbuf) = { let slice = (*outbuf).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe { let mut bytes_read = mem::MaybeUninit::uninit(); let mut bytes_written = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let ret = ffi::g_converter_convert( self.as_ref().to_glib_none().0, mut_override(inbuf), inbuf_size, outbuf, outbuf_size, flags.into_glib(), bytes_read.as_mut_ptr(), bytes_written.as_mut_ptr(), &mut error, ); if error.is_null() { Ok(( from_glib(ret), bytes_read.assume_init(), bytes_written.assume_init(), )) } else { Err(from_glib_full(error)) } } } } impl> ConverterExtManual for O {} gio-0.20.1/src/credentials.rs000064400000000000000000000044271046102023000141230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::*; use crate::{ffi, Credentials, CredentialsType}; impl Credentials { #[doc(alias = "g_credentials_get_native")] #[doc(alias = "get_native")] pub fn native(&self, native_type: CredentialsType) -> glib::ffi::gpointer { unsafe { ffi::g_credentials_get_native(self.to_glib_none().0, native_type.into_glib()) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_credentials_get_unix_pid")] #[doc(alias = "get_unix_pid")] pub fn unix_pid(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_credentials_get_unix_pid(self.to_glib_none().0, &mut error); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_credentials_get_unix_user")] #[doc(alias = "get_unix_user")] pub fn unix_user(&self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let ret = ffi::g_credentials_get_unix_user(self.to_glib_none().0, &mut error); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_credentials_set_native")] pub unsafe fn set_native(&self, native_type: CredentialsType, native: glib::ffi::gpointer) { unsafe { ffi::g_credentials_set_native(self.to_glib_none().0, native_type.into_glib(), native) } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_credentials_set_unix_user")] pub fn set_unix_user(&self, uid: libc::uid_t) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::g_credentials_set_unix_user(self.to_glib_none().0, uid, &mut error); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } gio-0.20.1/src/data_input_stream.rs000064400000000000000000000270441046102023000153310ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, mem, pin::Pin, ptr}; use glib::{prelude::*, translate::*, GString}; use crate::{ffi, Cancellable, DataInputStream}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DataInputStreamExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "g_data_input_stream_read_line")] fn read_line>( &self, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut length = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let ret = ffi::g_data_input_stream_read_line( self.as_ref().to_glib_none().0, length.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); let length = length.assume_init(); if error.is_null() { Ok(FromGlibContainer::from_glib_full_num(ret, length)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_line_async")] fn read_line_async< P: IsA, Q: FnOnce(Result, glib::Error>) + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_line_async_trampoline< Q: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let ret = ffi::g_data_input_stream_read_line_finish( _source_object as *mut _, res, length.as_mut_ptr(), &mut error, ); let length = length.assume_init(); let result = if error.is_null() { Ok(FromGlibContainer::from_glib_full_num(ret, length)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = read_line_async_trampoline::; unsafe { ffi::g_data_input_stream_read_line_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn read_line_future( &self, io_priority: glib::Priority, ) -> Pin< Box_< dyn std::future::Future, glib::Error>> + 'static, >, > { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_line_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_data_input_stream_read_line_utf8")] fn read_line_utf8>( &self, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_data_input_stream_read_line_utf8( self.as_ref().to_glib_none().0, ptr::null_mut(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } fn read_line_utf8_async< P: IsA, Q: FnOnce(Result, glib::Error>) + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_line_async_trampoline< Q: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let ret = ffi::g_data_input_stream_read_line_finish( _source_object as *mut _, res, ptr::null_mut(), &mut error, ); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = read_line_async_trampoline::; unsafe { ffi::g_data_input_stream_read_line_async( self.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn read_line_utf8_future( &self, io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_line_utf8_async(io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_data_input_stream_read_upto")] fn read_upto>( &self, stop_chars: &[u8], cancellable: Option<&P>, ) -> Result, glib::Error> { let stop_chars_len = stop_chars.len() as isize; unsafe { let mut error = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let ret = ffi::g_data_input_stream_read_upto( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0 as *const _, stop_chars_len, length.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { let length = length.assume_init(); Ok(FromGlibContainer::from_glib_full_num( ret as *mut u8, length, )) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_data_input_stream_read_upto_async")] fn read_upto_async< P: IsA, Q: FnOnce(Result, glib::Error>) + 'static, >( &self, stop_chars: &[u8], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let stop_chars_len = stop_chars.len() as isize; let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_upto_async_trampoline< Q: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let ret = ffi::g_data_input_stream_read_upto_finish( _source_object as *mut _, res, length.as_mut_ptr(), &mut error, ); let result = if error.is_null() { let length = length.assume_init(); Ok(FromGlibContainer::from_glib_full_num( ret as *mut u8, length, )) } else { Err(from_glib_full(error)) }; let callback: Box_> = Box_::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = read_upto_async_trampoline::; unsafe { ffi::g_data_input_stream_read_upto_async( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0 as *const _, stop_chars_len, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } fn read_upto_future( &self, stop_chars: &[u8], io_priority: glib::Priority, ) -> Pin< Box_< dyn std::future::Future, glib::Error>> + 'static, >, > { let stop_chars = Vec::from(stop_chars); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_upto_async(&stop_chars, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl> DataInputStreamExtManual for O {} gio-0.20.1/src/datagram_based.rs000064400000000000000000000165511046102023000145450ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::RefCell, mem::transmute, pin::Pin, ptr, time::Duration}; use futures_core::stream::Stream; use glib::{prelude::*, translate::*}; use crate::{ffi, Cancellable, DatagramBased, InputMessage, OutputMessage}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DatagramBasedExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_datagram_based_create_source")] fn create_source( &self, condition: glib::IOCondition, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self, glib::IOCondition) -> glib::ControlFlow + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O, glib::IOCondition) -> glib::ControlFlow + 'static, >( datagram_based: *mut ffi::GDatagramBased, condition: glib::ffi::GIOCondition, func: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let func: &RefCell = &*(func as *const RefCell); let mut func = func.borrow_mut(); (*func)( DatagramBased::from_glib_borrow(datagram_based).unsafe_cast_ref(), from_glib(condition), ) .into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { let _ = Box::>::from_raw(ptr as *mut _); } let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); unsafe { let source = ffi::g_datagram_based_create_source( self.as_ref().to_glib_none().0, condition.into_glib(), gcancellable.0, ); let trampoline = trampoline:: as glib::ffi::gpointer; glib::ffi::g_source_set_callback( source, Some(transmute::< glib::ffi::gpointer, unsafe extern "C" fn(glib::ffi::gpointer) -> glib::ffi::gboolean, >(trampoline)), Box::into_raw(Box::new(RefCell::new(func))) as glib::ffi::gpointer, Some(destroy_closure::), ); glib::ffi::g_source_set_priority(source, priority.into_glib()); if let Some(name) = name { glib::ffi::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } fn create_source_future>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { let _ = send.take().unwrap().send(condition); glib::ControlFlow::Break }, ) })) } fn create_source_stream>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceStream::new(move |send| { let send = Some(send); obj.create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { if send.as_ref().unwrap().unbounded_send(condition).is_err() { glib::ControlFlow::Break } else { glib::ControlFlow::Continue } }, ) })) } #[doc(alias = "g_datagram_based_condition_wait")] fn condition_wait( &self, condition: glib::IOCondition, timeout: Option, cancellable: Option<&impl IsA>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let is_ok = ffi::g_datagram_based_condition_wait( self.as_ref().to_glib_none().0, condition.into_glib(), timeout .map(|t| t.as_micros().try_into().unwrap()) .unwrap_or(-1), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_datagram_based_receive_messages")] fn receive_messages<'v, V: IntoIterator, C: IsA>( &self, messages: &mut [InputMessage], flags: i32, timeout: Option, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let count = ffi::g_datagram_based_receive_messages( self.as_ref().to_glib_none().0, messages.as_mut_ptr() as *mut _, messages.len().try_into().unwrap(), flags, timeout .map(|t| t.as_micros().try_into().unwrap()) .unwrap_or(-1), cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(count as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_datagram_based_send_messages")] fn send_messages>( &self, messages: &mut [OutputMessage], flags: i32, timeout: Option, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let count = ffi::g_datagram_based_send_messages( self.as_ref().to_glib_none().0, messages.as_mut_ptr() as *mut _, messages.len().try_into().unwrap(), flags, timeout .map(|t| t.as_micros().try_into().unwrap()) .unwrap_or(-1), cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(count as usize) } else { Err(from_glib_full(error)) } } } } impl> DatagramBasedExtManual for O {} gio-0.20.1/src/dbus.rs000064400000000000000000000116031046102023000125550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::num::NonZeroU32; use glib::translate::*; use crate::{ffi, BusNameOwnerFlags, BusNameWatcherFlags, BusType, DBusConnection}; #[derive(Debug, Eq, PartialEq)] pub struct OwnerId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct WatcherId(NonZeroU32); fn own_closure(f: F) -> glib::Closure where F: Fn(DBusConnection, &str) + 'static, { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let name = args[1].get::<&str>().unwrap(); f(conn, name); None }) } fn appeared_closure(f: F) -> glib::Closure where F: Fn(DBusConnection, &str, &str) + 'static, { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let name = args[1].get::<&str>().unwrap(); let name_owner = args[2].get::<&str>().unwrap(); f(conn, name, name_owner); None }) } fn vanished_closure(f: F) -> glib::Closure where F: Fn(DBusConnection, &str) + 'static, { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let name = args[1].get::<&str>().unwrap(); f(conn, name); None }) } #[doc(alias = "g_bus_own_name_on_connection_with_closures")] pub fn bus_own_name_on_connection( connection: &DBusConnection, name: &str, flags: BusNameOwnerFlags, name_acquired: NameAcquired, name_lost: NameLost, ) -> OwnerId where NameAcquired: Fn(DBusConnection, &str) + 'static, NameLost: Fn(DBusConnection, &str) + 'static, { unsafe { let id = ffi::g_bus_own_name_on_connection_with_closures( connection.to_glib_none().0, name.to_glib_none().0, flags.into_glib(), own_closure(name_acquired).to_glib_none().0, own_closure(name_lost).to_glib_none().0, ); OwnerId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_bus_own_name_with_closures")] pub fn bus_own_name( bus_type: BusType, name: &str, flags: BusNameOwnerFlags, bus_acquired: BusAcquired, name_acquired: NameAcquired, name_lost: NameLost, ) -> OwnerId where BusAcquired: Fn(DBusConnection, &str) + 'static, NameAcquired: Fn(DBusConnection, &str) + 'static, NameLost: Fn(Option, &str) + 'static, { unsafe { let id = ffi::g_bus_own_name_with_closures( bus_type.into_glib(), name.to_glib_none().0, flags.into_glib(), own_closure(bus_acquired).to_glib_none().0, own_closure(name_acquired).to_glib_none().0, glib::Closure::new_local(move |args| { let conn = args[0].get::>().unwrap(); let name = args[1].get::<&str>().unwrap(); name_lost(conn, name); None }) .to_glib_none() .0, ); OwnerId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_bus_unown_name")] pub fn bus_unown_name(owner_id: OwnerId) { unsafe { ffi::g_bus_unown_name(owner_id.0.into()); } } #[doc(alias = "g_bus_watch_name_on_connection_with_closures")] pub fn bus_watch_name_on_connection( connection: &DBusConnection, name: &str, flags: BusNameWatcherFlags, name_appeared: NameAppeared, name_vanished: NameVanished, ) -> WatcherId where NameAppeared: Fn(DBusConnection, &str, &str) + 'static, NameVanished: Fn(DBusConnection, &str) + 'static, { unsafe { let id = ffi::g_bus_watch_name_on_connection_with_closures( connection.to_glib_none().0, name.to_glib_none().0, flags.into_glib(), appeared_closure(name_appeared).to_glib_none().0, vanished_closure(name_vanished).to_glib_none().0, ); WatcherId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_bus_watch_name_with_closures")] pub fn bus_watch_name( bus_type: BusType, name: &str, flags: BusNameWatcherFlags, name_appeared: NameAppeared, name_vanished: NameVanished, ) -> WatcherId where NameAppeared: Fn(DBusConnection, &str, &str) + 'static, NameVanished: Fn(DBusConnection, &str) + 'static, { unsafe { let id = ffi::g_bus_watch_name_with_closures( bus_type.into_glib(), name.to_glib_none().0, flags.into_glib(), appeared_closure(name_appeared).to_glib_none().0, vanished_closure(name_vanished).to_glib_none().0, ); WatcherId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_bus_unwatch_name")] pub fn bus_unwatch_name(watcher_id: WatcherId) { unsafe { ffi::g_bus_unwatch_name(watcher_id.0.into()); } } gio-0.20.1/src/dbus_connection.rs000064400000000000000000000334441046102023000150030ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, num::NonZeroU32}; use glib::{prelude::*, translate::*}; use crate::{ ffi, ActionGroup, DBusConnection, DBusInterfaceInfo, DBusMessage, DBusMethodInvocation, DBusSignalFlags, MenuModel, }; #[derive(Debug, Eq, PartialEq)] pub struct RegistrationId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct WatcherId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct ActionGroupExportId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct MenuModelExportId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct FilterId(NonZeroU32); #[derive(Debug, Eq, PartialEq)] pub struct SignalSubscriptionId(NonZeroU32); #[must_use = "The builder must be built to be used"] pub struct RegistrationBuilder<'a> { connection: &'a DBusConnection, object_path: &'a str, interface_info: &'a DBusInterfaceInfo, #[allow(clippy::type_complexity)] method_call: Option< Box_, >, #[allow(clippy::type_complexity)] get_property: Option glib::Variant>>, #[allow(clippy::type_complexity)] set_property: Option bool>>, } impl<'a> RegistrationBuilder<'a> { pub fn method_call< F: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant, DBusMethodInvocation) + 'static, >( mut self, f: F, ) -> Self { self.method_call = Some(Box_::new(f)); self } #[doc(alias = "get_property")] pub fn property glib::Variant + 'static>( mut self, f: F, ) -> Self { self.get_property = Some(Box_::new(f)); self } pub fn set_property< F: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant) -> bool + 'static, >( mut self, f: F, ) -> Self { self.set_property = Some(Box_::new(f)); self } pub fn build(self) -> Result { unsafe { let mut error = std::ptr::null_mut(); let id = ffi::g_dbus_connection_register_object_with_closures( self.connection.to_glib_none().0, self.object_path.to_glib_none().0, self.interface_info.to_glib_none().0, self.method_call .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let sender = args[1].get::<&str>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); let interface_name = args[3].get::<&str>().unwrap(); let method_name = args[4].get::<&str>().unwrap(); let parameters = args[5].get::().unwrap(); let invocation = args[6].get::().unwrap(); f( conn, sender, object_path, interface_name, method_name, parameters, invocation, ); None }) }) .to_glib_none() .0, self.set_property .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let sender = args[1].get::<&str>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); let interface_name = args[3].get::<&str>().unwrap(); let property_name = args[4].get::<&str>().unwrap(); let value = args[5].get::().unwrap(); let result = f( conn, sender, object_path, interface_name, property_name, value, ); Some(result.to_value()) }) }) .to_glib_none() .0, self.get_property .map(|f| { glib::Closure::new_local(move |args| { let conn = args[0].get::().unwrap(); let sender = args[1].get::<&str>().unwrap(); let object_path = args[2].get::<&str>().unwrap(); let interface_name = args[3].get::<&str>().unwrap(); let property_name = args[4].get::<&str>().unwrap(); let result = f(conn, sender, object_path, interface_name, property_name); Some(result.to_value()) }) }) .to_glib_none() .0, &mut error, ); if error.is_null() { Ok(RegistrationId(NonZeroU32::new_unchecked(id))) } else { Err(from_glib_full(error)) } } } } impl DBusConnection { #[doc(alias = "g_dbus_connection_register_object")] #[doc(alias = "g_dbus_connection_register_object_with_closures")] pub fn register_object<'a>( &'a self, object_path: &'a str, interface_info: &'a DBusInterfaceInfo, ) -> RegistrationBuilder<'a> { RegistrationBuilder { connection: self, object_path, interface_info, method_call: None, get_property: None, set_property: None, } } #[doc(alias = "g_dbus_connection_unregister_object")] pub fn unregister_object( &self, registration_id: RegistrationId, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_dbus_connection_unregister_object( self.to_glib_none().0, registration_id.0.into() ), "Failed to unregister D-Bus object" ) } } #[doc(alias = "g_dbus_connection_export_action_group")] pub fn export_action_group>( &self, object_path: &str, action_group: &P, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let id = ffi::g_dbus_connection_export_action_group( self.to_glib_none().0, object_path.to_glib_none().0, action_group.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(ActionGroupExportId(NonZeroU32::new_unchecked(id))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_unexport_action_group")] pub fn unexport_action_group(&self, export_id: ActionGroupExportId) { unsafe { ffi::g_dbus_connection_unexport_action_group(self.to_glib_none().0, export_id.0.into()); } } #[doc(alias = "g_dbus_connection_export_menu_model")] pub fn export_menu_model>( &self, object_path: &str, menu: &P, ) -> Result { unsafe { let mut error = std::ptr::null_mut(); let id = ffi::g_dbus_connection_export_menu_model( self.to_glib_none().0, object_path.to_glib_none().0, menu.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(MenuModelExportId(NonZeroU32::new_unchecked(id))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_unexport_menu_model")] pub fn unexport_menu_model(&self, export_id: MenuModelExportId) { unsafe { ffi::g_dbus_connection_unexport_menu_model(self.to_glib_none().0, export_id.0.into()); } } #[doc(alias = "g_dbus_connection_add_filter")] pub fn add_filter< P: Fn(&DBusConnection, &DBusMessage, bool) -> Option + 'static, >( &self, filter_function: P, ) -> FilterId { let filter_function_data: Box_

= Box_::new(filter_function); unsafe extern "C" fn filter_function_func< P: Fn(&DBusConnection, &DBusMessage, bool) -> Option + 'static, >( connection: *mut ffi::GDBusConnection, message: *mut ffi::GDBusMessage, incoming: glib::ffi::gboolean, user_data: glib::ffi::gpointer, ) -> *mut ffi::GDBusMessage { let connection = from_glib_borrow(connection); let message = from_glib_full(message); let incoming = from_glib(incoming); let callback: &P = &*(user_data as *mut _); let res = (*callback)(&connection, &message, incoming); res.into_glib_ptr() } let filter_function = Some(filter_function_func::

as _); unsafe extern "C" fn user_data_free_func_func< P: Fn(&DBusConnection, &DBusMessage, bool) -> Option + 'static, >( data: glib::ffi::gpointer, ) { let _callback: Box_

= Box_::from_raw(data as *mut _); } let destroy_call3 = Some(user_data_free_func_func::

as _); let super_callback0: Box_

= filter_function_data; unsafe { let id = ffi::g_dbus_connection_add_filter( self.to_glib_none().0, filter_function, Box_::into_raw(super_callback0) as *mut _, destroy_call3, ); FilterId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_dbus_connection_remove_filter")] pub fn remove_filter(&self, filter_id: FilterId) { unsafe { ffi::g_dbus_connection_remove_filter(self.to_glib_none().0, filter_id.0.into()); } } #[doc(alias = "g_dbus_connection_signal_subscribe")] #[allow(clippy::too_many_arguments)] pub fn signal_subscribe< P: Fn(&DBusConnection, &str, &str, &str, &str, &glib::Variant) + 'static, >( &self, sender: Option<&str>, interface_name: Option<&str>, member: Option<&str>, object_path: Option<&str>, arg0: Option<&str>, flags: DBusSignalFlags, callback: P, ) -> SignalSubscriptionId { let callback_data: Box_

= Box_::new(callback); unsafe extern "C" fn callback_func< P: Fn(&DBusConnection, &str, &str, &str, &str, &glib::Variant) + 'static, >( connection: *mut ffi::GDBusConnection, sender_name: *const libc::c_char, object_path: *const libc::c_char, interface_name: *const libc::c_char, signal_name: *const libc::c_char, parameters: *mut glib::ffi::GVariant, user_data: glib::ffi::gpointer, ) { let connection = from_glib_borrow(connection); let sender_name: Borrowed = from_glib_borrow(sender_name); let object_path: Borrowed = from_glib_borrow(object_path); let interface_name: Borrowed = from_glib_borrow(interface_name); let signal_name: Borrowed = from_glib_borrow(signal_name); let parameters = from_glib_borrow(parameters); let callback: &P = &*(user_data as *mut _); (*callback)( &connection, sender_name.as_str(), object_path.as_str(), interface_name.as_str(), signal_name.as_str(), ¶meters, ); } let callback = Some(callback_func::

as _); unsafe extern "C" fn user_data_free_func_func< P: Fn(&DBusConnection, &str, &str, &str, &str, &glib::Variant) + 'static, >( data: glib::ffi::gpointer, ) { let _callback: Box_

= Box_::from_raw(data as *mut _); } let destroy_call9 = Some(user_data_free_func_func::

as _); let super_callback0: Box_

= callback_data; unsafe { let id = ffi::g_dbus_connection_signal_subscribe( self.to_glib_none().0, sender.to_glib_none().0, interface_name.to_glib_none().0, member.to_glib_none().0, object_path.to_glib_none().0, arg0.to_glib_none().0, flags.into_glib(), callback, Box_::into_raw(super_callback0) as *mut _, destroy_call9, ); SignalSubscriptionId(NonZeroU32::new_unchecked(id)) } } #[doc(alias = "g_dbus_connection_signal_unsubscribe")] pub fn signal_unsubscribe(&self, subscription_id: SignalSubscriptionId) { unsafe { ffi::g_dbus_connection_signal_unsubscribe( self.to_glib_none().0, subscription_id.0.into(), ); } } } gio-0.20.1/src/dbus_message.rs000064400000000000000000000004131046102023000142560ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::fmt; use crate::DBusMessage; impl fmt::Display for DBusMessage { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.print(0)) } } gio-0.20.1/src/dbus_method_invocation.rs000064400000000000000000000015751046102023000163550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use crate::{ffi, DBusMethodInvocation}; impl DBusMethodInvocation { #[doc(alias = "g_dbus_method_invocation_return_error_literal")] pub fn return_error(&self, error: T, message: &str) { unsafe { ffi::g_dbus_method_invocation_return_error_literal( self.to_glib_full(), T::domain().into_glib(), error.code(), message.to_glib_none().0, ); } } #[doc(alias = "g_dbus_method_invocation_return_gerror")] pub fn return_gerror(&self, error: glib::Error) { unsafe { ffi::g_dbus_method_invocation_return_gerror( self.to_glib_full(), error.to_glib_none().0, ); } } } gio-0.20.1/src/dbus_node_info.rs000064400000000000000000000021031046102023000145700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ffi::CStr; use crate::{DBusInterfaceInfo, DBusNodeInfo}; impl DBusNodeInfo { pub fn path(&self) -> Option<&str> { unsafe { let c_obj = self.as_ptr(); let path = (*c_obj).path; if path.is_null() { return None; } let c_str = CStr::from_ptr(path); Some(c_str.to_str().unwrap()) } } pub fn interfaces(&self) -> &[DBusInterfaceInfo] { unsafe { let c_obj = self.as_ptr(); let c_ii = (*c_obj).interfaces; if c_ii.is_null() { return &[]; } glib::collections::PtrSlice::from_glib_borrow(c_ii) } } pub fn nodes(&self) -> &[DBusNodeInfo] { unsafe { let c_obj = self.as_ptr(); let c_ni = (*c_obj).nodes; if c_ni.is_null() { return &[]; } glib::collections::PtrSlice::from_glib_borrow(c_ni) } } } gio-0.20.1/src/dbus_proxy.rs000064400000000000000000000067751046102023000140340ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, mem::transmute}; use glib::{prelude::*, signal::connect_raw, translate::*, SignalHandlerId}; use crate::{ffi, DBusProxy}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DBusProxyExtManual: sealed::Sealed + IsA + 'static { #[cfg(feature = "v2_72")] #[doc(alias = "g-signal")] fn connect_g_signal< F: Fn(&Self, Option<&str>, &str, &glib::Variant) + Send + Sync + 'static, >( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId { unsafe extern "C" fn g_signal_trampoline< P: IsA, F: Fn(&P, Option<&str>, &str, &glib::Variant) + Send + Sync + 'static, >( this: *mut ffi::GDBusProxy, sender_name: *mut libc::c_char, signal_name: *mut libc::c_char, parameters: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusProxy::from_glib_borrow(this).unsafe_cast_ref(), Option::::from_glib_borrow(sender_name) .as_ref() .as_deref(), &glib::GString::from_glib_borrow(signal_name), &from_glib_borrow(parameters), ) } unsafe { let f: Box_ = Box_::new(f); let detailed_signal_name = detail.map(|name| format!("g-signal::{name}\0")); let signal_name: &[u8] = detailed_signal_name .as_ref() .map_or(&b"g-signal\0"[..], |n| n.as_bytes()); connect_raw( self.as_ptr() as *mut _, signal_name.as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( g_signal_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(not(feature = "v2_72"))] #[doc(alias = "g-signal")] fn connect_g_signal< F: Fn(&Self, Option<&str>, &str, &glib::Variant) + Send + Sync + 'static, >( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn g_signal_trampoline< P: IsA, F: Fn(&P, Option<&str>, &str, &glib::Variant) + Send + Sync + 'static, >( this: *mut ffi::GDBusProxy, sender_name: *mut libc::c_char, signal_name: *mut libc::c_char, parameters: *mut glib::ffi::GVariant, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f( DBusProxy::from_glib_borrow(this).unsafe_cast_ref(), Option::::from_glib_borrow(sender_name) .as_ref() .as_deref(), &glib::GString::from_glib_borrow(signal_name), &from_glib_borrow(parameters), ) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"g-signal\0".as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( g_signal_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl> DBusProxyExtManual for O {} gio-0.20.1/src/debug_controller_dbus.rs000064400000000000000000000010321046102023000161610ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::prelude::*; use crate::{DBusConnection, DebugControllerDBus}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait DebugControllerDBusExtManual: sealed::Sealed + IsA + Sized { fn connection(&self) -> DBusConnection { ObjectExt::property(self.as_ref(), "connection") } } impl> DebugControllerDBusExtManual for O {} gio-0.20.1/src/desktop_app_info.rs000064400000000000000000000110321046102023000151400ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(all(unix, feature = "v2_58"))] use std::boxed::Box as Box_; #[cfg(all(unix, feature = "v2_58"))] use std::os::unix::io::AsRawFd; #[cfg(all(unix, feature = "v2_58"))] use std::ptr; #[cfg(all(feature = "v2_58", unix))] use glib::{prelude::*, Error}; use glib::{translate::*, GString}; #[cfg(all(feature = "v2_58", unix))] use crate::AppLaunchContext; use crate::{ffi, DesktopAppInfo}; impl DesktopAppInfo { #[doc(alias = "g_desktop_app_info_search")] pub fn search(search_string: &str) -> Vec> { unsafe { let out = ffi::g_desktop_app_info_search(search_string.to_glib_none().0); if out.is_null() { return Vec::new(); } let mut ret = Vec::new(); let mut it = 0; loop { let tmp: *mut *mut libc::c_char = *out.offset(it); if tmp.is_null() { break; } let v: Vec = FromGlibPtrContainer::from_glib_full(tmp); ret.push(v); it += 1; } glib::ffi::g_free(out as *mut libc::c_void); ret } } } #[cfg(all(feature = "v2_58", unix))] mod sealed { pub trait Sealed {} impl> Sealed for T {} } #[cfg(all(feature = "v2_58", unix))] pub trait DesktopAppInfoExtManual: sealed::Sealed + IsA { #[cfg_attr(docsrs, doc(cfg(all(feature = "v2_58", unix))))] #[doc(alias = "g_desktop_app_info_launch_uris_as_manager_with_fds")] fn launch_uris_as_manager_with_fds< P: IsA, T: AsRawFd, U: AsRawFd, V: AsRawFd, >( &self, uris: &[&str], launch_context: Option<&P>, spawn_flags: glib::SpawnFlags, user_setup: Option>, pid_callback: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>, stdin_fd: &mut T, stdout_fd: &mut U, stderr_fd: &mut V, ) -> Result<(), Error> { let user_setup_data: Box_>> = Box_::new(user_setup); unsafe extern "C" fn user_setup_func(user_data: glib::ffi::gpointer) { let callback: Box_>> = Box_::from_raw(user_data as *mut _); let callback = (*callback).expect("cannot get closure..."); callback() } let user_setup = if user_setup_data.is_some() { Some(user_setup_func as _) } else { None }; let pid_callback_data: Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = pid_callback; unsafe extern "C" fn pid_callback_func( appinfo: *mut ffi::GDesktopAppInfo, pid: glib::ffi::GPid, user_data: glib::ffi::gpointer, ) { let appinfo = from_glib_borrow(appinfo); let pid = from_glib(pid); let callback = user_data as *mut Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))>; if let Some(ref mut callback) = *callback { callback(&appinfo, pid) } else { panic!("cannot get closure...") }; } let pid_callback = if pid_callback_data.is_some() { Some(pid_callback_func as _) } else { None }; let super_callback0: Box_>> = user_setup_data; let super_callback1: &Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = &pid_callback_data; unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_desktop_app_info_launch_uris_as_manager_with_fds( self.as_ref().to_glib_none().0, uris.to_glib_none().0, launch_context.map(|p| p.as_ref()).to_glib_none().0, spawn_flags.into_glib(), user_setup, Box_::into_raw(super_callback0) as *mut _, pid_callback, super_callback1 as *const _ as *mut _, stdin_fd.as_raw_fd(), stdout_fd.as_raw_fd(), stderr_fd.as_raw_fd(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } #[cfg(all(feature = "v2_58", unix))] impl> DesktopAppInfoExtManual for O {} gio-0.20.1/src/error.rs000064400000000000000000000032451046102023000127540ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::io; #[cfg(feature = "v2_74")] use crate::glib::translate::*; #[cfg(feature = "v2_74")] use crate::glib::FileError; use crate::IOErrorEnum; impl From for io::ErrorKind { fn from(kind: IOErrorEnum) -> Self { match kind { IOErrorEnum::NotFound => Self::NotFound, IOErrorEnum::Exists => Self::AlreadyExists, IOErrorEnum::InvalidFilename => Self::InvalidInput, IOErrorEnum::InvalidArgument => Self::InvalidInput, IOErrorEnum::PermissionDenied => Self::PermissionDenied, IOErrorEnum::AddressInUse => Self::AddrInUse, IOErrorEnum::TimedOut => Self::TimedOut, IOErrorEnum::WouldBlock => Self::WouldBlock, IOErrorEnum::InvalidData => Self::InvalidData, IOErrorEnum::ConnectionRefused => Self::ConnectionRefused, IOErrorEnum::BrokenPipe => Self::BrokenPipe, IOErrorEnum::NotConnected => Self::NotConnected, _ => Self::Other, } } } pub(crate) fn to_std_io_result(result: Result) -> io::Result { result.map_err(|g_error| match g_error.kind::() { Some(io_error_enum) => io::Error::new(io_error_enum.into(), g_error), None => io::Error::new(io::ErrorKind::Other, g_error), }) } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] impl From for IOErrorEnum { #[doc(alias = "g_io_error_from_file_error")] fn from(e: FileError) -> Self { unsafe { from_glib(crate::ffi::g_io_error_from_file_error(e.into_glib())) } } } gio-0.20.1/src/file.rs000064400000000000000000001227331046102023000125460ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::RefCell, mem, pin::Pin, ptr}; use glib::{prelude::*, translate::*}; #[cfg(feature = "v2_74")] use crate::FileIOStream; use crate::{ffi, Cancellable, File, FileCreateFlags, FileEnumerator, FileQueryInfoFlags}; impl File { #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_file_new_tmp_async")] pub fn new_tmp_async) + 'static>( tmpl: Option>, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn new_tmp_async_trampoline< P: FnOnce(Result<(File, FileIOStream), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let mut iostream = ptr::null_mut(); let ret = ffi::g_file_new_tmp_finish(res, &mut iostream, &mut error); let result = if error.is_null() { Ok((from_glib_full(ret), from_glib_full(iostream))) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = new_tmp_async_trampoline::

; unsafe { ffi::g_file_new_tmp_async( tmpl.as_ref().map(|p| p.as_ref()).to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub fn new_tmp_future( tmpl: Option>, io_priority: glib::Priority, ) -> Pin< Box> + 'static>, > { let tmpl = tmpl.map(|tmpl| tmpl.as_ref().to_owned()); Box::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::new_tmp_async( tmpl.as_ref() .map(>::borrow), io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_file_new_tmp_dir_async")] pub fn new_tmp_dir_async) + 'static>( tmpl: Option>, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn new_tmp_dir_async_trampoline< P: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let ret = ffi::g_file_new_tmp_dir_finish(res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = new_tmp_dir_async_trampoline::

; unsafe { ffi::g_file_new_tmp_dir_async( tmpl.as_ref().map(|p| p.as_ref()).to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] pub fn new_tmp_dir_future( tmpl: Option>, io_priority: glib::Priority, ) -> Pin> + 'static>> { let tmpl = tmpl.map(|tmpl| tmpl.as_ref().to_owned()); Box::pin(crate::GioFuture::new( &(), move |_obj, cancellable, send| { Self::new_tmp_dir_async( tmpl.as_ref() .map(>::borrow), io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_file_replace_contents_async")] fn replace_contents_async< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, glib::Error)>) + 'static, C: IsA, >( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&C>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let etag = etag.to_glib_none(); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), contents)); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, contents_ptr) = { let contents = &user_data.1; let slice = contents.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn replace_contents_async_trampoline< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::from_raw(user_data as *mut _); let (callback, contents) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let mut new_etag = ptr::null_mut(); let _ = ffi::g_file_replace_contents_finish( _source_object as *mut _, res, &mut new_etag, &mut error, ); let result = if error.is_null() { Ok((contents, from_glib_full(new_etag))) } else { Err((contents, from_glib_full(error))) }; callback(result); } let callback = replace_contents_async_trampoline::; unsafe { ffi::g_file_replace_contents_async( self.as_ref().to_glib_none().0, mut_override(contents_ptr), count, etag.0, make_backup.into_glib(), flags.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn replace_contents_future + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Pin< Box< dyn std::future::Future> + 'static, >, > { let etag = etag.map(glib::GString::from); Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.replace_contents_async( contents, etag.as_ref().map(|s| s.as_str()), make_backup, flags, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_enumerate_children_async")] fn enumerate_children_async< P: IsA, Q: FnOnce(Result) + 'static, >( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn create_async_trampoline< Q: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let ret = ffi::g_file_enumerate_children_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback = callback.into_inner(); callback(result); } let callback = create_async_trampoline::; unsafe { ffi::g_file_enumerate_children_async( self.as_ref().to_glib_none().0, attributes.to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn enumerate_children_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { let attributes = attributes.to_owned(); Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.enumerate_children_async( &attributes, flags, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[doc(alias = "g_file_copy_async")] fn copy_async) + 'static>( &self, destination: &impl IsA, flags: crate::FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, progress_callback: Option>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let progress_trampoline = if progress_callback.is_some() { Some(copy_async_progress_trampoline:: as _) } else { None }; let user_data: Box<( glib::thread_guard::ThreadGuard, RefCell>>>, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), RefCell::new(progress_callback.map(glib::thread_guard::ThreadGuard::new)), )); unsafe extern "C" fn copy_async_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); ffi::g_file_copy_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box<( glib::thread_guard::ThreadGuard, RefCell>>>, )> = Box::from_raw(user_data as *mut _); let callback = callback.0.into_inner(); callback(result); } unsafe extern "C" fn copy_async_progress_trampoline< Q: FnOnce(Result<(), glib::Error>) + 'static, >( current_num_bytes: i64, total_num_bytes: i64, user_data: glib::ffi::gpointer, ) { let callback: &( glib::thread_guard::ThreadGuard, RefCell>>>, ) = &*(user_data as *const _); (callback .1 .borrow_mut() .as_mut() .expect("no closure") .get_mut())(current_num_bytes, total_num_bytes); } let user_data = Box::into_raw(user_data) as *mut _; unsafe { ffi::g_file_copy_async( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_trampoline, user_data, Some(copy_async_trampoline::), user_data, ); } } fn copy_future( &self, destination: &(impl IsA + Clone + 'static), flags: crate::FileCopyFlags, io_priority: glib::Priority, ) -> ( Pin> + 'static>>, Pin + 'static>>, ) { let destination = destination.clone(); let (sender, receiver) = futures_channel::mpsc::unbounded(); let fut = Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.copy_async( &destination, flags, io_priority, Some(cancellable), Some(Box::new(move |current_num_bytes, total_num_bytes| { let _ = sender.unbounded_send((current_num_bytes, total_num_bytes)); })), move |res| { send.resolve(res); }, ); }, )); (fut, Box::pin(receiver)) } #[doc(alias = "g_file_load_contents")] fn load_contents( &self, cancellable: Option<&impl IsA>, ) -> Result<(glib::collections::Slice, Option), glib::Error> { unsafe { let mut contents = std::ptr::null_mut(); let mut length = std::mem::MaybeUninit::uninit(); let mut etag_out = std::ptr::null_mut(); let mut error = std::ptr::null_mut(); let is_ok = ffi::g_file_load_contents( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut contents, length.as_mut_ptr(), &mut etag_out, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length.assume_init() as _), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_load_contents_async")] fn load_contents_async< P: FnOnce(Result<(glib::collections::Slice, Option), glib::Error>) + 'static, >( &self, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn load_contents_async_trampoline< P: FnOnce(Result<(glib::collections::Slice, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = std::ptr::null_mut(); let mut contents = std::ptr::null_mut(); let mut length = std::mem::MaybeUninit::uninit(); let mut etag_out = std::ptr::null_mut(); let _ = ffi::g_file_load_contents_finish( _source_object as *mut _, res, &mut contents, length.as_mut_ptr(), &mut etag_out, &mut error, ); let result = if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length.assume_init() as _), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = load_contents_async_trampoline::

; unsafe { ffi::g_file_load_contents_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn load_contents_future( &self, ) -> Pin< Box< dyn std::future::Future< Output = Result< (glib::collections::Slice, Option), glib::Error, >, > + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.load_contents_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[doc(alias = "g_file_load_partial_contents_async")] fn load_partial_contents_async< P: FnMut(&[u8]) -> bool + 'static, Q: FnOnce(Result<(glib::collections::Slice, Option), glib::Error>) + 'static, >( &self, cancellable: Option<&impl IsA>, read_more_callback: P, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box<( glib::thread_guard::ThreadGuard, RefCell>, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), RefCell::new(glib::thread_guard::ThreadGuard::new(read_more_callback)), )); unsafe extern "C" fn load_partial_contents_async_trampoline< P: FnMut(&[u8]) -> bool + 'static, Q: FnOnce(Result<(glib::collections::Slice, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut contents = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let mut etag_out = ptr::null_mut(); let mut error = ptr::null_mut(); ffi::g_file_load_partial_contents_finish( _source_object as *mut _, res, &mut contents, length.as_mut_ptr(), &mut etag_out, &mut error, ); let result = if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length.assume_init() as _), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) }; let callback: Box<( glib::thread_guard::ThreadGuard, RefCell>, )> = Box::from_raw(user_data as *mut _); let callback = callback.0.into_inner(); callback(result); } unsafe extern "C" fn load_partial_contents_async_read_more_trampoline< P: FnMut(&[u8]) -> bool + 'static, Q: FnOnce(Result<(glib::collections::Slice, Option), glib::Error>) + 'static, >( file_contents: *const libc::c_char, file_size: i64, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { use std::slice; let callback: &( glib::thread_guard::ThreadGuard, RefCell>, ) = &*(user_data as *const _); let data = if file_size == 0 { &[] } else { slice::from_raw_parts(file_contents as *const u8, file_size as usize) }; (*callback.1.borrow_mut().get_mut())(data).into_glib() } let user_data = Box::into_raw(user_data) as *mut _; unsafe { ffi::g_file_load_partial_contents_async( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(load_partial_contents_async_read_more_trampoline::), Some(load_partial_contents_async_trampoline::), user_data, ); } } #[doc(alias = "g_file_measure_disk_usage")] fn measure_disk_usage( &self, flags: crate::FileMeasureFlags, cancellable: Option<&impl IsA>, progress_callback: Option>, ) -> Result<(u64, u64, u64), glib::Error> { let progress_callback_data: Box< Option>>, > = Box::new(progress_callback.map(RefCell::new)); unsafe extern "C" fn progress_callback_func( reporting: glib::ffi::gboolean, current_size: u64, num_dirs: u64, num_files: u64, user_data: glib::ffi::gpointer, ) { let reporting = from_glib(reporting); let callback: &Option>> = &*(user_data as *mut _); if let Some(ref callback) = *callback { (*callback.borrow_mut())(reporting, current_size, num_dirs, num_files) } else { panic!("cannot get closure...") }; } let progress_callback = if progress_callback_data.is_some() { Some(progress_callback_func as _) } else { None }; let super_callback0: Box>>> = progress_callback_data; unsafe { let mut disk_usage = mem::MaybeUninit::uninit(); let mut num_dirs = mem::MaybeUninit::uninit(); let mut num_files = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = ffi::g_file_measure_disk_usage( self.as_ref().to_glib_none().0, flags.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback, Box::into_raw(super_callback0) as *mut _, disk_usage.as_mut_ptr(), num_dirs.as_mut_ptr(), num_files.as_mut_ptr(), &mut error, ); let disk_usage = disk_usage.assume_init(); let num_dirs = num_dirs.assume_init(); let num_files = num_files.assume_init(); if error.is_null() { Ok((disk_usage, num_dirs, num_files)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_file_measure_disk_usage_async")] fn measure_disk_usage_async) + 'static>( &self, flags: crate::FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, progress_callback: Option>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let progress_callback_trampoline = if progress_callback.is_some() { Some(measure_disk_usage_async_progress_trampoline::

as _) } else { None }; let user_data: Box<( glib::thread_guard::ThreadGuard

, RefCell< Option< glib::thread_guard::ThreadGuard>, >, >, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), RefCell::new(progress_callback.map(glib::thread_guard::ThreadGuard::new)), )); unsafe extern "C" fn measure_disk_usage_async_trampoline< P: FnOnce(Result<(u64, u64, u64), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut disk_usage = mem::MaybeUninit::uninit(); let mut num_dirs = mem::MaybeUninit::uninit(); let mut num_files = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); ffi::g_file_measure_disk_usage_finish( _source_object as *mut _, res, disk_usage.as_mut_ptr(), num_dirs.as_mut_ptr(), num_files.as_mut_ptr(), &mut error, ); let result = if error.is_null() { Ok(( disk_usage.assume_init(), num_dirs.assume_init(), num_files.assume_init(), )) } else { Err(from_glib_full(error)) }; let callback: Box<( glib::thread_guard::ThreadGuard

, RefCell< Option< glib::thread_guard::ThreadGuard< Box, >, >, >, )> = Box::from_raw(user_data as *mut _); let callback = callback.0.into_inner(); callback(result); } unsafe extern "C" fn measure_disk_usage_async_progress_trampoline< P: FnOnce(Result<(u64, u64, u64), glib::Error>) + 'static, >( reporting: glib::ffi::gboolean, disk_usage: u64, num_dirs: u64, num_files: u64, user_data: glib::ffi::gpointer, ) { let callback: &( glib::thread_guard::ThreadGuard

, RefCell< Option< glib::thread_guard::ThreadGuard< Box, >, >, >, ) = &*(user_data as *const _); (callback .1 .borrow_mut() .as_mut() .expect("can't get callback") .get_mut())(from_glib(reporting), disk_usage, num_dirs, num_files); } let user_data = Box::into_raw(user_data) as *mut _; unsafe { ffi::g_file_measure_disk_usage_async( self.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_callback_trampoline, user_data, Some(measure_disk_usage_async_trampoline::

), user_data, ); } } fn measure_disk_usage_future( &self, flags: crate::FileMeasureFlags, io_priority: glib::Priority, ) -> ( Pin> + 'static>>, Pin + 'static>>, ) { let (sender, receiver) = futures_channel::mpsc::unbounded(); let fut = Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.measure_disk_usage_async( flags, io_priority, Some(cancellable), Some(Box::new( move |reporting, disk_usage, num_dirs, num_files| { let _ = sender.unbounded_send((reporting, disk_usage, num_dirs, num_files)); }, )), move |res| { send.resolve(res); }, ); }, )); (fut, Box::pin(receiver)) } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] #[doc(alias = "g_file_move_async")] fn move_async) + 'static>( &self, destination: &impl IsA, flags: crate::FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&impl IsA>, progress_callback: Option>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let progress_trampoline = if progress_callback.is_some() { Some(move_async_progress_trampoline:: as _) } else { None }; let user_data: Box<( glib::thread_guard::ThreadGuard, RefCell>>>, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), RefCell::new(progress_callback.map(glib::thread_guard::ThreadGuard::new)), )); unsafe extern "C" fn move_async_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); ffi::g_file_move_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box<( glib::thread_guard::ThreadGuard, RefCell>>>, )> = Box::from_raw(user_data as *mut _); let callback = callback.0.into_inner(); callback(result); } unsafe extern "C" fn move_async_progress_trampoline< Q: FnOnce(Result<(), glib::Error>) + 'static, >( current_num_bytes: i64, total_num_bytes: i64, user_data: glib::ffi::gpointer, ) { let callback: &( glib::thread_guard::ThreadGuard, RefCell>>>, ) = &*(user_data as *const _); (callback .1 .borrow_mut() .as_mut() .expect("no closure") .get_mut())(current_num_bytes, total_num_bytes); } let user_data = Box::into_raw(user_data) as *mut _; unsafe { ffi::g_file_move_async( self.as_ref().to_glib_none().0, destination.as_ref().to_glib_none().0, flags.into_glib(), io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, progress_trampoline, user_data, Some(move_async_trampoline::), user_data, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_file_make_symbolic_link_async")] fn make_symbolic_link_async) + 'static>( &self, symlink_value: impl AsRef, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let user_data: Box> = Box::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn make_symbolic_link_async_trampoline< P: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let _ = ffi::g_file_make_symbolic_link_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; let callback: Box> = Box::from_raw(user_data as *mut _); let callback: P = callback.into_inner(); callback(result); } let callback = make_symbolic_link_async_trampoline::

; unsafe { ffi::g_file_make_symbolic_link_async( self.as_ref().to_glib_none().0, symlink_value.as_ref().to_glib_none().0, io_priority.into_glib(), cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] fn make_symbolic_link_future( &self, symlink_value: impl AsRef, io_priority: glib::Priority, ) -> Pin> + 'static>> { let symlink_value = symlink_value.as_ref().to_owned(); Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.make_symbolic_link_async( &symlink_value, io_priority, Some(cancellable), move |res| { send.resolve(res); }, ); }, )) } #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] fn move_future( &self, destination: &(impl IsA + Clone + 'static), flags: crate::FileCopyFlags, io_priority: glib::Priority, ) -> ( Pin> + 'static>>, Pin + 'static>>, ) { let destination = destination.clone(); let (sender, receiver) = futures_channel::mpsc::unbounded(); let fut = Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.move_async( &destination, flags, io_priority, Some(cancellable), Some(Box::new(move |current_num_bytes, total_num_bytes| { let _ = sender.unbounded_send((current_num_bytes, total_num_bytes)); })), move |res| { send.resolve(res); }, ); }, )); (fut, Box::pin(receiver)) } } impl> FileExtManual for O {} gio-0.20.1/src/file_attribute_info.rs000064400000000000000000000034061046102023000156370ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{fmt, mem, ptr}; use crate::ffi; use glib::translate::*; glib::wrapper! { #[doc(alias = "GFileAttributeInfo")] pub struct FileAttributeInfo(BoxedInline); match fn { copy => |ptr| { let copy = glib::ffi::g_malloc0(mem::size_of::()) as *mut ffi::GFileAttributeInfo; (*copy).name = glib::ffi::g_strdup((*ptr).name); copy }, free => |ptr| { glib::ffi::g_free((*ptr).name as *mut _); glib::ffi::g_free(ptr as *mut _); }, init => |ptr| { *ptr = mem::zeroed(); }, copy_into => |dest, src| { ptr::copy_nonoverlapping(src, dest, 1); (*dest).name = glib::ffi::g_strdup((*dest).name); }, clear => |ptr| { glib::ffi::g_free((*ptr).name as *mut _); }, } } impl FileAttributeInfo { #[inline] pub fn name(&self) -> &str { unsafe { use std::ffi::CStr; CStr::from_ptr(self.inner.name) .to_str() .expect("non-UTF-8 string") } } #[inline] pub fn type_(&self) -> crate::FileAttributeType { unsafe { from_glib(self.inner.type_) } } #[inline] pub fn flags(&self) -> crate::FileAttributeInfoFlags { unsafe { from_glib(self.inner.flags) } } } impl fmt::Debug for FileAttributeInfo { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FileAttributeInfo") .field("name", &self.name()) .field("type", &self.type_()) .field("flags", &self.flags()) .finish() } } gio-0.20.1/src/file_attribute_info_list.rs000064400000000000000000000015521046102023000166720ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::*; use crate::{ffi, FileAttributeInfo, FileAttributeInfoList}; impl FileAttributeInfoList { #[doc(alias = "g_file_attribute_info_list_lookup")] pub fn lookup(&self, name: &str) -> Option { unsafe { let res = ffi::g_file_attribute_info_list_lookup( self.to_glib_none().0, name.to_glib_none().0, ); if res.is_null() { None } else { Some(from_glib_none(res)) } } } pub fn attributes(&self) -> Vec { unsafe { let ptr: *const _ = self.to_glib_none().0; FromGlibContainer::from_glib_none_num((*ptr).infos, (*ptr).n_infos as usize) } } } gio-0.20.1/src/file_attribute_matcher.rs000064400000000000000000000015071046102023000163270ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::iter::FusedIterator; use crate::ffi; use glib::{translate::*, GString}; pub struct FileAttributematcherIter(crate::FileAttributeMatcher); impl Iterator for FileAttributematcherIter { type Item = GString; #[doc(alias = "g_file_attribute_matcher_enumerate_next")] fn next(&mut self) -> Option { unsafe { from_glib_none(ffi::g_file_attribute_matcher_enumerate_next( self.0.to_glib_none().0, )) } } } impl FusedIterator for FileAttributematcherIter {} impl IntoIterator for crate::FileAttributeMatcher { type Item = GString; type IntoIter = FileAttributematcherIter; fn into_iter(self) -> Self::IntoIter { FileAttributematcherIter(self) } } gio-0.20.1/src/file_descriptor_based.rs000064400000000000000000000025171046102023000161370ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use crate::ffi; use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; glib::wrapper! { #[doc(alias = "GFileDescriptorBased")] pub struct FileDescriptorBased(Interface); match fn { type_ => || ffi::g_file_descriptor_based_get_type(), } } impl FileDescriptorBased { pub const NONE: Option<&'static FileDescriptorBased> = None; } impl AsRawFd for FileDescriptorBased { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_file_descriptor_based_get_fd(self.to_glib_none().0) as _ } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileDescriptorBasedExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "g_file_descriptor_based_get_fd")] #[doc(alias = "get_fd")] fn fd(&self) -> T { unsafe { T::from_raw_fd(ffi::g_file_descriptor_based_get_fd( self.as_ref().to_glib_none().0, )) } } } impl> FileDescriptorBasedExtManual for O {} gio-0.20.1/src/file_enumerator.rs000064400000000000000000000110631046102023000150000ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::{prelude::*, FileEnumerator, FileInfo}; use futures_core::future::LocalBoxFuture; use futures_util::FutureExt; use std::{iter::FusedIterator, task::Poll}; impl Iterator for FileEnumerator { type Item = Result; fn next(&mut self) -> Option> { match self.next_file(crate::Cancellable::NONE) { Err(err) => Some(Err(err)), Ok(file_info) => file_info.map(Ok), } } } impl FusedIterator for FileEnumerator {} mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait FileEnumeratorExtManual: sealed::Sealed + IsA { // rustdoc-stripper-ignore-next /// Converts the enumerator into a [`Stream`](futures_core::Stream). fn into_stream(self, num_files: i32, priority: glib::Priority) -> FileEnumeratorStream { let future = Some(self.next_files_future(num_files, priority)); FileEnumeratorStream { enumerator: self.upcast(), future, num_files, priority, } } } impl> FileEnumeratorExtManual for O {} // rustdoc-stripper-ignore-next /// A [`Stream`](futures_core::Stream) used to enumerate files in directories. pub struct FileEnumeratorStream { enumerator: FileEnumerator, future: Option, glib::Error>>>, num_files: i32, priority: glib::Priority, } impl std::fmt::Debug for FileEnumeratorStream { #[inline] fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("FileEnumeratorStream") .field("enumerator", &self.enumerator) .field("num_files", &self.num_files) .field("priority", &self.priority) .finish() } } impl futures_core::Stream for FileEnumeratorStream { type Item = Result, glib::Error>; #[inline] fn poll_next( mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> Poll> { match self.future.take() { Some(mut f) => match f.poll_unpin(cx) { Poll::Ready(Ok(fs)) if fs.is_empty() => Poll::Ready(None), Poll::Ready(Ok(fs)) => { self.future = Some( self.enumerator .next_files_future(self.num_files, self.priority), ); Poll::Ready(Some(Ok(fs))) } Poll::Ready(Err(e)) => Poll::Ready(Some(Err(e))), Poll::Pending => { self.future = Some(f); Poll::Pending } }, None => Poll::Ready(None), } } } impl futures_core::FusedStream for FileEnumeratorStream { #[inline] fn is_terminated(&self) -> bool { self.future.is_none() } } #[cfg(test)] mod tests { use crate::prelude::*; use futures_util::StreamExt; use std::{cell::Cell, rc::Rc}; #[test] fn file_enumerator_stream() { let dir = std::env::current_dir().unwrap(); let ctx = glib::MainContext::new(); let lp = glib::MainLoop::new(Some(&ctx), false); let res = Rc::new(Cell::new(None)); let lp_clone = lp.clone(); let res_clone = res.clone(); ctx.spawn_local(async move { res_clone.replace(Some( async { let dir = crate::File::for_path(dir); let mut stream = dir .enumerate_children_future( crate::FILE_ATTRIBUTE_STANDARD_NAME, crate::FileQueryInfoFlags::NONE, glib::Priority::default(), ) .await? .into_stream(4, glib::Priority::default()); while let Some(files) = stream.next().await { for file in files? { let _ = file.name(); } } Ok::<_, glib::Error>(()) } .await, )); lp_clone.quit(); }); lp.run(); // propagate any error from the future into a panic Rc::try_unwrap(res) .unwrap_or_else(|_| panic!("future not finished")) .into_inner() .unwrap() .unwrap(); } } gio-0.20.1/src/file_info.rs000064400000000000000000000047751046102023000135660ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ mem, time::{Duration, SystemTime}, }; use glib::{translate::*, StrV}; use crate::{ffi, FileInfo}; impl FileInfo { #[cfg_attr(feature = "v2_62", deprecated)] #[doc(alias = "g_file_info_get_modification_time")] #[doc(alias = "get_modification_time")] pub fn modification_time(&self) -> SystemTime { unsafe { let mut result = mem::MaybeUninit::uninit(); ffi::g_file_info_get_modification_time(self.to_glib_none().0, result.as_mut_ptr()); let result = result.assume_init(); if result.tv_sec > 0 { let duration = Duration::from_secs(result.tv_sec as u64) + Duration::from_millis(result.tv_usec as u64); SystemTime::UNIX_EPOCH + duration } else { let duration = Duration::from_secs((-result.tv_sec) as u64) + Duration::from_millis(result.tv_usec as u64); SystemTime::UNIX_EPOCH - duration } } } #[cfg_attr(feature = "v2_62", deprecated)] #[doc(alias = "g_file_info_set_modification_time")] pub fn set_modification_time(&self, mtime: SystemTime) { let diff = mtime .duration_since(SystemTime::UNIX_EPOCH) .expect("failed to convert time"); unsafe { ffi::g_file_info_set_modification_time( self.to_glib_none().0, mut_override(&glib::ffi::GTimeVal { tv_sec: diff.as_secs() as _, tv_usec: diff.subsec_micros() as _, }), ); } } #[doc(alias = "g_file_info_get_attribute_stringv")] #[doc(alias = "get_attribute_stringv")] pub fn attribute_stringv(&self, attribute: &str) -> StrV { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_file_info_get_attribute_stringv( self.to_glib_none().0, attribute.to_glib_none().0, )) } } #[doc(alias = "g_file_info_set_attribute_stringv")] pub fn set_attribute_stringv(&self, attribute: &str, attr_value: impl IntoStrV) { unsafe { attr_value.run_with_strv(|attr_value| { ffi::g_file_info_set_attribute_stringv( self.to_glib_none().0, attribute.to_glib_none().0, attr_value.as_ptr() as *mut _, ); }); } } } gio-0.20.1/src/flags.rs000064400000000000000000000003141046102023000127110ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ApplicationFlags; impl Default for ApplicationFlags { fn default() -> Self { Self::empty() } } gio-0.20.1/src/gio_future.rs000064400000000000000000000070471046102023000137770ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ future::Future, pin::{self, Pin}, }; use futures_channel::oneshot; use futures_core::{ task::{Context, Poll}, FusedFuture, }; use crate::{prelude::*, Cancellable}; pub struct GioFuture { obj: O, schedule_operation: Option, cancellable: Option, receiver: Option>, } pub struct GioFutureResult { sender: oneshot::Sender, } impl GioFutureResult { pub fn resolve(self, res: T) { let _ = self.sender.send(res); } } impl GioFuture where O: Clone + 'static, F: FnOnce(&O, &Cancellable, GioFutureResult) + 'static, { pub fn new(obj: &O, schedule_operation: F) -> GioFuture { GioFuture { obj: obj.clone(), schedule_operation: Some(schedule_operation), cancellable: Some(Cancellable::new()), receiver: None, } } } impl Future for GioFuture where O: Clone + 'static, F: FnOnce(&O, &Cancellable, GioFutureResult) + 'static, { type Output = T; fn poll(mut self: pin::Pin<&mut Self>, ctx: &mut Context) -> Poll { let GioFuture { ref obj, ref mut schedule_operation, ref mut cancellable, ref mut receiver, .. } = *self; if let Some(schedule_operation) = schedule_operation.take() { let main_context = glib::MainContext::ref_thread_default(); assert!( main_context.is_owner(), "Spawning futures only allowed if the thread is owning the MainContext" ); // Channel for sending back the GIO async operation // result to our future here. // // In theory, we could directly continue polling the // corresponding task from the GIO async operation // callback, however this would break at the very // least the g_main_current_source() API. let (send, recv) = oneshot::channel(); schedule_operation( obj, cancellable.as_ref().unwrap(), GioFutureResult { sender: send }, ); *receiver = Some(recv); } // At this point we must have a receiver let res = { let receiver = receiver.as_mut().unwrap(); Pin::new(receiver).poll(ctx) }; match res { Poll::Pending => Poll::Pending, Poll::Ready(Err(_)) => panic!("Async operation sender was unexpectedly closed"), Poll::Ready(Ok(v)) => { // Get rid of the reference to the cancellable and receiver let _ = cancellable.take(); let _ = receiver.take(); Poll::Ready(v) } } } } impl FusedFuture for GioFuture where O: Clone + 'static, F: FnOnce(&O, &Cancellable, GioFutureResult) + 'static, { fn is_terminated(&self) -> bool { self.schedule_operation.is_none() && self .receiver .as_ref() .map_or(true, |receiver| receiver.is_terminated()) } } impl Drop for GioFuture { fn drop(&mut self) { if let Some(cancellable) = self.cancellable.take() { cancellable.cancel(); } let _ = self.receiver.take(); } } impl Unpin for GioFuture {} gio-0.20.1/src/inet_address.rs000064400000000000000000000053361046102023000142720ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; use glib::{prelude::*, translate::*}; use crate::{ffi, prelude::*, InetAddress, SocketFamily}; #[derive(Debug)] pub enum InetAddressBytes<'a> { V4(&'a [u8; 4]), V6(&'a [u8; 16]), } impl<'a> InetAddressBytes<'a> { #[inline] fn deref(&self) -> &[u8] { use self::InetAddressBytes::*; match *self { V4(bytes) => bytes, V6(bytes) => bytes, } } } impl InetAddress { #[doc(alias = "g_inet_address_new_from_bytes")] pub fn from_bytes(inet_address_bytes: InetAddressBytes) -> Self { let bytes = inet_address_bytes.deref(); let family = match inet_address_bytes { InetAddressBytes::V4(_) => SocketFamily::Ipv4, InetAddressBytes::V6(_) => SocketFamily::Ipv6, }; unsafe { from_glib_full(ffi::g_inet_address_new_from_bytes( bytes.to_glib_none().0, family.into_glib(), )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InetAddressExtManual: sealed::Sealed + IsA + 'static { // rustdoc-stripper-ignore-next /// Returns `None` in case the address has a native size different than 4 and 16. #[doc(alias = "g_inet_address_to_bytes")] #[inline] fn to_bytes(&self) -> Option> { let size = self.native_size(); unsafe { let bytes = ffi::g_inet_address_to_bytes(self.as_ref().to_glib_none().0); if size == 4 { Some(InetAddressBytes::V4(&*(bytes as *const [u8; 4]))) } else if size == 16 { Some(InetAddressBytes::V6(&*(bytes as *const [u8; 16]))) } else { None } } } } impl> InetAddressExtManual for O {} impl From for InetAddress { fn from(addr: IpAddr) -> Self { match addr { IpAddr::V4(v4) => Self::from_bytes(InetAddressBytes::V4(&v4.octets())), IpAddr::V6(v6) => Self::from_bytes(InetAddressBytes::V6(&v6.octets())), } } } impl From for IpAddr { fn from(addr: InetAddress) -> Self { let size = addr.native_size(); unsafe { let bytes = ffi::g_inet_address_to_bytes(addr.to_glib_none().0); if size == 4 { Self::V4(Ipv4Addr::from(*(bytes as *const [u8; 4]))) } else if size == 16 { Self::V6(Ipv6Addr::from(*(bytes as *const [u16; 8]))) } else { panic!("Unknown IP kind"); } } } } gio-0.20.1/src/inet_socket_address.rs000064400000000000000000000007361046102023000156410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::net::SocketAddr; use crate::{prelude::*, InetAddress, InetSocketAddress}; impl From for InetSocketAddress { fn from(addr: SocketAddr) -> Self { Self::new(&InetAddress::from(addr.ip()), addr.port()) } } impl From for SocketAddr { fn from(addr: InetSocketAddress) -> Self { Self::new(addr.address().into(), addr.port()) } } gio-0.20.1/src/initable.rs000064400000000000000000000107161046102023000134130ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::marker::PhantomData; use glib::{object::IsClass, prelude::*, Object, Type}; use crate::{prelude::*, Cancellable, Initable}; impl Initable { // rustdoc-stripper-ignore-next /// Create a new instance of an object with the default property values. /// /// Similar to [`Object::new`] but can fail because the object initialization in /// `Initable::init` failed. #[track_caller] #[allow(clippy::new_ret_no_self)] pub fn new + IsClass + IsA>( cancellable: Option<&impl IsA>, ) -> Result { let object = Self::with_type(T::static_type(), cancellable)?; Ok(unsafe { object.unsafe_cast() }) } // rustdoc-stripper-ignore-next /// Create a new instance of an object with the default property values. /// /// Similar to [`Object::with_type`] but can fail because the object initialization in /// `Initable::init` failed. #[track_caller] pub fn with_type( type_: Type, cancellable: Option<&impl IsA>, ) -> Result { if !type_.is_a(Initable::static_type()) { panic!("Type '{type_}' is not initable"); } unsafe { let object = Object::new_internal(type_, &mut []); object.unsafe_cast_ref::().init(cancellable)?; Ok(object) } } // rustdoc-stripper-ignore-next /// Create a new instance of an object of the given type with the given properties as mutable /// values. /// /// # Panics /// /// This panics if the object is not instantiable, doesn't have all the given properties or /// property values of the wrong type are provided. #[track_caller] pub fn with_mut_values( type_: Type, properties: &mut [(&str, glib::Value)], cancellable: Option<&impl IsA>, ) -> Result { if !type_.is_a(Initable::static_type()) { panic!("Type '{type_}' is not initable"); } unsafe { let object = Object::new_internal(type_, properties); object.unsafe_cast_ref::().init(cancellable)?; Ok(object) } } // rustdoc-stripper-ignore-next /// Create a new object builder for a specific type. pub fn builder<'a, O: IsA + IsClass + IsA>() -> InitableBuilder<'a, O> { InitableBuilder::new(O::static_type()) } // rustdoc-stripper-ignore-next /// Create a new object builder for a specific type. pub fn builder_with_type<'a>(type_: Type) -> InitableBuilder<'a, Object> { if !type_.is_a(Initable::static_type()) { panic!("Type '{type_}' is not initable"); } InitableBuilder::new(type_) } } #[must_use = "builder doesn't do anything unless built"] pub struct InitableBuilder<'a, O> { type_: Type, properties: smallvec::SmallVec<[(&'a str, glib::Value); 16]>, phantom: PhantomData, } impl<'a, O: IsA + IsClass> InitableBuilder<'a, O> { #[inline] fn new(type_: Type) -> Self { InitableBuilder { type_, properties: smallvec::SmallVec::new(), phantom: PhantomData, } } // rustdoc-stripper-ignore-next /// Gets the type of this builder. #[inline] pub fn type_(&self) -> Type { self.type_ } // rustdoc-stripper-ignore-next /// Set property `name` to the given value `value`. #[inline] pub fn property(self, name: &'a str, value: impl Into) -> Self { let InitableBuilder { type_, mut properties, .. } = self; properties.push((name, value.into())); InitableBuilder { type_, properties, phantom: PhantomData, } } // rustdoc-stripper-ignore-next /// Build the object with the provided properties. /// /// # Panics /// /// This panics if the object is not instantiable, doesn't have all the given properties or /// property values of the wrong type are provided. #[track_caller] #[inline] pub fn build(mut self, cancellable: Option<&impl IsA>) -> Result { let object = Initable::with_mut_values(self.type_, &mut self.properties, cancellable)?; Ok(unsafe { object.unsafe_cast::() }) } } gio-0.20.1/src/input_stream.rs000064400000000000000000000523201046102023000143330ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{fmt, future::Future, io, mem, pin::Pin, ptr}; use futures_core::task::{Context, Poll}; use futures_io::{AsyncBufRead, AsyncRead}; use glib::{prelude::*, translate::*, Priority}; use crate::{error::to_std_io_result, ffi, prelude::*, Cancellable, InputStream, Seekable}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait InputStreamExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_input_stream_read")] fn read, C: IsA>( &self, mut buffer: B, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_input_stream_read( self.as_ref().to_glib_none().0, buffer_ptr, count, gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_input_stream_read_all")] fn read_all, C: IsA>( &self, mut buffer: B, cancellable: Option<&C>, ) -> Result<(usize, Option), glib::Error> { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut bytes_read = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = ffi::g_input_stream_read_all( self.as_ref().to_glib_none().0, buffer_ptr, count, bytes_read.as_mut_ptr(), gcancellable.0, &mut error, ); let bytes_read = bytes_read.assume_init(); if error.is_null() { Ok((bytes_read, None)) } else if bytes_read != 0 { Ok((bytes_read, Some(from_glib_full(error)))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_input_stream_read_all_async")] fn read_all_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let mut user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), buffer)); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &mut user_data.1; let slice = (*buffer).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe extern "C" fn read_all_async_trampoline< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::from_raw(user_data as *mut _); let (callback, buffer) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let mut bytes_read = mem::MaybeUninit::uninit(); let _ = ffi::g_input_stream_read_all_finish( _source_object as *mut _, res, bytes_read.as_mut_ptr(), &mut error, ); let bytes_read = bytes_read.assume_init(); let result = if error.is_null() { Ok((buffer, bytes_read, None)) } else if bytes_read != 0 { Ok((buffer, bytes_read, Some(from_glib_full(error)))) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = read_all_async_trampoline::; unsafe { ffi::g_input_stream_read_all_async( self.as_ref().to_glib_none().0, buffer_ptr, count, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[doc(alias = "g_input_stream_read_async")] fn read_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let mut user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), buffer)); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &mut user_data.1; let slice = (*buffer).as_mut(); (slice.len(), slice.as_mut_ptr()) }; unsafe extern "C" fn read_async_trampoline< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::from_raw(user_data as *mut _); let (callback, buffer) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let ret = ffi::g_input_stream_read_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok((buffer, ret as usize)) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = read_async_trampoline::; unsafe { ffi::g_input_stream_read_async( self.as_ref().to_glib_none().0, buffer_ptr, count, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn read_all_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin< Box< dyn std::future::Future< Output = Result<(B, usize, Option), (B, glib::Error)>, > + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_all_async(buffer, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } fn read_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin> + 'static>> { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_async(buffer, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } fn into_read(self) -> InputStreamRead where Self: IsA, { InputStreamRead(self) } fn into_async_buf_read(self, buffer_size: usize) -> InputStreamAsyncBufRead where Self: IsA, { InputStreamAsyncBufRead::new(self, buffer_size) } } impl> InputStreamExtManual for O {} #[derive(Debug)] pub struct InputStreamRead>(T); impl> InputStreamRead { pub fn into_input_stream(self) -> T { self.0 } pub fn input_stream(&self) -> &T { &self.0 } } impl> io::Read for InputStreamRead { fn read(&mut self, buf: &mut [u8]) -> io::Result { let gio_result = self.0.as_ref().read(buf, crate::Cancellable::NONE); to_std_io_result(gio_result) } } impl + IsA> io::Seek for InputStreamRead { fn seek(&mut self, pos: io::SeekFrom) -> io::Result { let (pos, type_) = match pos { io::SeekFrom::Start(pos) => (pos as i64, glib::SeekType::Set), io::SeekFrom::End(pos) => (pos, glib::SeekType::End), io::SeekFrom::Current(pos) => (pos, glib::SeekType::Cur), }; let seekable: &Seekable = self.0.as_ref(); let gio_result = seekable .seek(pos, type_, crate::Cancellable::NONE) .map(|_| seekable.tell() as u64); to_std_io_result(gio_result) } } enum State { Waiting { buffer: Vec, }, Transitioning, Reading { pending: Pin< Box< dyn std::future::Future, usize), (Vec, glib::Error)>> + 'static, >, >, }, HasData { buffer: Vec, valid: (usize, usize), // first index is inclusive, second is exclusive }, Failed(crate::IOErrorEnum), } impl State { fn into_buffer(self) -> Vec { match self { State::Waiting { buffer } => buffer, _ => panic!("Invalid state"), } } #[doc(alias = "get_pending")] fn pending( &mut self, ) -> &mut Pin< Box< dyn std::future::Future, usize), (Vec, glib::Error)>> + 'static, >, > { match self { State::Reading { ref mut pending } => pending, _ => panic!("Invalid state"), } } } pub struct InputStreamAsyncBufRead> { stream: T, state: State, } impl> InputStreamAsyncBufRead { pub fn into_input_stream(self) -> T { self.stream } pub fn input_stream(&self) -> &T { &self.stream } fn new(stream: T, buffer_size: usize) -> Self { let buffer = vec![0; buffer_size]; Self { stream, state: State::Waiting { buffer }, } } fn set_reading( &mut self, ) -> &mut Pin< Box< dyn std::future::Future, usize), (Vec, glib::Error)>> + 'static, >, > { match self.state { State::Waiting { .. } => { let waiting = mem::replace(&mut self.state, State::Transitioning); let buffer = waiting.into_buffer(); let pending = self.input_stream().read_future(buffer, Priority::default()); self.state = State::Reading { pending }; } State::Reading { .. } => {} _ => panic!("Invalid state"), }; self.state.pending() } #[doc(alias = "get_data")] fn data(&self) -> Poll> { if let State::HasData { ref buffer, valid: (i, j), } = self.state { return Poll::Ready(Ok(&buffer[i..j])); } panic!("Invalid state") } fn set_waiting(&mut self, buffer: Vec) { match self.state { State::Reading { .. } | State::Transitioning => self.state = State::Waiting { buffer }, _ => panic!("Invalid state"), } } fn set_has_data(&mut self, buffer: Vec, valid: (usize, usize)) { match self.state { State::Reading { .. } | State::Transitioning { .. } => { self.state = State::HasData { buffer, valid } } _ => panic!("Invalid state"), } } fn poll_fill_buf(&mut self, cx: &mut Context) -> Poll> { match self.state { State::Failed(kind) => Poll::Ready(Err(io::Error::new( io::ErrorKind::from(kind), BufReadError::Failed, ))), State::HasData { .. } => self.data(), State::Transitioning => panic!("Invalid state"), State::Waiting { .. } | State::Reading { .. } => { let pending = self.set_reading(); match Pin::new(pending).poll(cx) { Poll::Ready(Ok((buffer, res))) => { if res == 0 { self.set_waiting(buffer); Poll::Ready(Ok(&[])) } else { self.set_has_data(buffer, (0, res)); self.data() } } Poll::Ready(Err((_, err))) => { let kind = err .kind::() .unwrap_or(crate::IOErrorEnum::Failed); self.state = State::Failed(kind); Poll::Ready(Err(io::Error::new(io::ErrorKind::from(kind), err))) } Poll::Pending => Poll::Pending, } } } } fn consume(&mut self, amt: usize) { if amt == 0 { return; } if let State::HasData { .. } = self.state { let has_data = mem::replace(&mut self.state, State::Transitioning); if let State::HasData { buffer, valid: (i, j), } = has_data { let available = j - i; if amt > available { panic!("Cannot consume {amt} bytes as only {available} are available",) } let remaining = available - amt; if remaining == 0 { return self.set_waiting(buffer); } else { return self.set_has_data(buffer, (i + amt, j)); } } } panic!("Invalid state") } } #[derive(Debug)] enum BufReadError { Failed, } impl std::error::Error for BufReadError {} impl fmt::Display for BufReadError { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match self { Self::Failed => fmt.write_str("Previous read operation failed"), } } } impl> AsyncRead for InputStreamAsyncBufRead { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, out_buf: &mut [u8], ) -> Poll> { let reader = self.get_mut(); let poll = reader.poll_fill_buf(cx); let poll = poll.map_ok(|buffer| { let copied = buffer.len().min(out_buf.len()); out_buf[..copied].copy_from_slice(&buffer[..copied]); copied }); if let Poll::Ready(Ok(consumed)) = poll { reader.consume(consumed); } poll } } impl> AsyncBufRead for InputStreamAsyncBufRead { fn poll_fill_buf( self: Pin<&mut Self>, cx: &mut Context, ) -> Poll> { self.get_mut().poll_fill_buf(cx) } fn consume(self: Pin<&mut Self>, amt: usize) { self.get_mut().consume(amt); } } impl> Unpin for InputStreamAsyncBufRead {} #[cfg(test)] mod tests { use std::io::Read; use glib::Bytes; use crate::{prelude::*, test_util::run_async, MemoryInputStream}; #[test] fn read_all_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let buf = vec![0; 10]; strm.read_all_async( buf, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let (buf, count, err) = ret.unwrap(); assert_eq!(count, 3); assert!(err.is_none()); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_all() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read_all(&mut buf, crate::Cancellable::NONE).unwrap(); assert_eq!(ret.0, 3); assert!(ret.1.is_none()); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, crate::Cancellable::NONE); assert_eq!(ret.unwrap(), 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let buf = vec![0; 10]; strm.read_async( buf, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let (buf, count) = ret.unwrap(); assert_eq!(count, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn read_bytes_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); strm.read_bytes_async( 10, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let bytes = ret.unwrap(); assert_eq!(bytes, vec![1, 2, 3]); } #[test] fn skip_async() { let ret = run_async(|tx, l| { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); strm.skip_async( 10, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let skipped = ret.unwrap(); assert_eq!(skipped, 3); } #[test] fn std_io_read() { let b = Bytes::from_owned(vec![1, 2, 3]); let mut read = MemoryInputStream::from_bytes(&b).into_read(); let mut buf = [0u8; 10]; let ret = read.read(&mut buf); assert_eq!(ret.unwrap(), 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); } #[test] fn into_input_stream() { let b = Bytes::from_owned(vec![1, 2, 3]); let stream = MemoryInputStream::from_bytes(&b); let stream_clone = stream.clone(); let stream = stream.into_read().into_input_stream(); assert_eq!(stream, stream_clone); } } gio-0.20.1/src/io_extension.rs000064400000000000000000000033121046102023000143210ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{fmt, marker::PhantomData, ptr}; use crate::ffi; use glib::{translate::*, Type}; // rustdoc-stripper-ignore-next /// The implementation of an `IOExtensionPoint`. #[doc(alias = "GIOExtension")] #[derive(Copy, Clone, Eq, PartialEq)] pub struct IOExtension(ptr::NonNull); impl fmt::Debug for IOExtension { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("IOExtension") .field("name", &self.name()) .field("priority", &self.priority()) .field("type", &self.type_()) .finish() } } impl FromGlibPtrNone<*mut ffi::GIOExtension> for IOExtension { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GIOExtension) -> Self { debug_assert!(!ptr.is_null()); IOExtension(ptr::NonNull::new_unchecked(ptr)) } } impl<'a> ToGlibPtr<'a, *mut ffi::GIOExtension> for &'a IOExtension { type Storage = PhantomData<&'a IOExtension>; #[inline] fn to_glib_none(&self) -> Stash<'a, *mut ffi::GIOExtension, &'a IOExtension> { Stash(self.0.as_ptr() as *mut ffi::GIOExtension, PhantomData) } } impl IOExtension { #[doc(alias = "g_io_extension_get_name")] pub fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_io_extension_get_name(self.0.as_ptr())) } } #[doc(alias = "g_io_extension_get_priority")] pub fn priority(&self) -> i32 { unsafe { ffi::g_io_extension_get_priority(self.0.as_ptr()) } } #[doc(alias = "g_io_extension_get_type")] pub fn type_(&self) -> Type { unsafe { from_glib(ffi::g_io_extension_get_type(self.0.as_ptr())) } } } gio-0.20.1/src/io_extension_point.rs000064400000000000000000000137511046102023000155420ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{marker::PhantomData, ptr}; use glib::{translate::*, GString, Type}; use crate::{ffi, IOExtension}; // rustdoc-stripper-ignore-next /// Builder for extension points. #[derive(Debug)] #[must_use = "The builder must be built to be used"] pub struct IOExtensionPointBuilder { name: GString, required_type: Option, } impl IOExtensionPointBuilder { fn new(name: GString) -> Self { Self { name, required_type: None, } } #[doc(alias = "g_io_extension_point_set_required_type")] pub fn required_type(self, required_type: Type) -> Self { Self { required_type: Some(required_type), ..self } } #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] pub fn build(self) -> IOExtensionPoint { unsafe { let ep = IOExtensionPoint::from_glib_none(ffi::g_io_extension_point_register( self.name.to_glib_none().0, )); if let Some(t) = self.required_type { ffi::g_io_extension_point_set_required_type(ep.0.as_ptr(), t.into_glib()); } ep } } } // rustdoc-stripper-ignore-next /// An extension point provides a mechanism to extend the functionality of a library or application. /// Each extension point is identified by a name, and it may optionally require that any implementation /// must be of a certain type. #[doc(alias = "GIOExtensionPoint")] #[derive(Debug, Copy, Clone, Eq, PartialEq)] pub struct IOExtensionPoint(ptr::NonNull); impl FromGlibPtrNone<*mut ffi::GIOExtensionPoint> for IOExtensionPoint { #[inline] unsafe fn from_glib_none(ptr: *mut ffi::GIOExtensionPoint) -> Self { debug_assert!(!ptr.is_null()); IOExtensionPoint(ptr::NonNull::new_unchecked(ptr)) } } impl<'a> ToGlibPtr<'a, *mut ffi::GIOExtensionPoint> for &'a IOExtensionPoint { type Storage = PhantomData<&'a IOExtensionPoint>; #[inline] fn to_glib_none(&self) -> Stash<'a, *mut ffi::GIOExtensionPoint, &'a IOExtensionPoint> { Stash(self.0.as_ptr() as *mut ffi::GIOExtensionPoint, PhantomData) } } impl IOExtensionPoint { // rustdoc-stripper-ignore-next /// Create a new builder for an extension point. #[doc(alias = "g_io_extension_point_register")] pub fn builder(name: impl Into) -> IOExtensionPointBuilder { IOExtensionPointBuilder::new(name.into()) } #[doc(alias = "g_io_extension_point_lookup")] pub fn lookup(name: impl IntoGStr) -> Option { name.run_with_gstr(|name| unsafe { let ep = ffi::g_io_extension_point_lookup(name.to_glib_none().0); from_glib_none(ep) }) } #[doc(alias = "g_io_extension_point_get_extensions")] pub fn extensions(&self) -> Vec { let mut res = Vec::new(); unsafe { let mut l = ffi::g_io_extension_point_get_extensions(self.0.as_ptr()); while !l.is_null() { let e: *mut ffi::GIOExtension = Ptr::from((*l).data); res.push(from_glib_none(e)); l = (*l).next; } } res } #[doc(alias = "g_io_extension_point_get_extension_by_name")] pub fn extension_by_name(&self, name: impl IntoGStr) -> Option { name.run_with_gstr(|name| unsafe { let e = ffi::g_io_extension_point_get_extension_by_name( self.0.as_ptr(), name.to_glib_none().0, ); from_glib_none(e) }) } #[doc(alias = "g_io_extension_point_get_required_type")] pub fn required_type(&self) -> Type { unsafe { from_glib(ffi::g_io_extension_point_get_required_type(self.0.as_ptr())) } } #[doc(alias = "g_io_extension_point_implement")] pub fn implement( extension_point_name: impl IntoGStr, type_: Type, extension_name: impl IntoGStr, priority: i32, ) -> Option { extension_point_name.run_with_gstr(|extension_point_name| { extension_name.run_with_gstr(|extension_name| unsafe { let e = ffi::g_io_extension_point_implement( extension_point_name.to_glib_none().0, type_.into_glib(), extension_name.to_glib_none().0, priority, ); from_glib_none(e) }) }) } } #[cfg(test)] mod tests { use glib::prelude::*; use super::*; #[test] fn extension_point() { let ep = IOExtensionPoint::lookup("test-extension-point"); assert!(ep.is_none()); let ep = IOExtensionPoint::builder("test-extension-point").build(); let ep2 = IOExtensionPoint::lookup("test-extension-point"); assert_eq!(ep2, Some(ep)); let req = ep.required_type(); assert_eq!(req, Type::INVALID); let ep = IOExtensionPoint::builder("test-extension-point") .required_type(Type::OBJECT) .build(); let req = ep.required_type(); assert_eq!(req, Type::OBJECT); let v = ep.extensions(); assert!(v.is_empty()); let e = IOExtensionPoint::implement( "test-extension-point", ::static_type(), "extension1", 10, ); assert!(e.is_some()); let e = IOExtensionPoint::implement("test-extension-point", Type::OBJECT, "extension2", 20); assert!(e.is_some()); let v = ep.extensions(); assert_eq!(v.len(), 2); assert_eq!(v[0].name(), "extension2"); assert_eq!(v[0].type_(), Type::OBJECT); assert_eq!(v[0].priority(), 20); assert_eq!(v[1].name(), "extension1"); assert_eq!(v[1].type_(), ::static_type()); assert_eq!(v[1].priority(), 10); } } gio-0.20.1/src/io_stream.rs000064400000000000000000000053471046102023000136120ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{io, pin::Pin}; use futures_core::task::{Context, Poll}; use futures_io::{AsyncRead, AsyncWrite}; use glib::prelude::*; use crate::{ prelude::*, IOStream, InputStreamAsyncRead, OutputStreamAsyncWrite, PollableInputStream, PollableOutputStream, }; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait IOStreamExtManual: sealed::Sealed + Sized + IsA { fn into_async_read_write(self) -> Result, Self> { let write = self .output_stream() .dynamic_cast::() .ok() .and_then(|s| s.into_async_write().ok()); let read = self .input_stream() .dynamic_cast::() .ok() .and_then(|s| s.into_async_read().ok()); let (read, write) = match (read, write) { (Some(read), Some(write)) => (read, write), _ => return Err(self), }; Ok(IOStreamAsyncReadWrite { io_stream: self, read, write, }) } } impl> IOStreamExtManual for O {} #[derive(Debug)] pub struct IOStreamAsyncReadWrite { io_stream: T, read: InputStreamAsyncRead, write: OutputStreamAsyncWrite, } impl> IOStreamAsyncReadWrite { pub fn input_stream(&self) -> &PollableInputStream { self.read.input_stream() } pub fn output_stream(&self) -> &PollableOutputStream { self.write.output_stream() } pub fn into_io_stream(self) -> T { self.io_stream } pub fn io_stream(&self) -> &T { &self.io_stream } } impl + std::marker::Unpin> AsyncRead for IOStreamAsyncReadWrite { fn poll_read( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll> { Pin::new(&mut Pin::get_mut(self).read).poll_read(cx, buf) } } impl + std::marker::Unpin> AsyncWrite for IOStreamAsyncReadWrite { fn poll_write( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], ) -> Poll> { Pin::new(&mut Pin::get_mut(self).write).poll_write(cx, buf) } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut Pin::get_mut(self).write).poll_flush(cx) } fn poll_close(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> { Pin::new(&mut Pin::get_mut(self).write).poll_close(cx) } } gio-0.20.1/src/lib.rs000064400000000000000000000076071046102023000123770ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #![cfg_attr(docsrs, feature(doc_cfg))] #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] #![allow(clippy::missing_safety_doc)] #![doc = include_str!("../README.md")] pub use gio_sys as ffi; pub use glib; mod action_entry; mod action_map; #[cfg(feature = "v2_60")] mod app_info; mod application; pub use action_entry::{ActionEntry, ActionEntryBuilder}; pub use application::{ApplicationBusyGuard, ApplicationHoldGuard}; mod async_initable; mod cancellable; mod cancellable_future; pub use crate::cancellable_future::{CancellableFuture, Cancelled}; mod converter; mod credentials; mod data_input_stream; mod datagram_based; mod dbus; pub use self::dbus::*; mod dbus_connection; pub use self::dbus_connection::{ ActionGroupExportId, FilterId, MenuModelExportId, RegistrationId, SignalSubscriptionId, WatcherId, }; mod dbus_message; mod dbus_method_invocation; mod dbus_node_info; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] mod debug_controller_dbus; #[cfg(all(not(windows), not(target_os = "macos")))] mod desktop_app_info; mod error; mod file; mod file_attribute_info; pub use crate::file_attribute_info::FileAttributeInfo; mod file_attribute_info_list; mod file_attribute_matcher; pub use crate::file_attribute_matcher::FileAttributematcherIter; #[cfg(unix)] mod file_descriptor_based; #[cfg(unix)] pub use file_descriptor_based::FileDescriptorBased; mod file_enumerator; pub use crate::file_enumerator::FileEnumeratorStream; mod file_info; mod flags; mod inet_address; pub use crate::inet_address::InetAddressBytes; mod inet_socket_address; mod io_stream; pub use crate::io_stream::IOStreamAsyncReadWrite; mod initable; mod input_stream; pub use crate::input_stream::{InputStreamAsyncBufRead, InputStreamRead}; mod list_model; mod list_store; #[cfg(test)] mod memory_input_stream; #[cfg(test)] mod memory_output_stream; mod output_stream; pub use crate::output_stream::OutputStreamWrite; mod pollable_input_stream; pub use crate::pollable_input_stream::InputStreamAsyncRead; mod pollable_output_stream; pub use crate::pollable_output_stream::OutputStreamAsyncWrite; mod resource; pub use crate::resource::resources_register_include_impl; mod settings; pub use crate::settings::BindingBuilder; mod simple_proxy_resolver; mod socket; pub use socket::{InputMessage, InputVector, OutputMessage, OutputVector, SocketControlMessages}; mod socket_control_message; mod socket_listener; mod socket_msg_flags; pub use socket_msg_flags::SocketMsgFlags; mod subprocess; mod subprocess_launcher; mod threaded_socket_service; #[cfg(unix)] mod unix_fd_list; #[cfg(unix)] mod unix_fd_message; #[cfg(unix)] mod unix_input_stream; #[cfg(unix)] mod unix_mount_entry; #[cfg(unix)] mod unix_mount_point; #[cfg(unix)] mod unix_output_stream; #[cfg(unix)] mod unix_socket_address; #[cfg(test)] mod test_util; pub mod builders { pub use super::async_initable::AsyncInitableBuilder; pub use super::auto::builders::*; pub use super::initable::InitableBuilder; } pub mod functions { pub use super::auto::functions::*; } pub use crate::auto::*; pub use crate::functions::*; pub mod prelude; #[allow(clippy::missing_safety_doc)] #[allow(clippy::new_ret_no_self)] #[allow(unused_imports)] mod auto; mod gio_future; pub use crate::gio_future::*; mod io_extension; pub use crate::io_extension::*; mod io_extension_point; pub use crate::io_extension_point::*; mod task; pub use crate::task::*; #[macro_use] pub mod subclass; mod read_input_stream; pub use crate::read_input_stream::ReadInputStream; mod write_output_stream; pub use crate::write_output_stream::WriteOutputStream; mod dbus_proxy; mod tls_connection; #[cfg(windows)] mod win32_input_stream; #[cfg(windows)] pub use self::win32_input_stream::Win32InputStream; #[cfg(windows)] mod win32_output_stream; #[cfg(windows)] pub use self::win32_output_stream::Win32OutputStream; gio-0.20.1/src/list_model.rs000064400000000000000000000222761046102023000137630ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::Cell, fmt, iter::FusedIterator, marker::PhantomData, rc::Rc}; use glib::SignalHandlerId; use crate::{prelude::*, ListModel}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait ListModelExtManual: sealed::Sealed + IsA + Sized { // rustdoc-stripper-ignore-next /// Get an immutable snapshot of the container inside the `ListModel`. /// Any modification done to the returned container `Vec` will not be /// reflected on the `ListModel`. fn snapshot(&self) -> Vec { let mut res = Vec::with_capacity(self.n_items() as usize); for i in 0..self.n_items() { res.push(self.item(i).unwrap()) } res } // rustdoc-stripper-ignore-next /// If `T::static_type().is_a(self.item_type())` then it returns an iterator over the `ListModel` elements, /// else the types are not compatible and returns an `Err(...)`. /// /// # Panics /// /// Panics if `T::static_type().is_a(self.item_type())` is not true. fn iter>(&self) -> ListModelIter { assert!(self.item_type().is_a(LT::static_type())); let len = self.n_items(); let changed = Rc::new(Cell::new(false)); let changed_clone = changed.clone(); let signal_id = Some(self.connect_items_changed(move |_, pos, _, _| { if pos < len { changed_clone.set(true); } })); ListModelIter { ty: Default::default(), i: 0, reverse_pos: len, model: self.upcast_ref(), changed, signal_id, } } } impl> ListModelExtManual for T {} #[derive(Debug, PartialEq, Eq)] pub struct ListModelMutatedDuringIter; impl std::error::Error for ListModelMutatedDuringIter {} impl fmt::Display for ListModelMutatedDuringIter { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fmt.write_str("the list model was mutated during iteration") } } // rustdoc-stripper-ignore-next /// Iterator of `ListModel`'s items. /// This iterator will always give `n = initial_model.n_items()` items, even if the `ListModel` /// is mutated during iteration. /// If the internal `ListModel` gets mutated, the iterator /// will return `Some(Err(...))` for the remaining items. /// Mutations to the `ListModel` in position >= `initial_model.n_items()` are allowed. pub struct ListModelIter<'a, T: IsA> { ty: PhantomData, i: u32, // it's > i when valid reverse_pos: u32, model: &'a ListModel, changed: Rc>, signal_id: Option, } impl<'a, T: IsA> Iterator for ListModelIter<'a, T> { type Item = Result; fn next(&mut self) -> Option { if self.i >= self.reverse_pos { return None; } let res = match self.changed.get() { true => Err(ListModelMutatedDuringIter), false => Ok(self.model.item(self.i).unwrap().downcast::().unwrap()), }; self.i += 1; Some(res) } fn size_hint(&self) -> (usize, Option) { let n: usize = (self.reverse_pos - self.i) as _; (n, Some(n)) } fn count(self) -> usize { (self.reverse_pos - self.i) as usize } fn nth(&mut self, n: usize) -> Option { let (end, overflow) = (self.i as usize).overflowing_add(n); if end >= self.reverse_pos as usize || overflow { self.i = self.reverse_pos; None } else { let end = end as u32; self.i = end + 1; let res = match self.changed.get() { true => Err(ListModelMutatedDuringIter), false => Ok(self.model.item(end).unwrap().downcast::().unwrap()), }; Some(res) } } fn last(self) -> Option { if self.i == self.reverse_pos { None } else { let res = match self.changed.get() { true => Err(ListModelMutatedDuringIter), false => Ok(self .model .item(self.reverse_pos - 1) .unwrap() .downcast::() .unwrap()), }; Some(res) } } } impl<'a, T: IsA> FusedIterator for ListModelIter<'a, T> {} impl<'a, T: IsA> ExactSizeIterator for ListModelIter<'a, T> {} impl<'a, T: IsA> DoubleEndedIterator for ListModelIter<'a, T> { fn next_back(&mut self) -> Option { if self.reverse_pos == self.i { return None; } self.reverse_pos -= 1; let res = match self.changed.get() { true => Err(ListModelMutatedDuringIter), false => Ok(self .model .item(self.reverse_pos) .unwrap() .downcast::() .unwrap()), }; Some(res) } fn nth_back(&mut self, n: usize) -> Option { let (end, overflow) = (self.reverse_pos as usize).overflowing_sub(n); if end <= self.i as usize || overflow { self.i = self.reverse_pos; None } else { let end = end as u32; self.reverse_pos = end - 1; let res = match self.changed.get() { true => Err(ListModelMutatedDuringIter), false => Ok(self.model.item(end - 1).unwrap().downcast::().unwrap()), }; Some(res) } } } impl<'a, T: IsA> Drop for ListModelIter<'a, T> { #[inline] fn drop(&mut self) { self.model.disconnect(self.signal_id.take().unwrap()); } } impl<'a> std::iter::IntoIterator for &'a ListModel { type Item = Result; type IntoIter = ListModelIter<'a, glib::Object>; fn into_iter(self) -> Self::IntoIter { self.iter() } } #[test] fn list_model_iter_ok() { let list = crate::ListStore::new::(); let m1 = crate::Menu::new(); let m2 = crate::Menu::new(); let m3 = crate::Menu::new(); let m4 = crate::Menu::new(); list.append(&m1); list.append(&m2); list.append(&m3); let mut iter = list.iter::(); assert_eq!(iter.len(), 3); assert_eq!(iter.next(), Some(Ok(m1))); // Appending items at the end of the `ListModel` can't affect the items // we are iterating over. list.append(&m4); assert_eq!(iter.next_back(), Some(Ok(m3))); assert_eq!(iter.len(), 1); assert_eq!(iter.next_back(), Some(Ok(m2))); assert_eq!(iter.next(), None); assert_eq!(iter.next_back(), None); } #[test] fn list_model_iter_err() { let list = crate::ListStore::new::(); let m1 = crate::Menu::new(); let m2 = crate::Menu::new(); let m3 = crate::Menu::new(); let m4 = crate::Menu::new(); list.append(&m1); list.append(&m2); list.append(&m3); list.append(&m4); let mut iter = list.iter::(); assert_eq!(iter.next_back(), Some(Ok(m4))); // These two don't affect the iter list.append(&m2); list.append(&m2); assert_eq!(iter.next(), Some(Ok(m1))); // Does affect the iter list.remove(2); // Doesn't affect the iter, but the iter should stay tainted. list.remove(4); assert_eq!(iter.next(), Some(Err(ListModelMutatedDuringIter))); assert_eq!(iter.next(), Some(Err(ListModelMutatedDuringIter))); // Returned n items assert_eq!(iter.next(), None); } #[test] fn list_model_iter_nth() { let list = crate::ListStore::new::(); let m1 = crate::Menu::new(); let m2 = crate::Menu::new(); let m3 = crate::Menu::new(); let m4 = crate::Menu::new(); let m5 = crate::Menu::new(); let m6 = crate::Menu::new(); list.append(&m1); list.append(&m2); list.append(&m3); list.append(&m4); list.append(&m5); list.append(&m6); let mut iter = list.iter::(); assert_eq!(iter.len(), 6); assert_eq!(iter.nth(1), Some(Ok(m2))); assert_eq!(iter.len(), 4); assert_eq!(iter.next(), Some(Ok(m3))); assert_eq!(iter.nth_back(2), Some(Ok(m4))); assert_eq!(iter.len(), 0); assert_eq!(iter.next(), None); assert_eq!(iter.next_back(), None); } #[test] fn list_model_iter_last() { let list = crate::ListStore::new::(); let m1 = crate::Menu::new(); let m2 = crate::Menu::new(); let m3 = crate::Menu::new(); list.append(&m1); list.append(&m2); list.append(&m3); let iter = list.iter::(); assert_eq!(iter.len(), 3); assert_eq!(iter.last(), Some(Ok(m3))); } #[test] fn list_model_iter_count() { let list = crate::ListStore::new::(); let m1 = crate::Menu::new(); let m2 = crate::Menu::new(); let m3 = crate::Menu::new(); list.append(&m1); list.append(&m2); list.append(&m3); let iter = list.iter::(); assert_eq!(iter.len(), 3); assert_eq!(iter.count(), 3); } gio-0.20.1/src/list_store.rs000064400000000000000000000257521046102023000140210ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::Cell, cmp::Ordering, rc::Rc}; use glib::{prelude::*, translate::*, Object}; use crate::{ffi, prelude::*, ListModel, ListStore}; impl ListStore { #[doc(alias = "g_list_store_new")] pub fn new>() -> Self { Self::with_type(T::static_type()) } #[doc(alias = "g_list_store_new")] pub fn with_type(type_: glib::types::Type) -> Self { unsafe { from_glib_full(ffi::g_list_store_new(type_.into_glib())) } } #[doc(alias = "g_list_store_insert_sorted")] pub fn insert_sorted, F: FnMut(&Object, &Object) -> Ordering>( &self, item: &P, compare_func: F, ) -> u32 { unsafe { let mut func = compare_func; let func_obj: &mut (dyn FnMut(&Object, &Object) -> Ordering) = &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(&Object, &Object) -> Ordering) as glib::ffi::gpointer; ffi::g_list_store_insert_sorted( self.to_glib_none().0, item.as_ref().to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } #[doc(alias = "g_list_store_sort")] pub fn sort Ordering>(&self, compare_func: F) { unsafe { let mut func = compare_func; let func_obj: &mut (dyn FnMut(&Object, &Object) -> Ordering) = &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(&Object, &Object) -> Ordering) as glib::ffi::gpointer; ffi::g_list_store_sort( self.to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } #[doc(alias = "g_list_store_splice")] pub fn splice(&self, position: u32, n_removals: u32, additions: &[impl IsA]) { let n_additions = additions.len() as u32; unsafe { let additions = additions.as_ptr() as *mut *mut glib::gobject_ffi::GObject; ffi::g_list_store_splice( self.to_glib_none().0, position, n_removals, additions, n_additions, ); } } // rustdoc-stripper-ignore-next /// Appends all elements in a slice to the `ListStore`. pub fn extend_from_slice(&self, additions: &[impl IsA]) { self.splice(self.n_items(), 0, additions) } // rustdoc-stripper-ignore-next /// Retains only the elements specified by the predicate. /// This method operates in place, visiting each element exactly once in the original order, /// and preserves the order of the retained elements. /// Because the elements are visited exactly once in the original order, /// external state may be used to decide which elements to keep. /// /// # Panics /// Panics if the predicate closure mutates the list by removing or adding items. pub fn retain(&self, mut f: impl FnMut(&glib::Object) -> bool) { let mut consec_removed = 0; let mut i = 0; const ADDITIONS: &[glib::Object] = &[]; // To satisfy the type checker let changed = Rc::new(Cell::new(false)); let changed_clone = changed.clone(); let signal_id = self.connect_items_changed(move |_list, _, _, _| changed_clone.set(true)); let _signal_guard = { struct Guard<'a> { list_store: &'a ListStore, signal_id: Option, } impl Drop for Guard<'_> { fn drop(&mut self) { self.list_store.disconnect(self.signal_id.take().unwrap()); } } Guard { list_store: self, signal_id: Some(signal_id), } }; while i < self.n_items() { let keep = f(self.item(i).unwrap().as_ref()); if changed.get() { panic!("The closure passed to ListStore::retain() must not mutate the list store"); } if !keep { consec_removed += 1; } else if consec_removed > 0 { self.splice(i - consec_removed, consec_removed, ADDITIONS); changed.set(false); i -= consec_removed; consec_removed = 0; } i += 1; } if consec_removed > 0 { self.splice(i - consec_removed, consec_removed, ADDITIONS); } } #[cfg(feature = "v2_74")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_74")))] #[doc(alias = "g_list_store_find_with_equal_func_full")] #[doc(alias = "g_list_store_find_with_equal_func")] pub fn find_with_equal_func bool>( &self, equal_func: F, ) -> Option { unsafe extern "C" fn equal_func_trampoline( a: glib::ffi::gconstpointer, _b: glib::ffi::gconstpointer, func: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let func = func as *mut &mut (dyn FnMut(&Object) -> bool); let a = from_glib_borrow(a as *mut glib::gobject_ffi::GObject); (*func)(&a).into_glib() } unsafe { // GIO requires a non-NULL item to be passed in so we're constructing a fake item here. // See https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3284 let item = glib::gobject_ffi::GObject { g_type_instance: glib::gobject_ffi::GTypeInstance { g_class: glib::gobject_ffi::g_type_class_peek(self.item_type().into_glib()) as *mut _, }, ref_count: 1, qdata: std::ptr::null_mut(), }; let mut func = equal_func; let func_obj: &mut (dyn FnMut(&Object) -> bool) = &mut func; let func_ptr = &func_obj as *const &mut (dyn FnMut(&Object) -> bool) as glib::ffi::gpointer; let mut position = std::mem::MaybeUninit::uninit(); let found = bool::from_glib(ffi::g_list_store_find_with_equal_func_full( self.to_glib_none().0, mut_override(&item as *const _), Some(equal_func_trampoline), func_ptr, position.as_mut_ptr(), )); found.then(|| position.assume_init()) } } } impl> std::iter::FromIterator

for ListStore { fn from_iter>(iter: I) -> Self { let store = Self::new::

(); for item in iter.into_iter() { store.append(&item) } store } } impl<'a> std::iter::IntoIterator for &'a ListStore { type Item = <&'a ListModel as IntoIterator>::Item; type IntoIter = <&'a ListModel as IntoIterator>::IntoIter; fn into_iter(self) -> Self::IntoIter { self.upcast_ref::().into_iter() } } unsafe extern "C" fn compare_func_trampoline( a: glib::ffi::gconstpointer, b: glib::ffi::gconstpointer, func: glib::ffi::gpointer, ) -> i32 { let func = func as *mut &mut (dyn FnMut(&Object, &Object) -> Ordering); let a = from_glib_borrow(a as *mut glib::gobject_ffi::GObject); let b = from_glib_borrow(b as *mut glib::gobject_ffi::GObject); (*func)(&a, &b).into_glib() } impl> std::iter::Extend for ListStore { fn extend>(&mut self, iter: T) { let additions = iter .into_iter() .map(|o| o.as_ref().clone()) .collect::>(); self.splice(self.n_items(), 0, &additions) } } #[cfg(test)] mod tests { use crate::{prelude::*, ListStore}; #[test] fn splice() { let item0 = ListStore::new::(); let item1 = ListStore::new::(); let list = ListStore::new::(); list.splice(0, 0, &[item0.clone(), item1.clone()]); assert_eq!(list.item(0), Some(item0.upcast())); assert_eq!(list.item(1), Some(item1.upcast())); } #[test] fn extend() { let item0 = ListStore::new::(); let item1 = ListStore::new::(); let mut list = ListStore::new::(); list.extend([&item0, &item1]); assert_eq!(list.item(0).as_ref(), Some(item0.upcast_ref())); assert_eq!(list.item(1).as_ref(), Some(item1.upcast_ref())); list.extend([item0.clone(), item1.clone()]); assert_eq!(list.item(2).as_ref(), Some(item0.upcast_ref())); assert_eq!(list.item(3).as_ref(), Some(item1.upcast_ref())); let list_from_slice = ListStore::new::(); list_from_slice.extend_from_slice(&[item0, item1.clone()]); assert_eq!(list_from_slice.item(1).as_ref(), Some(item1.upcast_ref())); } #[test] fn from_iterator() { let item0 = ListStore::new::(); let item1 = ListStore::new::(); let v = vec![item0.clone(), item1.clone()]; let list = ListStore::from_iter(v); assert_eq!(list.item(0).as_ref(), Some(item0.upcast_ref())); assert_eq!(list.item(1).as_ref(), Some(item1.upcast_ref())); assert_eq!(list.item(2).as_ref(), None); } #[cfg(feature = "v2_74")] #[test] fn find() { let item0 = ListStore::new::(); let item1 = ListStore::new::(); let list = ListStore::new::(); list.append(&item0); list.append(&item1); let res = list.find_with_equal_func(|item| item == &item1); assert_eq!(res, Some(1)); } #[test] fn retain() { let list = { let list = ListStore::new::(); for _ in 0..10 { list.append(&ListStore::new::()); } list }; use std::cell::Cell; use std::rc::Rc; let signal_count = Rc::new(Cell::new(0)); let signal_count_clone = signal_count.clone(); list.connect_items_changed(move |_, _, _, _| { signal_count_clone.set(signal_count_clone.get() + 1); }); let to_keep = [ // list.item(0).unwrap(), list.item(1).unwrap(), // list.item(2).unwrap(), list.item(3).unwrap(), // list.item(4).unwrap(), // list.item(5).unwrap(), // list.item(6).unwrap(), list.item(7).unwrap(), // list.item(8).unwrap(), // list.item(9).unwrap(), ]; list.retain(|item| to_keep.contains(item)); // Check that we removed the correct items assert_eq!(list.n_items(), 3); assert_eq!(list.item(0).as_ref(), Some(&to_keep[0])); assert_eq!(list.item(1).as_ref(), Some(&to_keep[1])); assert_eq!(list.item(2).as_ref(), Some(&to_keep[2])); assert_eq!(signal_count.get(), 4); } } gio-0.20.1/src/memory_input_stream.rs000064400000000000000000000121141046102023000157200ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(test)] mod tests { use std::error::Error; use futures_util::io::{AsyncBufReadExt, AsyncReadExt}; use glib::Bytes; use crate::{prelude::*, MemoryInputStream}; #[test] fn new() { let strm = MemoryInputStream::new(); let ret = strm.skip(1, crate::Cancellable::NONE); assert!(ret.is_ok()); assert_eq!(ret.unwrap(), 0); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, crate::Cancellable::NONE).unwrap(); assert_eq!(ret, 0); } #[test] fn from_bytes() { let b = Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, crate::Cancellable::NONE).unwrap(); assert_eq!(ret, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); let ret = strm.skip(10, crate::Cancellable::NONE).unwrap(); assert_eq!(ret, 0); } #[test] fn add_bytes() { let strm = MemoryInputStream::new(); let b = Bytes::from_owned(vec![1, 2, 3]); strm.add_bytes(&b); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, crate::Cancellable::NONE).unwrap(); assert_eq!(ret, 3); assert_eq!(buf[0], 1); assert_eq!(buf[1], 2); assert_eq!(buf[2], 3); let ret = strm.skip(10, crate::Cancellable::NONE).unwrap(); assert_eq!(ret, 0); } #[test] fn read_future() { use futures_util::future::TryFutureExt; let c = glib::MainContext::new(); let buf = vec![0; 10]; let b = glib::Bytes::from_owned(vec![1, 2, 3]); let strm = MemoryInputStream::from_bytes(&b); let res = c .block_on( strm.read_future(buf, glib::Priority::default()) .map_err(|(_buf, err)| err) .map_ok(move |(mut buf, len)| { buf.truncate(len); buf }), ) .unwrap(); assert_eq!(res, vec![1, 2, 3]); } #[test] fn async_read() { async fn run() -> Result<(), Box> { let b = Bytes::from_owned(vec![1, 2, 3]); // Adapter is big enough to read everything in one read let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(8); let mut buf = [0u8; 4]; assert_eq!(read.read(&mut buf).await?, 3); assert_eq!(buf, [1, 2, 3, 0]); assert_eq!(read.read(&mut buf).await?, 0); let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(8); let mut buf = [0u8; 1]; assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [1]); assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [2]); assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [3]); assert_eq!(read.read(&mut buf).await?, 0); // Adapter is NOT big enough to read everything in one read let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(2); let mut buf = [0u8; 4]; assert_eq!(read.read(&mut buf).await?, 2); assert_eq!(buf, [1, 2, 0, 0]); assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf[0], 3); assert_eq!(read.read(&mut buf).await?, 0); let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(2); let mut buf = [0u8; 1]; assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [1]); assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [2]); assert_eq!(read.read(&mut buf).await?, 1); assert_eq!(buf, [3]); assert_eq!(read.read(&mut buf).await?, 0); Ok(()) } let main_context = glib::MainContext::new(); main_context.block_on(run()).unwrap(); } #[test] fn async_buf_read() { async fn run() -> Result<(), Box> { let b = Bytes::from_owned(vec![1, 2, 3]); // Adapter is big enough to read everything in one read let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(16); let mut buf = String::new(); assert_eq!(read.read_line(&mut buf).await?, 3); assert_eq!(buf.as_bytes(), [1, 2, 3]); assert_eq!(read.read_line(&mut buf).await?, 0); // Adapter is NOT big enough to read everything in one read let mut read = MemoryInputStream::from_bytes(&b).into_async_buf_read(2); let mut buf = String::new(); assert_eq!(read.read_line(&mut buf).await?, 3); assert_eq!(buf.as_bytes(), [1, 2, 3]); assert_eq!(read.read_line(&mut buf).await?, 0); Ok(()) } let main_context = glib::MainContext::new(); main_context.block_on(run()).unwrap(); } } gio-0.20.1/src/memory_output_stream.rs000064400000000000000000000015501046102023000161230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(test)] mod tests { use crate::{prelude::*, MemoryOutputStream}; #[test] fn steal_empty() { let strm = MemoryOutputStream::new_resizable(); assert_eq!(strm.data_size(), 0); assert!(strm.close(crate::Cancellable::NONE).is_ok()); assert_eq!(strm.steal_as_bytes(), [].as_ref()); } #[test] fn steal() { let strm = MemoryOutputStream::new_resizable(); assert!(strm.write(&[1, 2, 3], crate::Cancellable::NONE).is_ok()); assert_eq!(strm.data_size(), 3); assert!(strm.write(&[4, 5], crate::Cancellable::NONE).is_ok()); assert_eq!(strm.data_size(), 5); assert!(strm.close(crate::Cancellable::NONE).is_ok()); assert_eq!(strm.steal_as_bytes(), [1, 2, 3, 4, 5].as_ref()); } } gio-0.20.1/src/output_stream.rs000064400000000000000000000636541046102023000145500ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{io, mem, pin::Pin, ptr}; use glib::{prelude::*, translate::*, Priority}; #[cfg(feature = "v2_60")] use crate::OutputVector; use crate::{error::to_std_io_result, ffi, prelude::*, Cancellable, OutputStream, Seekable}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait OutputStreamExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_output_stream_write_async")] fn write_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), buffer)); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &user_data.1; let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn write_async_trampoline< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::from_raw(user_data as *mut _); let (callback, buffer) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let ret = ffi::g_output_stream_write_finish(_source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok((buffer, ret as usize)) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = write_async_trampoline::; unsafe { ffi::g_output_stream_write_async( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[doc(alias = "g_output_stream_write_all")] fn write_all>( &self, buffer: &[u8], cancellable: Option<&C>, ) -> Result<(usize, Option), glib::Error> { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let count = buffer.len(); unsafe { let mut bytes_written = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = ffi::g_output_stream_write_all( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, bytes_written.as_mut_ptr(), gcancellable.0, &mut error, ); let bytes_written = bytes_written.assume_init(); if error.is_null() { Ok((bytes_written, None)) } else if bytes_written != 0 { Ok((bytes_written, Some(from_glib_full(error)))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_output_stream_write_all_async")] fn write_all_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), buffer)); // Need to do this after boxing as the contents pointer might change by moving into the box let (count, buffer_ptr) = { let buffer = &user_data.1; let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe extern "C" fn write_all_async_trampoline< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<(glib::thread_guard::ThreadGuard, B)> = Box::from_raw(user_data as *mut _); let (callback, buffer) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let mut bytes_written = mem::MaybeUninit::uninit(); let _ = ffi::g_output_stream_write_all_finish( _source_object as *mut _, res, bytes_written.as_mut_ptr(), &mut error, ); let bytes_written = bytes_written.assume_init(); let result = if error.is_null() { Ok((buffer, bytes_written, None)) } else if bytes_written != 0 { Ok((buffer, bytes_written, from_glib_full(error))) } else { Err((buffer, from_glib_full(error))) }; callback(result); } let callback = write_all_async_trampoline::; unsafe { ffi::g_output_stream_write_all_async( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } fn write_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin> + 'static>> { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.write_async(buffer, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } fn write_all_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin< Box< dyn std::future::Future< Output = Result<(B, usize, Option), (B, glib::Error)>, > + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.write_all_async(buffer, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_output_stream_writev")] fn writev( &self, vectors: &[OutputVector], cancellable: Option<&impl IsA>, ) -> Result { unsafe { let mut error = ptr::null_mut(); let mut bytes_written = mem::MaybeUninit::uninit(); ffi::g_output_stream_writev( self.as_ref().to_glib_none().0, vectors.as_ptr() as *const _, vectors.len(), bytes_written.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(bytes_written.assume_init()) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_output_stream_writev_async")] fn writev_async< B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec, usize), (Vec, glib::Error)>) + 'static, >( &self, vectors: impl IntoIterator + 'static, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffers = vectors.into_iter().collect::>(); let vectors = buffers .iter() .map(|v| ffi::GOutputVector { buffer: v.as_ref().as_ptr() as *const _, size: v.as_ref().len(), }) .collect::>(); let vectors_ptr = vectors.as_ptr(); let num_vectors = vectors.len(); let user_data: Box<( glib::thread_guard::ThreadGuard

, Vec, Vec, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), buffers, vectors, )); unsafe extern "C" fn writev_async_trampoline< B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec, usize), (Vec, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<( glib::thread_guard::ThreadGuard

, Vec, Vec, )> = Box::from_raw(user_data as *mut _); let (callback, buffers, _) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let mut bytes_written = mem::MaybeUninit::uninit(); ffi::g_output_stream_writev_finish( _source_object as *mut _, res, bytes_written.as_mut_ptr(), &mut error, ); let bytes_written = bytes_written.assume_init(); let result = if error.is_null() { Ok((buffers, bytes_written)) } else { Err((buffers, from_glib_full(error))) }; callback(result); } let callback = writev_async_trampoline::; unsafe { ffi::g_output_stream_writev_async( self.as_ref().to_glib_none().0, vectors_ptr, num_vectors, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn writev_future + Send + 'static>( &self, vectors: impl IntoIterator + 'static, io_priority: glib::Priority, ) -> Pin< Box< dyn std::future::Future, usize), (Vec, glib::Error)>> + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.writev_async(vectors, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_output_stream_writev_all")] fn writev_all( &self, vectors: &[OutputVector], cancellable: Option<&impl IsA>, ) -> Result<(usize, Option), glib::Error> { unsafe { let mut error = ptr::null_mut(); let mut bytes_written = mem::MaybeUninit::uninit(); ffi::g_output_stream_writev_all( self.as_ref().to_glib_none().0, mut_override(vectors.as_ptr() as *const _), vectors.len(), bytes_written.as_mut_ptr(), cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); let bytes_written = bytes_written.assume_init(); if error.is_null() { Ok((bytes_written, None)) } else if bytes_written != 0 { Ok((bytes_written, Some(from_glib_full(error)))) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_output_stream_writev_all_async")] fn writev_all_async< B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec, usize, Option), (Vec, glib::Error)>) + 'static, >( &self, vectors: impl IntoIterator + 'static, io_priority: glib::Priority, cancellable: Option<&impl IsA>, callback: P, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffers = vectors.into_iter().collect::>(); let vectors = buffers .iter() .map(|v| ffi::GOutputVector { buffer: v.as_ref().as_ptr() as *const _, size: v.as_ref().len(), }) .collect::>(); let vectors_ptr = vectors.as_ptr(); let num_vectors = vectors.len(); let user_data: Box<( glib::thread_guard::ThreadGuard

, Vec, Vec, )> = Box::new(( glib::thread_guard::ThreadGuard::new(callback), buffers, vectors, )); unsafe extern "C" fn writev_all_async_trampoline< B: AsRef<[u8]> + Send + 'static, P: FnOnce(Result<(Vec, usize, Option), (Vec, glib::Error)>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let user_data: Box<( glib::thread_guard::ThreadGuard

, Vec, Vec, )> = Box::from_raw(user_data as *mut _); let (callback, buffers, _) = *user_data; let callback = callback.into_inner(); let mut error = ptr::null_mut(); let mut bytes_written = mem::MaybeUninit::uninit(); ffi::g_output_stream_writev_all_finish( _source_object as *mut _, res, bytes_written.as_mut_ptr(), &mut error, ); let bytes_written = bytes_written.assume_init(); let result = if error.is_null() { Ok((buffers, bytes_written, None)) } else if bytes_written != 0 { Ok((buffers, bytes_written, from_glib_full(error))) } else { Err((buffers, from_glib_full(error))) }; callback(result); } let callback = writev_all_async_trampoline::; unsafe { ffi::g_output_stream_writev_all_async( self.as_ref().to_glib_none().0, mut_override(vectors_ptr), num_vectors, io_priority.into_glib(), gcancellable.0, Some(callback), Box::into_raw(user_data) as *mut _, ); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn writev_all_future + Send + 'static>( &self, vectors: impl IntoIterator + 'static, io_priority: glib::Priority, ) -> Pin< Box< dyn std::future::Future< Output = Result<(Vec, usize, Option), (Vec, glib::Error)>, > + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.writev_all_async(vectors, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } fn into_write(self) -> OutputStreamWrite where Self: IsA, { OutputStreamWrite(self) } } impl> OutputStreamExtManual for O {} #[derive(Debug)] pub struct OutputStreamWrite>(T); impl> OutputStreamWrite { pub fn into_output_stream(self) -> T { self.0 } pub fn output_stream(&self) -> &T { &self.0 } } impl> io::Write for OutputStreamWrite { fn write(&mut self, buf: &[u8]) -> io::Result { let result = self .0 .as_ref() .write(buf, crate::Cancellable::NONE) .map(|size| size as usize); to_std_io_result(result) } fn write_all(&mut self, buf: &[u8]) -> io::Result<()> { let result = self .0 .as_ref() .write_all(buf, crate::Cancellable::NONE) .and_then(|(_, e)| e.map(Err).unwrap_or(Ok(()))); to_std_io_result(result) } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn write_vectored(&mut self, bufs: &[io::IoSlice<'_>]) -> io::Result { let vectors = bufs .iter() .map(|v| OutputVector::new(v)) .collect::>(); let result = self.0.as_ref().writev(&vectors, crate::Cancellable::NONE); to_std_io_result(result) } fn flush(&mut self) -> io::Result<()> { let gio_result = self.0.as_ref().flush(crate::Cancellable::NONE); to_std_io_result(gio_result) } } impl + IsA> io::Seek for OutputStreamWrite { fn seek(&mut self, pos: io::SeekFrom) -> io::Result { let (pos, type_) = match pos { io::SeekFrom::Start(pos) => (pos as i64, glib::SeekType::Set), io::SeekFrom::End(pos) => (pos, glib::SeekType::End), io::SeekFrom::Current(pos) => (pos, glib::SeekType::Cur), }; let seekable: &Seekable = self.0.as_ref(); let gio_result = seekable .seek(pos, type_, crate::Cancellable::NONE) .map(|_| seekable.tell() as u64); to_std_io_result(gio_result) } } #[cfg(test)] mod tests { use std::io::Write; use glib::Bytes; #[cfg(feature = "v2_60")] use crate::OutputVector; use crate::{prelude::*, test_util::run_async, MemoryInputStream, MemoryOutputStream}; #[test] fn splice_async() { let ret = run_async(|tx, l| { let input = MemoryInputStream::new(); let b = Bytes::from_owned(vec![1, 2, 3]); input.add_bytes(&b); let strm = MemoryOutputStream::new_resizable(); strm.splice_async( &input, crate::OutputStreamSpliceFlags::CLOSE_SOURCE, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); assert_eq!(ret.unwrap(), 3); } #[test] fn write_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let buf = vec![1, 2, 3]; strm.write_async( buf, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let (buf, size) = ret.unwrap(); assert_eq!(buf, vec![1, 2, 3]); assert_eq!(size, 3); } #[test] fn write_all_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let buf = vec![1, 2, 3]; strm.write_all_async( buf, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); let (buf, size, err) = ret.unwrap(); assert_eq!(buf, vec![1, 2, 3]); assert_eq!(size, 3); assert!(err.is_none()); } #[test] fn write_bytes_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let b = Bytes::from_owned(vec![1, 2, 3]); strm.write_bytes_async( &b, glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); l.quit(); }, ); }); assert_eq!(ret.unwrap(), 3); } #[test] fn std_io_write() { let b = Bytes::from_owned(vec![1, 2, 3]); let mut write = MemoryOutputStream::new_resizable().into_write(); let ret = write.write(&b); let stream = write.into_output_stream(); stream.close(crate::Cancellable::NONE).unwrap(); assert_eq!(ret.unwrap(), 3); assert_eq!(stream.steal_as_bytes(), [1, 2, 3].as_ref()); } #[test] fn into_output_stream() { let stream = MemoryOutputStream::new_resizable(); let stream_clone = stream.clone(); let stream = stream.into_write().into_output_stream(); assert_eq!(stream, stream_clone); } #[test] #[cfg(feature = "v2_60")] fn writev() { let stream = MemoryOutputStream::new_resizable(); let ret = stream.writev( &[OutputVector::new(&[1, 2, 3]), OutputVector::new(&[4, 5, 6])], crate::Cancellable::NONE, ); assert_eq!(ret.unwrap(), 6); stream.close(crate::Cancellable::NONE).unwrap(); assert_eq!(stream.steal_as_bytes(), [1, 2, 3, 4, 5, 6].as_ref()); } #[test] #[cfg(feature = "v2_60")] fn writev_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let strm_clone = strm.clone(); strm.writev_async( [vec![1, 2, 3], vec![4, 5, 6]], glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); strm_clone.close(crate::Cancellable::NONE).unwrap(); assert_eq!(strm_clone.steal_as_bytes(), [1, 2, 3, 4, 5, 6].as_ref()); l.quit(); }, ); }); let (buf, size) = ret.unwrap(); assert_eq!(buf, [[1, 2, 3], [4, 5, 6]]); assert_eq!(size, 6); } #[test] #[cfg(feature = "v2_60")] fn writev_all_async() { let ret = run_async(|tx, l| { let strm = MemoryOutputStream::new_resizable(); let strm_clone = strm.clone(); strm.writev_all_async( [vec![1, 2, 3], vec![4, 5, 6]], glib::Priority::DEFAULT_IDLE, crate::Cancellable::NONE, move |ret| { tx.send(ret).unwrap(); strm_clone.close(crate::Cancellable::NONE).unwrap(); assert_eq!(strm_clone.steal_as_bytes(), [1, 2, 3, 4, 5, 6].as_ref()); l.quit(); }, ); }); let (buf, size, err) = ret.unwrap(); assert_eq!(buf, [[1, 2, 3], [4, 5, 6]]); assert_eq!(size, 6); assert!(err.is_none()); } } gio-0.20.1/src/pollable_input_stream.rs000064400000000000000000000153211046102023000162050ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::RefCell, io, mem::transmute, pin::Pin, ptr}; use futures_core::{ stream::Stream, task::{Context, Poll}, }; use futures_io::AsyncRead; use glib::{prelude::*, translate::*}; use crate::{ffi, prelude::*, Cancellable, PollableInputStream}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PollableInputStreamExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_pollable_input_stream_create_source")] fn create_source( &self, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::ControlFlow + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O) -> glib::ControlFlow + 'static, >( stream: *mut ffi::GPollableInputStream, func: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let func: &RefCell = &*(func as *const RefCell); let mut func = func.borrow_mut(); (*func)(PollableInputStream::from_glib_borrow(stream).unsafe_cast_ref()).into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { let _ = Box::>::from_raw(ptr as *mut _); } let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); unsafe { let source = ffi::g_pollable_input_stream_create_source( self.as_ref().to_glib_none().0, gcancellable.0, ); let trampoline = trampoline:: as glib::ffi::gpointer; glib::ffi::g_source_set_callback( source, Some(transmute::< glib::ffi::gpointer, unsafe extern "C" fn(glib::ffi::gpointer) -> glib::ffi::gboolean, >(trampoline)), Box::into_raw(Box::new(RefCell::new(func))) as glib::ffi::gpointer, Some(destroy_closure::), ); glib::ffi::g_source_set_priority(source, priority.into_glib()); if let Some(name) = name { glib::ffi::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } fn create_source_future>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.create_source(cancellable.as_ref(), None, priority, move |_| { let _ = send.take().unwrap().send(()); glib::ControlFlow::Break }) })) } fn create_source_stream>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceStream::new(move |send| { obj.create_source(cancellable.as_ref(), None, priority, move |_| { if send.unbounded_send(()).is_err() { glib::ControlFlow::Break } else { glib::ControlFlow::Continue } }) })) } #[doc(alias = "g_pollable_input_stream_read_nonblocking")] fn read_nonblocking>( &self, buffer: &mut [u8], cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_pollable_input_stream_read_nonblocking( self.as_ref().to_glib_none().0, buffer.to_glib_none().0, count, gcancellable.0, &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } fn into_async_read(self) -> Result, Self> where Self: IsA, { if self.can_poll() { Ok(InputStreamAsyncRead(self)) } else { Err(self) } } } impl> PollableInputStreamExtManual for O {} #[derive(Debug)] pub struct InputStreamAsyncRead>(T); impl> InputStreamAsyncRead { pub fn into_input_stream(self) -> T { self.0 } pub fn input_stream(&self) -> &T { &self.0 } } impl> AsyncRead for InputStreamAsyncRead { fn poll_read( self: Pin<&mut Self>, cx: &mut Context, buf: &mut [u8], ) -> Poll> { let stream = Pin::get_ref(self.as_ref()); let gio_result = stream .0 .as_ref() .read_nonblocking(buf, crate::Cancellable::NONE); match gio_result { Ok(size) => Poll::Ready(Ok(size as usize)), Err(err) => { let kind = err .kind::() .unwrap_or(crate::IOErrorEnum::Failed); if kind == crate::IOErrorEnum::WouldBlock { let mut waker = Some(cx.waker().clone()); let source = stream.0.as_ref().create_source( crate::Cancellable::NONE, None, glib::Priority::default(), move |_| { if let Some(waker) = waker.take() { waker.wake(); } glib::ControlFlow::Break }, ); let main_context = glib::MainContext::ref_thread_default(); source.attach(Some(&main_context)); Poll::Pending } else { Poll::Ready(Err(io::Error::new(io::ErrorKind::from(kind), err))) } } } } } gio-0.20.1/src/pollable_output_stream.rs000064400000000000000000000251761046102023000164170ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cell::RefCell, io, mem::transmute, pin::Pin}; use futures_channel::oneshot; use futures_core::{ stream::Stream, task::{Context, Poll}, Future, }; use futures_io::AsyncWrite; use glib::{prelude::*, translate::*}; use crate::{error::to_std_io_result, ffi, prelude::*, Cancellable, PollableOutputStream}; #[cfg(feature = "v2_60")] use crate::{OutputVector, PollableReturn}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait PollableOutputStreamExtManual: sealed::Sealed + IsA { #[doc(alias = "g_pollable_output_stream_create_source")] fn create_source( &self, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::ControlFlow + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O) -> glib::ControlFlow + 'static, >( stream: *mut ffi::GPollableOutputStream, func: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let func: &RefCell = &*(func as *const RefCell); let mut func = func.borrow_mut(); (*func)(PollableOutputStream::from_glib_borrow(stream).unsafe_cast_ref()).into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { let _ = Box::>::from_raw(ptr as *mut _); } let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); unsafe { let source = ffi::g_pollable_output_stream_create_source( self.as_ref().to_glib_none().0, gcancellable.0, ); let trampoline = trampoline:: as glib::ffi::gpointer; glib::ffi::g_source_set_callback( source, Some(transmute::< glib::ffi::gpointer, unsafe extern "C" fn(glib::ffi::gpointer) -> glib::ffi::gboolean, >(trampoline)), Box::into_raw(Box::new(RefCell::new(func))) as glib::ffi::gpointer, Some(destroy_closure::), ); glib::ffi::g_source_set_priority(source, priority.into_glib()); if let Some(name) = name { glib::ffi::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } fn create_source_future>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.create_source(cancellable.as_ref(), None, priority, move |_| { let _ = send.take().unwrap().send(()); glib::ControlFlow::Break }) })) } fn create_source_stream>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceStream::new(move |send| { let send = Some(send); obj.create_source(cancellable.as_ref(), None, priority, move |_| { if send.as_ref().unwrap().unbounded_send(()).is_err() { glib::ControlFlow::Break } else { glib::ControlFlow::Continue } }) })) } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_pollable_output_stream_writev_nonblocking")] fn writev_nonblocking( &self, vectors: &[OutputVector], cancellable: Option<&impl IsA>, ) -> Result<(PollableReturn, usize), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let mut bytes_written = 0; let ret = ffi::g_pollable_output_stream_writev_nonblocking( self.as_ref().to_glib_none().0, vectors.as_ptr() as *const _, vectors.len(), &mut bytes_written, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib(ret), bytes_written)) } else { Err(from_glib_full(error)) } } } fn into_async_write(self) -> Result, Self> where Self: IsA, { if self.can_poll() { Ok(OutputStreamAsyncWrite(self, None)) } else { Err(self) } } } impl> PollableOutputStreamExtManual for O {} #[derive(Debug)] pub struct OutputStreamAsyncWrite>( T, Option>>, ); impl> OutputStreamAsyncWrite { pub fn into_output_stream(self) -> T { self.0 } pub fn output_stream(&self) -> &T { &self.0 } } impl> AsyncWrite for OutputStreamAsyncWrite { fn poll_write(self: Pin<&mut Self>, cx: &mut Context, buf: &[u8]) -> Poll> { let stream = Pin::get_ref(self.as_ref()); let gio_result = stream .0 .as_ref() .write_nonblocking(buf, crate::Cancellable::NONE); match gio_result { Ok(size) => Poll::Ready(Ok(size as usize)), Err(err) => { let kind = err .kind::() .unwrap_or(crate::IOErrorEnum::Failed); if kind == crate::IOErrorEnum::WouldBlock { let mut waker = Some(cx.waker().clone()); let source = stream.0.as_ref().create_source( crate::Cancellable::NONE, None, glib::Priority::default(), move |_| { if let Some(waker) = waker.take() { waker.wake(); } glib::ControlFlow::Break }, ); let main_context = glib::MainContext::ref_thread_default(); source.attach(Some(&main_context)); Poll::Pending } else { Poll::Ready(Err(io::Error::new(io::ErrorKind::from(kind), err))) } } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] fn poll_write_vectored( self: Pin<&mut Self>, cx: &mut Context<'_>, bufs: &[io::IoSlice<'_>], ) -> Poll> { let stream = Pin::get_ref(self.as_ref()); let vectors = bufs .iter() .map(|v| OutputVector::new(v)) .collect::>(); let gio_result = stream .0 .as_ref() .writev_nonblocking(&vectors, crate::Cancellable::NONE); match gio_result { Ok((PollableReturn::Ok, size)) => Poll::Ready(Ok(size)), Ok((PollableReturn::WouldBlock, _)) => { let mut waker = Some(cx.waker().clone()); let source = stream.0.as_ref().create_source( crate::Cancellable::NONE, None, glib::Priority::default(), move |_| { if let Some(waker) = waker.take() { waker.wake(); } glib::ControlFlow::Break }, ); let main_context = glib::MainContext::ref_thread_default(); source.attach(Some(&main_context)); Poll::Pending } Ok((_, _)) => unreachable!(), Err(err) => Poll::Ready(Err(io::Error::new( io::ErrorKind::from( err.kind::() .unwrap_or(crate::IOErrorEnum::Failed), ), err, ))), } } fn poll_flush(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let stream = unsafe { Pin::get_unchecked_mut(self) }; let rx = if let Some(ref mut rx) = stream.1 { rx } else { let (tx, rx) = oneshot::channel(); stream.0.as_ref().flush_async( glib::Priority::default(), crate::Cancellable::NONE, move |res| { let _ = tx.send(res); }, ); stream.1 = Some(rx); stream.1.as_mut().unwrap() }; match Pin::new(rx).poll(cx) { Poll::Ready(Ok(res)) => { let _ = stream.1.take(); Poll::Ready(to_std_io_result(res)) } Poll::Ready(Err(_)) => { let _ = stream.1.take(); Poll::Ready(Ok(())) } Poll::Pending => Poll::Pending, } } fn poll_close(self: Pin<&mut Self>, cx: &mut Context) -> Poll> { let stream = unsafe { Pin::get_unchecked_mut(self) }; let rx = if let Some(ref mut rx) = stream.1 { rx } else { let (tx, rx) = oneshot::channel(); stream.0.as_ref().close_async( glib::Priority::default(), crate::Cancellable::NONE, move |res| { let _ = tx.send(res); }, ); stream.1 = Some(rx); stream.1.as_mut().unwrap() }; match Pin::new(rx).poll(cx) { Poll::Ready(Ok(res)) => { let _ = stream.1.take(); Poll::Ready(to_std_io_result(res)) } Poll::Ready(Err(_)) => { let _ = stream.1.take(); Poll::Ready(Ok(())) } Poll::Pending => Poll::Pending, } } } gio-0.20.1/src/prelude.rs000064400000000000000000000041671046102023000132670ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. // rustdoc-stripper-ignore-next //! Traits and essential types intended for blanket imports. #[doc(hidden)] pub use glib::prelude::*; #[cfg(feature = "v2_60")] pub use crate::app_info::AppInfoExtManual; #[cfg(feature = "v2_72")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_72")))] pub use crate::debug_controller_dbus::DebugControllerDBusExtManual; #[cfg(feature = "v2_58")] #[cfg(all(not(windows), not(target_os = "macos")))] #[cfg_attr(docsrs, doc(cfg(all(not(windows), not(target_os = "macos")))))] pub use crate::desktop_app_info::DesktopAppInfoExtManual; #[cfg(unix)] pub use crate::file_descriptor_based::FileDescriptorBasedExtManual; #[cfg(unix)] pub use crate::unix_fd_list::UnixFDListExtManual; #[cfg(unix)] pub use crate::unix_fd_message::UnixFDMessageExtManual; #[cfg(unix)] pub use crate::unix_input_stream::UnixInputStreamExtManual; #[cfg(unix)] pub use crate::unix_output_stream::UnixOutputStreamExtManual; #[cfg(unix)] pub use crate::unix_socket_address::{UnixSocketAddressExtManual, UnixSocketAddressPath}; #[cfg(windows)] pub use crate::win32_input_stream::Win32InputStreamExt; #[cfg(windows)] pub use crate::win32_output_stream::Win32OutputStreamExt; pub use crate::{ action_map::ActionMapExtManual, application::ApplicationExtManual, auto::traits::*, cancellable::CancellableExtManual, converter::ConverterExtManual, data_input_stream::DataInputStreamExtManual, datagram_based::DatagramBasedExtManual, dbus_proxy::DBusProxyExtManual, file::FileExtManual, file_enumerator::FileEnumeratorExtManual, inet_address::InetAddressExtManual, input_stream::InputStreamExtManual, io_stream::IOStreamExtManual, list_model::ListModelExtManual, output_stream::OutputStreamExtManual, pollable_input_stream::PollableInputStreamExtManual, pollable_output_stream::PollableOutputStreamExtManual, settings::SettingsExtManual, simple_proxy_resolver::SimpleProxyResolverExtManual, socket::SocketExtManual, socket_control_message::SocketControlMessageExtManual, socket_listener::SocketListenerExtManual, tls_connection::TlsConnectionExtManual, }; gio-0.20.1/src/read_input_stream.rs000064400000000000000000000302321046102023000153240ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ any::Any, io::{Read, Seek}, }; use crate::{prelude::*, subclass::prelude::*, InputStream}; mod imp { use std::cell::RefCell; use super::*; pub(super) enum Reader { Read(AnyReader), ReadSeek(AnyReader), } #[derive(Default)] pub struct ReadInputStream { pub(super) read: RefCell>, } #[glib::object_subclass] impl ObjectSubclass for ReadInputStream { const NAME: &'static str = "ReadInputStream"; const ALLOW_NAME_CONFLICT: bool = true; type Type = super::ReadInputStream; type ParentType = InputStream; type Interfaces = (crate::Seekable,); } impl ObjectImpl for ReadInputStream {} impl InputStreamImpl for ReadInputStream { fn read( &self, buffer: &mut [u8], _cancellable: Option<&crate::Cancellable>, ) -> Result { let mut read = self.read.borrow_mut(); let read = match *read { None => { return Err(glib::Error::new( crate::IOErrorEnum::Closed, "Already closed", )); } Some(Reader::Read(ref mut read)) => read, Some(Reader::ReadSeek(ref mut read)) => read, }; loop { match std_error_to_gio_error(read.read(buffer)) { None => continue, Some(res) => return res, } } } fn close(&self, _cancellable: Option<&crate::Cancellable>) -> Result<(), glib::Error> { let _ = self.read.take(); Ok(()) } } impl SeekableImpl for ReadInputStream { fn tell(&self) -> i64 { // XXX: stream_position is not stable yet // let mut read = self.read.borrow_mut(); // match *read { // Some(Reader::ReadSeek(ref mut read)) => { // read.stream_position().map(|pos| pos as i64).unwrap_or(-1) // }, // _ => -1, // }; -1 } fn can_seek(&self) -> bool { let read = self.read.borrow(); matches!(*read, Some(Reader::ReadSeek(_))) } fn seek( &self, offset: i64, type_: glib::SeekType, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { use std::io::SeekFrom; let mut read = self.read.borrow_mut(); match *read { Some(Reader::ReadSeek(ref mut read)) => { let pos = match type_ { glib::SeekType::Cur => SeekFrom::Current(offset), glib::SeekType::Set => { if offset < 0 { return Err(glib::Error::new( crate::IOErrorEnum::InvalidArgument, "Invalid Argument", )); } else { SeekFrom::Start(offset as u64) } } glib::SeekType::End => SeekFrom::End(offset), _ => unimplemented!(), }; loop { match std_error_to_gio_error(read.seek(pos)) { None => continue, Some(res) => return res.map(|_| ()), } } } _ => Err(glib::Error::new( crate::IOErrorEnum::NotSupported, "Truncating not supported", )), } } fn can_truncate(&self) -> bool { false } fn truncate( &self, _offset: i64, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { Err(glib::Error::new( crate::IOErrorEnum::NotSupported, "Truncating not supported", )) } } } glib::wrapper! { pub struct ReadInputStream(ObjectSubclass) @extends crate::InputStream, @implements crate::Seekable; } impl ReadInputStream { pub fn new(read: R) -> ReadInputStream { let obj: Self = glib::Object::new(); *obj.imp().read.borrow_mut() = Some(imp::Reader::Read(AnyReader::new(read))); obj } pub fn new_seekable(read: R) -> ReadInputStream { let obj: Self = glib::Object::new(); *obj.imp().read.borrow_mut() = Some(imp::Reader::ReadSeek(AnyReader::new_seekable(read))); obj } pub fn close_and_take(&self) -> Box { let inner = self.imp().read.take(); let ret = match inner { None => { panic!("Stream already closed or inner taken"); } Some(imp::Reader::Read(read)) => read.reader, Some(imp::Reader::ReadSeek(read)) => read.reader, }; let _ = self.close(crate::Cancellable::NONE); match ret { AnyOrPanic::Any(r) => r, AnyOrPanic::Panic(p) => std::panic::resume_unwind(p), } } } enum AnyOrPanic { Any(Box), Panic(Box), } // Helper struct for dynamically dispatching to any kind of Reader and // catching panics along the way struct AnyReader { reader: AnyOrPanic, read_fn: fn(s: &mut AnyReader, buffer: &mut [u8]) -> std::io::Result, seek_fn: Option std::io::Result>, } impl AnyReader { fn new(r: R) -> Self { Self { reader: AnyOrPanic::Any(Box::new(r)), read_fn: Self::read_fn::, seek_fn: None, } } fn new_seekable(r: R) -> Self { Self { reader: AnyOrPanic::Any(Box::new(r)), read_fn: Self::read_fn::, seek_fn: Some(Self::seek_fn::), } } fn read_fn(s: &mut AnyReader, buffer: &mut [u8]) -> std::io::Result { s.with_inner(|r: &mut R| r.read(buffer)) } fn seek_fn( s: &mut AnyReader, pos: std::io::SeekFrom, ) -> std::io::Result { s.with_inner(|r: &mut R| r.seek(pos)) } fn with_inner std::io::Result>( &mut self, func: F, ) -> std::io::Result { match self.reader { AnyOrPanic::Any(ref mut reader) => { let r = reader.downcast_mut::().unwrap(); match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| func(r))) { Ok(res) => res, Err(panic) => { self.reader = AnyOrPanic::Panic(panic); Err(std::io::Error::new(std::io::ErrorKind::Other, "Panicked")) } } } AnyOrPanic::Panic(_) => Err(std::io::Error::new( std::io::ErrorKind::Other, "Panicked before", )), } } fn read(&mut self, buffer: &mut [u8]) -> std::io::Result { (self.read_fn)(self, buffer) } fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result { if let Some(ref seek_fn) = self.seek_fn { seek_fn(self, pos) } else { unreachable!() } } } pub(crate) fn std_error_to_gio_error( res: Result, ) -> Option> { match res { Ok(res) => Some(Ok(res)), Err(err) => { use std::io::ErrorKind; #[allow(clippy::wildcard_in_or_patterns)] match err.kind() { ErrorKind::NotFound => Some(Err(glib::Error::new( crate::IOErrorEnum::NotFound, "Not Found", ))), ErrorKind::PermissionDenied => Some(Err(glib::Error::new( crate::IOErrorEnum::PermissionDenied, "Permission Denied", ))), ErrorKind::ConnectionRefused => Some(Err(glib::Error::new( crate::IOErrorEnum::ConnectionRefused, "Connection Refused", ))), ErrorKind::ConnectionReset | ErrorKind::ConnectionAborted | ErrorKind::NotConnected => Some(Err(glib::Error::new( crate::IOErrorEnum::NotConnected, "Connection Reset", ))), ErrorKind::AddrInUse | ErrorKind::AddrNotAvailable => Some(Err(glib::Error::new( crate::IOErrorEnum::AddressInUse, "Address In Use", ))), ErrorKind::BrokenPipe => Some(Err(glib::Error::new( crate::IOErrorEnum::BrokenPipe, "Broken Pipe", ))), ErrorKind::AlreadyExists => Some(Err(glib::Error::new( crate::IOErrorEnum::Exists, "Already Exists", ))), ErrorKind::WouldBlock => Some(Err(glib::Error::new( crate::IOErrorEnum::WouldBlock, "Would Block", ))), ErrorKind::InvalidInput | ErrorKind::InvalidData => Some(Err(glib::Error::new( crate::IOErrorEnum::InvalidData, "Invalid Input", ))), ErrorKind::TimedOut => Some(Err(glib::Error::new( crate::IOErrorEnum::TimedOut, "Timed Out", ))), ErrorKind::Interrupted => None, ErrorKind::UnexpectedEof => Some(Err(glib::Error::new( crate::IOErrorEnum::Closed, "Unexpected Eof", ))), ErrorKind::WriteZero | _ => Some(Err(glib::Error::new( crate::IOErrorEnum::Failed, format!("Unknown error: {err:?}").as_str(), ))), } } } } #[cfg(test)] mod tests { use std::io::Cursor; use super::*; #[test] fn test_read() { let cursor = Cursor::new(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); let stream = ReadInputStream::new(cursor); let mut buf = [0u8; 1024]; assert_eq!(stream.read(&mut buf[..], crate::Cancellable::NONE), Ok(10)); assert_eq!(&buf[..10], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..]); assert_eq!(stream.read(&mut buf[..], crate::Cancellable::NONE), Ok(0)); let inner = stream.close_and_take(); assert!(inner.is::>>()); let inner = inner.downcast_ref::>>().unwrap(); assert_eq!(inner.get_ref(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); } #[test] fn test_read_seek() { let cursor = Cursor::new(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); let stream = ReadInputStream::new_seekable(cursor); let mut buf = [0u8; 1024]; assert_eq!(stream.read(&mut buf[..], crate::Cancellable::NONE), Ok(10)); assert_eq!(&buf[..10], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..]); assert_eq!(stream.read(&mut buf[..], crate::Cancellable::NONE), Ok(0)); assert!(stream.can_seek()); assert_eq!( stream.seek(0, glib::SeekType::Set, crate::Cancellable::NONE), Ok(()) ); assert_eq!(stream.read(&mut buf[..], crate::Cancellable::NONE), Ok(10)); assert_eq!(&buf[..10], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..]); let inner = stream.close_and_take(); assert!(inner.is::>>()); let inner = inner.downcast_ref::>>().unwrap(); assert_eq!(inner.get_ref(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); } } gio-0.20.1/src/resource.rs000064400000000000000000000034031046102023000134460ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr}; use glib::translate::*; use crate::{resources_register, Resource}; impl Resource { #[doc(alias = "g_resource_new_from_data")] pub fn from_data(data: &glib::Bytes) -> Result { unsafe { let mut error = ptr::null_mut(); // Create a copy of data if it is not pointer-aligned // https://bugzilla.gnome.org/show_bug.cgi?id=790030 let mut data = data.clone(); let data_ptr = glib::ffi::g_bytes_get_data(data.to_glib_none().0, ptr::null_mut()); if data_ptr as usize % mem::align_of::<*const u8>() != 0 { data = glib::Bytes::from(&*data); } let ret = crate::ffi::g_resource_new_from_data(data.to_glib_none().0, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } } #[doc(hidden)] pub fn resources_register_include_impl(bytes: &'static [u8]) -> Result<(), glib::Error> { let bytes = glib::Bytes::from_static(bytes); let resource = Resource::from_data(&bytes)?; resources_register(&resource); Ok(()) } // rustdoc-stripper-ignore-next /// Include gresources generated with `glib_build_tools::compile_resources` and register with glib. `path` is /// relative to `OUTDIR`. /// /// ```ignore /// gio::resources_register_include!("compiled.gresource").unwrap(); /// ``` #[macro_export] macro_rules! resources_register_include { ($path:expr) => { $crate::resources_register_include_impl(include_bytes!(concat!( env!("OUT_DIR"), "/", $path ))) }; } gio-0.20.1/src/settings.rs000064400000000000000000000233421046102023000134630ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*, BoolError, StrV, Variant}; use crate::{ffi, prelude::*, Settings, SettingsBindFlags}; #[must_use = "The builder must be built to be used"] pub struct BindingBuilder<'a> { settings: &'a Settings, key: &'a str, object: &'a glib::Object, property: &'a str, flags: SettingsBindFlags, #[allow(clippy::type_complexity)] get_mapping: Option Option>>, #[allow(clippy::type_complexity)] set_mapping: Option Option>>, } impl<'a> BindingBuilder<'a> { pub fn flags(mut self, flags: SettingsBindFlags) -> Self { self.flags = flags; self } // rustdoc-stripper-ignore-next /// Set the binding flags to [`GET`][crate::SettingsBindFlags::GET]. pub fn get(mut self) -> Self { self.flags |= SettingsBindFlags::GET; self } // rustdoc-stripper-ignore-next /// Set the binding flags to [`SET`][crate::SettingsBindFlags::SET]. pub fn set(mut self) -> Self { self.flags |= SettingsBindFlags::SET; self } // rustdoc-stripper-ignore-next /// Unsets the default [`GET`][crate::SettingsBindFlags::GET] flag. pub fn set_only(mut self) -> Self { self.flags = (self.flags - SettingsBindFlags::GET) | SettingsBindFlags::SET; self } // rustdoc-stripper-ignore-next /// Unsets the default [`SET`][crate::SettingsBindFlags::SET] flag. pub fn get_only(mut self) -> Self { self.flags = (self.flags - SettingsBindFlags::SET) | SettingsBindFlags::GET; self } // rustdoc-stripper-ignore-next /// Set the binding flags to [`NO_SENSITIVITY`][crate::SettingsBindFlags::NO_SENSITIVITY]. pub fn no_sensitivity(mut self) -> Self { self.flags |= SettingsBindFlags::NO_SENSITIVITY; self } // rustdoc-stripper-ignore-next /// Set the binding flags to [`GET_NO_CHANGES`][crate::SettingsBindFlags::GET_NO_CHANGES]. pub fn get_no_changes(mut self) -> Self { self.flags |= SettingsBindFlags::GET_NO_CHANGES; self } // rustdoc-stripper-ignore-next /// Set the binding flags to [`INVERT_BOOLEAN`][crate::SettingsBindFlags::INVERT_BOOLEAN]. pub fn invert_boolean(mut self) -> Self { self.flags |= SettingsBindFlags::INVERT_BOOLEAN; self } #[doc(alias = "get_mapping")] pub fn mapping Option + 'static>( mut self, f: F, ) -> Self { self.get_mapping = Some(Box::new(f)); self } pub fn set_mapping< F: Fn(&glib::Value, glib::VariantType) -> Option + 'static, >( mut self, f: F, ) -> Self { self.set_mapping = Some(Box::new(f)); self } pub fn build(self) { type Mappings = ( Option Option>>, Option Option>>, ); unsafe extern "C" fn bind_with_mapping_get_trampoline( value: *mut glib::gobject_ffi::GValue, variant: *mut glib::ffi::GVariant, user_data: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let user_data = &*(user_data as *const Mappings); let f = user_data.0.as_ref().unwrap(); let value = &mut *(value as *mut glib::Value); if let Some(v) = f(&from_glib_borrow(variant), value.type_()) { *value = v; true } else { false } .into_glib() } unsafe extern "C" fn bind_with_mapping_set_trampoline( value: *const glib::gobject_ffi::GValue, variant_type: *const glib::ffi::GVariantType, user_data: glib::ffi::gpointer, ) -> *mut glib::ffi::GVariant { let user_data = &*(user_data as *const Mappings); let f = user_data.1.as_ref().unwrap(); let value = &*(value as *const glib::Value); f(value, from_glib_none(variant_type)).into_glib_ptr() } unsafe extern "C" fn destroy_closure(ptr: *mut libc::c_void) { let _ = Box::::from_raw(ptr as *mut _); } if self.get_mapping.is_none() && self.set_mapping.is_none() { unsafe { ffi::g_settings_bind( self.settings.to_glib_none().0, self.key.to_glib_none().0, self.object.to_glib_none().0, self.property.to_glib_none().0, self.flags.into_glib(), ); } } else { let get_trampoline: Option _> = if self.get_mapping.is_none() { None } else { Some(bind_with_mapping_get_trampoline) }; let set_trampoline: Option _> = if self.set_mapping.is_none() { None } else { Some(bind_with_mapping_set_trampoline) }; let mappings: Mappings = (self.get_mapping, self.set_mapping); unsafe { ffi::g_settings_bind_with_mapping( self.settings.to_glib_none().0, self.key.to_glib_none().0, self.object.to_glib_none().0, self.property.to_glib_none().0, self.flags.into_glib(), get_trampoline, set_trampoline, Box::into_raw(Box::new(mappings)) as *mut libc::c_void, Some(destroy_closure), ) } } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SettingsExtManual: sealed::Sealed + IsA { fn get(&self, key: &str) -> U { let val = self.value(key); FromVariant::from_variant(&val).unwrap_or_else(|| { panic!( "Type mismatch: Expected '{}' got '{}'", U::static_variant_type().as_str(), val.type_() ) }) } fn set(&self, key: &str, value: impl Into) -> Result<(), BoolError> { self.set_value(key, &value.into()) } #[doc(alias = "g_settings_get_strv")] #[doc(alias = "get_strv")] fn strv(&self, key: &str) -> StrV { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_get_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } #[doc(alias = "g_settings_set_strv")] fn set_strv(&self, key: &str, value: impl IntoStrV) -> Result<(), glib::error::BoolError> { unsafe { value.run_with_strv(|value| { glib::result_from_gboolean!( ffi::g_settings_set_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.as_ptr() as *mut _, ), "Can't set readonly key" ) }) } } #[doc(alias = "g_settings_bind")] #[doc(alias = "g_settings_bind_with_mapping")] fn bind<'a, P: IsA>( &'a self, key: &'a str, object: &'a P, property: &'a str, ) -> BindingBuilder<'a> { BindingBuilder { settings: self.upcast_ref(), key, object: object.upcast_ref(), property, flags: SettingsBindFlags::DEFAULT, get_mapping: None, set_mapping: None, } } } impl> SettingsExtManual for O {} #[cfg(test)] mod test { use std::{env::set_var, process::Command, str::from_utf8, sync::Once}; use super::*; static INIT: Once = Once::new(); fn set_env() { INIT.call_once(|| { let output = Command::new("glib-compile-schemas") .args([ &format!("{}/tests", env!("CARGO_MANIFEST_DIR")), "--targetdir", env!("OUT_DIR"), ]) .output() .unwrap(); if !output.status.success() { println!("Failed to generate GSchema!"); println!( "glib-compile-schemas stdout: {}", from_utf8(&output.stdout).unwrap() ); println!( "glib-compile-schemas stderr: {}", from_utf8(&output.stderr).unwrap() ); panic!("Can't test without GSchemas!"); } set_var("GSETTINGS_SCHEMA_DIR", env!("OUT_DIR")); set_var("GSETTINGS_BACKEND", "memory"); }); } #[test] #[serial_test::serial] fn string_get() { set_env(); let settings = Settings::new("com.github.gtk-rs.test"); assert_eq!(settings.get::("test-string").as_str(), "Good"); } #[test] #[serial_test::serial] fn bool_set_get() { set_env(); let settings = Settings::new("com.github.gtk-rs.test"); settings.set("test-bool", false).unwrap(); assert!(!settings.get::("test-bool")); } #[test] #[should_panic] #[serial_test::serial] fn wrong_type() { set_env(); let settings = Settings::new("com.github.gtk-rs.test"); settings.get::("test-string"); } } gio-0.20.1/src/simple_proxy_resolver.rs000064400000000000000000000025371046102023000163010ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use crate::{ffi, ProxyResolver, SimpleProxyResolver}; impl SimpleProxyResolver { #[doc(alias = "g_simple_proxy_resolver_new")] #[allow(clippy::new_ret_no_self)] pub fn new(default_proxy: Option<&str>, ignore_hosts: impl IntoStrV) -> ProxyResolver { unsafe { ignore_hosts.run_with_strv(|ignore_hosts| { from_glib_full(ffi::g_simple_proxy_resolver_new( default_proxy.to_glib_none().0, ignore_hosts.as_ptr() as *mut _, )) }) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SimpleProxyResolverExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "g_simple_proxy_resolver_set_ignore_hosts")] fn set_ignore_hosts(&self, ignore_hosts: impl IntoStrV) { unsafe { ignore_hosts.run_with_strv(|ignore_hosts| { ffi::g_simple_proxy_resolver_set_ignore_hosts( self.as_ref().to_glib_none().0, ignore_hosts.as_ptr() as *mut _, ); }) } } } impl> SimpleProxyResolverExtManual for O {} gio-0.20.1/src/socket.rs000064400000000000000000000713531046102023000131200ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; #[cfg(feature = "v2_60")] use std::time::Duration; use std::{cell::RefCell, marker::PhantomData, mem::transmute, pin::Pin, ptr}; use futures_core::stream::Stream; use glib::{prelude::*, translate::*, Slice}; #[cfg(feature = "v2_60")] use crate::PollableReturn; use crate::{ffi, Cancellable, Socket, SocketAddress, SocketControlMessage}; impl Socket { #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[allow(clippy::missing_safety_doc)] pub unsafe fn from_fd(fd: impl IntoRawFd) -> Result { let fd = fd.into_raw_fd(); let mut error = ptr::null_mut(); let ret = ffi::g_socket_new_from_fd(fd, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } #[cfg(windows)] #[cfg_attr(docsrs, doc(cfg(windows)))] #[allow(clippy::missing_safety_doc)] pub unsafe fn from_socket(socket: impl IntoRawSocket) -> Result { let socket = socket.into_raw_socket(); let mut error = ptr::null_mut(); let ret = ffi::g_socket_new_from_fd(socket as i32, &mut error); if error.is_null() { Ok(from_glib_full(ret)) } else { Err(from_glib_full(error)) } } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] impl AsRawFd for Socket { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_socket_get_fd(self.to_glib_none().0) as _ } } } #[cfg(windows)] #[cfg_attr(docsrs, doc(cfg(windows)))] impl AsRawSocket for Socket { fn as_raw_socket(&self) -> RawSocket { unsafe { ffi::g_socket_get_fd(self.to_glib_none().0) as _ } } } #[doc(alias = "GInputVector")] #[repr(transparent)] #[derive(Debug)] pub struct InputVector<'v> { vector: ffi::GInputVector, buffer: PhantomData<&'v mut [u8]>, } impl<'v> InputVector<'v> { #[inline] pub fn new(buffer: &'v mut [u8]) -> Self { Self { vector: ffi::GInputVector { buffer: buffer.as_mut_ptr() as *mut _, size: buffer.len(), }, buffer: PhantomData, } } } unsafe impl<'v> Send for InputVector<'v> {} unsafe impl<'v> Sync for InputVector<'v> {} impl<'v> std::ops::Deref for InputVector<'v> { type Target = [u8]; #[inline] fn deref(&self) -> &Self::Target { unsafe { std::slice::from_raw_parts(self.vector.buffer as *const _, self.vector.size) } } } impl<'v> std::ops::DerefMut for InputVector<'v> { #[inline] fn deref_mut(&mut self) -> &mut Self::Target { unsafe { std::slice::from_raw_parts_mut(self.vector.buffer as *mut _, self.vector.size) } } } #[derive(Debug)] pub struct SocketControlMessages { ptr: *mut *mut ffi::GSocketControlMessage, len: u32, } impl SocketControlMessages { #[inline] pub const fn new() -> Self { Self { ptr: ptr::null_mut(), len: 0, } } } impl AsRef<[SocketControlMessage]> for SocketControlMessages { #[inline] fn as_ref(&self) -> &[SocketControlMessage] { unsafe { std::slice::from_raw_parts(self.ptr as *const _, self.len as usize) } } } impl std::ops::Deref for SocketControlMessages { type Target = [SocketControlMessage]; #[inline] fn deref(&self) -> &Self::Target { self.as_ref() } } impl Default for SocketControlMessages { #[inline] fn default() -> Self { Self::new() } } impl Drop for SocketControlMessages { #[inline] fn drop(&mut self) { unsafe { let _: Slice = Slice::from_glib_full_num(self.ptr as *mut _, self.len as usize); } } } #[doc(alias = "GInputMessage")] #[repr(transparent)] #[derive(Debug)] pub struct InputMessage<'m> { message: ffi::GInputMessage, address: PhantomData>>, vectors: PhantomData<&'m mut [InputVector<'m>]>, control_messages: PhantomData>, } impl<'m> InputMessage<'m> { pub fn new( mut address: Option<&'m mut Option>, vectors: &'m mut [InputVector<'m>], control_messages: Option<&'m mut SocketControlMessages>, ) -> Self { let address = address .as_mut() .map(|a| { assert!(a.is_none()); *a as *mut _ as *mut _ }) .unwrap_or_else(ptr::null_mut); let (control_messages, num_control_messages) = control_messages .map(|c| (&mut c.ptr as *mut _, &mut c.len as *mut _)) .unwrap_or_else(|| (ptr::null_mut(), ptr::null_mut())); Self { message: ffi::GInputMessage { address, vectors: vectors.as_mut_ptr() as *mut ffi::GInputVector, num_vectors: vectors.len().try_into().unwrap(), bytes_received: 0, flags: 0, control_messages, num_control_messages, }, address: PhantomData, vectors: PhantomData, control_messages: PhantomData, } } #[inline] pub fn vectors(&mut self) -> &'m mut [InputVector<'m>] { unsafe { std::slice::from_raw_parts_mut( self.message.vectors as *mut _, self.message.num_vectors as usize, ) } } #[inline] pub const fn flags(&self) -> i32 { self.message.flags } #[inline] pub const fn bytes_received(&self) -> usize { self.message.bytes_received } } #[doc(alias = "GOutputVector")] #[repr(transparent)] #[derive(Debug)] pub struct OutputVector<'v> { vector: ffi::GOutputVector, buffer: PhantomData<&'v [u8]>, } impl<'v> OutputVector<'v> { #[inline] pub const fn new(buffer: &'v [u8]) -> Self { Self { vector: ffi::GOutputVector { buffer: buffer.as_ptr() as *const _, size: buffer.len(), }, buffer: PhantomData, } } } unsafe impl<'v> Send for OutputVector<'v> {} unsafe impl<'v> Sync for OutputVector<'v> {} impl<'v> std::ops::Deref for OutputVector<'v> { type Target = [u8]; #[inline] fn deref(&self) -> &Self::Target { unsafe { std::slice::from_raw_parts(self.vector.buffer as *const _, self.vector.size) } } } #[doc(alias = "GOutputMessage")] #[repr(transparent)] #[derive(Debug)] pub struct OutputMessage<'m> { message: ffi::GOutputMessage, address: PhantomData>, vectors: PhantomData<&'m [OutputVector<'m>]>, control_messages: PhantomData<&'m [SocketControlMessage]>, } impl<'m> OutputMessage<'m> { pub fn new>( address: Option<&'m A>, vectors: &'m [OutputVector<'m>], control_messages: &'m [SocketControlMessage], ) -> Self { Self { message: ffi::GOutputMessage { address: address .map(|a| a.upcast_ref::().as_ptr()) .unwrap_or_else(ptr::null_mut), vectors: mut_override(vectors.as_ptr() as *const ffi::GOutputVector), num_vectors: vectors.len().try_into().unwrap(), bytes_sent: 0, control_messages: control_messages.as_ptr() as *mut _, num_control_messages: control_messages.len().try_into().unwrap(), }, address: PhantomData, vectors: PhantomData, control_messages: PhantomData, } } #[inline] pub fn vectors(&self) -> &'m [OutputVector<'m>] { unsafe { std::slice::from_raw_parts( self.message.vectors as *const _, self.message.num_vectors as usize, ) } } #[inline] pub fn bytes_sent(&self) -> u32 { self.message.bytes_sent } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_socket_receive")] fn receive, C: IsA>( &self, mut buffer: B, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_receive( self.as_ref().to_glib_none().0, buffer_ptr, count, gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_receive_from")] fn receive_from, C: IsA>( &self, mut buffer: B, cancellable: Option<&C>, ) -> Result<(usize, SocketAddress), glib::Error> { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let mut addr_ptr = ptr::null_mut(); let ret = ffi::g_socket_receive_from( self.as_ref().to_glib_none().0, &mut addr_ptr, buffer_ptr, count, gcancellable.0, &mut error, ); if error.is_null() { Ok((ret as usize, from_glib_full(addr_ptr))) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_receive_message")] fn receive_message>( &self, mut address: Option<&mut Option>, vectors: &mut [InputVector], control_messages: Option<&mut SocketControlMessages>, mut flags: i32, cancellable: Option<&C>, ) -> Result<(usize, i32), glib::Error> { let cancellable = cancellable.map(|c| c.as_ref()); let address = address .as_mut() .map(|a| { assert!(a.is_none()); *a as *mut _ as *mut _ }) .unwrap_or_else(ptr::null_mut); let (control_messages, num_control_messages) = control_messages .map(|c| (&mut c.ptr as *mut _, &mut c.len as *mut _ as *mut _)) .unwrap_or_else(|| (ptr::null_mut(), ptr::null_mut())); unsafe { let mut error = ptr::null_mut(); let received = ffi::g_socket_receive_message( self.as_ref().to_glib_none().0, address, vectors.as_mut_ptr() as *mut ffi::GInputVector, vectors.len().try_into().unwrap(), control_messages, num_control_messages, &mut flags, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok((received as usize, flags)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_receive_messages")] fn receive_messages>( &self, messages: &mut [InputMessage], flags: i32, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let count = ffi::g_socket_receive_messages( self.as_ref().to_glib_none().0, messages.as_mut_ptr() as *mut _, messages.len().try_into().unwrap(), flags, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(count as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_receive_with_blocking")] fn receive_with_blocking, C: IsA>( &self, mut buffer: B, blocking: bool, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let buffer = buffer.as_mut(); let buffer_ptr = buffer.as_mut_ptr(); let count = buffer.len(); unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_receive_with_blocking( self.as_ref().to_glib_none().0, buffer_ptr, count, blocking.into_glib(), gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_send")] fn send, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_send( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_send_message")] fn send_message, C: IsA>( &self, address: Option<&P>, vectors: &[OutputVector], messages: &[SocketControlMessage], flags: i32, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_send_message( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, vectors.as_ptr() as *mut ffi::GOutputVector, vectors.len().try_into().unwrap(), messages.as_ptr() as *mut _, messages.len().try_into().unwrap(), flags, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_socket_send_message_with_timeout")] fn send_message_with_timeout, C: IsA>( &self, address: Option<&P>, vectors: &[OutputVector], messages: &[SocketControlMessage], flags: i32, timeout: Option, cancellable: Option<&C>, ) -> Result<(PollableReturn, usize), glib::Error> { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let mut bytes_written = 0; let ret = ffi::g_socket_send_message_with_timeout( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, vectors.as_ptr() as *mut ffi::GOutputVector, vectors.len().try_into().unwrap(), messages.as_ptr() as *mut _, messages.len().try_into().unwrap(), flags, timeout .map(|t| t.as_micros().try_into().unwrap()) .unwrap_or(-1), &mut bytes_written, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok((from_glib(ret), bytes_written)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_send_messages")] fn send_messages>( &self, messages: &mut [OutputMessage], flags: i32, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); unsafe { let mut error = ptr::null_mut(); let count = ffi::g_socket_send_messages( self.as_ref().to_glib_none().0, messages.as_mut_ptr() as *mut _, messages.len().try_into().unwrap(), flags, cancellable.to_glib_none().0, &mut error, ); if error.is_null() { Ok(count as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_send_to")] fn send_to, P: IsA, C: IsA>( &self, address: Option<&P>, buffer: B, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_send_to( self.as_ref().to_glib_none().0, address.map(|p| p.as_ref()).to_glib_none().0, mut_override(buffer_ptr), count, gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_socket_send_with_blocking")] fn send_with_blocking, C: IsA>( &self, buffer: B, blocking: bool, cancellable: Option<&C>, ) -> Result { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let (count, buffer_ptr) = { let slice = buffer.as_ref(); (slice.len(), slice.as_ptr()) }; unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_socket_send_with_blocking( self.as_ref().to_glib_none().0, mut_override(buffer_ptr), count, blocking.into_glib(), gcancellable.0, &mut error, ); if error.is_null() { Ok(ret as usize) } else { Err(from_glib_full(error)) } } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "get_fd")] #[doc(alias = "g_socket_get_fd")] fn fd(&self) -> T { unsafe { FromRawFd::from_raw_fd(ffi::g_socket_get_fd(self.as_ref().to_glib_none().0)) } } #[cfg(windows)] #[cfg_attr(docsrs, doc(cfg(windows)))] #[doc(alias = "get_socket")] #[doc(alias = "g_socket_get_fd")] fn socket(&self) -> T { unsafe { FromRawSocket::from_raw_socket(ffi::g_socket_get_fd(self.as_ref().to_glib_none().0) as _) } } #[doc(alias = "g_socket_create_source")] fn create_source( &self, condition: glib::IOCondition, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self, glib::IOCondition) -> glib::ControlFlow + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O, glib::IOCondition) -> glib::ControlFlow + 'static, >( socket: *mut ffi::GSocket, condition: glib::ffi::GIOCondition, func: glib::ffi::gpointer, ) -> glib::ffi::gboolean { let func: &RefCell = &*(func as *const RefCell); let mut func = func.borrow_mut(); (*func)( Socket::from_glib_borrow(socket).unsafe_cast_ref(), from_glib(condition), ) .into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { let _ = Box::>::from_raw(ptr as *mut _); } let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); unsafe { let source = ffi::g_socket_create_source( self.as_ref().to_glib_none().0, condition.into_glib(), gcancellable.0, ); let trampoline = trampoline:: as glib::ffi::gpointer; glib::ffi::g_source_set_callback( source, Some(transmute::< glib::ffi::gpointer, unsafe extern "C" fn(glib::ffi::gpointer) -> glib::ffi::gboolean, >(trampoline)), Box::into_raw(Box::new(RefCell::new(func))) as glib::ffi::gpointer, Some(destroy_closure::), ); glib::ffi::g_source_set_priority(source, priority.into_glib()); if let Some(name) = name { glib::ffi::g_source_set_name(source, name.to_glib_none().0); } from_glib_full(source) } } fn create_source_future>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceFuture::new(move |send| { let mut send = Some(send); obj.create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { let _ = send.take().unwrap().send(condition); glib::ControlFlow::Break }, ) })) } fn create_source_stream>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>> { let cancellable: Option = cancellable.map(|c| c.as_ref()).cloned(); let obj = self.clone(); Box::pin(glib::SourceStream::new(move |send| { let send = Some(send); obj.create_source( condition, cancellable.as_ref(), None, priority, move |_, condition| { if send.as_ref().unwrap().unbounded_send(condition).is_err() { glib::ControlFlow::Break } else { glib::ControlFlow::Continue } }, ) })) } } impl> SocketExtManual for O {} #[cfg(all(docsrs, not(unix)))] pub trait IntoRawFd { fn into_raw_fd(self) -> libc::c_int; } #[cfg(all(docsrs, not(unix)))] pub trait FromRawFd { unsafe fn from_raw_fd(fd: libc::c_int) -> Self; } #[cfg(all(docsrs, not(unix)))] pub trait AsRawFd { fn as_raw_fd(&self) -> RawFd; } #[cfg(all(docsrs, not(unix)))] pub type RawFd = libc::c_int; #[cfg(all(docsrs, not(windows)))] pub trait IntoRawSocket { fn into_raw_socket(self) -> u64; } #[cfg(all(docsrs, not(windows)))] pub trait FromRawSocket { unsafe fn from_raw_socket(sock: u64) -> Self; } #[cfg(all(docsrs, not(windows)))] pub trait AsRawSocket { fn as_raw_socket(&self) -> RawSocket; } #[cfg(all(docsrs, not(windows)))] pub type RawSocket = *mut std::os::raw::c_void; #[cfg(test)] mod tests { #[test] #[cfg(unix)] fn socket_messages() { use std::{io, os::unix::io::AsRawFd}; use super::Socket; use crate::{prelude::*, Cancellable, UnixFDMessage}; let mut fds = [0 as libc::c_int; 2]; let (out_sock, in_sock) = unsafe { let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr()); if ret != 0 { panic!("{}", io::Error::last_os_error()); } ( Socket::from_fd(fds[0]).unwrap(), Socket::from_fd(fds[1]).unwrap(), ) }; let fd_msg = UnixFDMessage::new(); fd_msg.append_fd(out_sock.as_raw_fd()).unwrap(); let vs = [super::OutputVector::new(&[0])]; let ctrl_msgs = [fd_msg.upcast()]; let mut out_msg = [super::OutputMessage::new( crate::SocketAddress::NONE, vs.as_slice(), ctrl_msgs.as_slice(), )]; let written = super::SocketExtManual::send_messages( &out_sock, out_msg.as_mut_slice(), 0, Cancellable::NONE, ) .unwrap(); assert_eq!(written, 1); assert_eq!(out_msg[0].bytes_sent(), 1); let mut v = [0u8]; let mut vs = [super::InputVector::new(v.as_mut_slice())]; let mut ctrl_msgs = super::SocketControlMessages::new(); let mut in_msg = [super::InputMessage::new( None, vs.as_mut_slice(), Some(&mut ctrl_msgs), )]; let received = super::SocketExtManual::receive_messages( &in_sock, in_msg.as_mut_slice(), 0, Cancellable::NONE, ) .unwrap(); assert_eq!(received, 1); assert_eq!(in_msg[0].bytes_received(), 1); assert_eq!(ctrl_msgs.len(), 1); let fds = ctrl_msgs[0] .downcast_ref::() .unwrap() .fd_list(); assert_eq!(fds.length(), 1); } #[test] #[cfg(unix)] fn dgram_socket_messages() { use super::Socket; use crate::{prelude::*, Cancellable}; let addr = crate::InetSocketAddress::from_string("127.0.0.1", 28351).unwrap(); let out_sock = Socket::new( crate::SocketFamily::Ipv4, crate::SocketType::Datagram, crate::SocketProtocol::Udp, ) .unwrap(); let in_sock = Socket::new( crate::SocketFamily::Ipv4, crate::SocketType::Datagram, crate::SocketProtocol::Udp, ) .unwrap(); in_sock.bind(&addr, true).unwrap(); const DATA: [u8; std::mem::size_of::()] = 1234u64.to_be_bytes(); let out_vec = DATA; let out_vecs = [super::OutputVector::new(out_vec.as_slice())]; let mut out_msg = [super::OutputMessage::new( Some(&addr), out_vecs.as_slice(), &[], )]; let written = super::SocketExtManual::send_messages( &out_sock, out_msg.as_mut_slice(), 0, Cancellable::NONE, ) .unwrap(); assert_eq!(written, 1); assert_eq!(out_msg[0].bytes_sent() as usize, out_vec.len()); let mut in_addr = None; let mut in_vec = [0u8; DATA.len()]; let mut in_vecs = [super::InputVector::new(in_vec.as_mut_slice())]; let mut in_msg = [super::InputMessage::new( Some(&mut in_addr), in_vecs.as_mut_slice(), None, )]; let received = super::SocketExtManual::receive_messages( &in_sock, in_msg.as_mut_slice(), 0, Cancellable::NONE, ) .unwrap(); assert_eq!(received, 1); assert_eq!(in_msg[0].bytes_received(), in_vec.len()); assert_eq!(in_vec, out_vec); let in_addr = in_addr .unwrap() .downcast::() .unwrap(); assert_eq!(in_addr.address().to_str(), addr.address().to_str()); } } gio-0.20.1/src/socket_control_message.rs000064400000000000000000000014351046102023000163560ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use crate::{prelude::*, SocketControlMessage}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait SocketControlMessageExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_socket_control_message_serialize")] fn serialize(&self, data: &mut [u8]) { assert!(data.len() >= self.size()); unsafe { crate::ffi::g_socket_control_message_serialize( self.as_ref().to_glib_none().0, data.as_mut_ptr() as *mut _, ); } } } impl> SocketControlMessageExtManual for O {} gio-0.20.1/src/socket_listener.rs000064400000000000000000000032721046102023000150200ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{pin::Pin, task::ready}; use futures_core::{ stream::Stream, task::{Context, Poll}, Future, }; use crate::{prelude::SocketListenerExt, SocketConnection, SocketListener}; use glib::{prelude::*, Error, Object}; pub struct Incoming { listener: SocketListener, fut: Option), Error>>>>>, } impl Stream for Incoming { type Item = Result<(SocketConnection, Option), Error>; fn poll_next(mut self: Pin<&mut Self>, ctx: &mut Context<'_>) -> Poll> { if self.fut.is_none() { self.fut = Some(self.listener.accept_future()); } let fut = self.fut.as_mut().unwrap(); let res = ready!(Pin::new(fut).poll(ctx)); self.fut.take(); Poll::Ready(Some(res)) } } pub trait SocketListenerExtManual: SocketListenerExt { // rustdoc-stripper-ignore-next /// Returns a stream of incoming connections /// /// Iterating over this stream is equivalent to calling [`SocketListenerExt::accept_future`] in a /// loop. The stream of connections is infinite, i.e awaiting the next /// connection will never result in [`None`]. fn incoming( &self, ) -> Pin), Error>>>>; } impl> SocketListenerExtManual for O { fn incoming( &self, ) -> Pin), Error>>>> { Box::pin(Incoming { listener: self.as_ref().clone(), fut: None, }) } } gio-0.20.1/src/socket_msg_flags.rs000064400000000000000000000037521046102023000151400ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ffi; use glib::{bitflags, prelude::*, translate::*, Type}; bitflags::bitflags! { #[doc(alias = "GSocketMsgFlags")] #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] pub struct SocketMsgFlags: ffi::GSocketMsgFlags { #[doc(alias = "G_SOCKET_MSG_NONE")] const NONE = ffi::G_SOCKET_MSG_NONE as _; #[doc(alias = "G_SOCKET_MSG_OOB")] const OOB = ffi::G_SOCKET_MSG_OOB as _; #[doc(alias = "G_SOCKET_MSG_PEEK")] const PEEK = ffi::G_SOCKET_MSG_PEEK as _; #[doc(alias = "G_SOCKET_MSG_DONTROUTE")] const DONTROUTE = ffi::G_SOCKET_MSG_DONTROUTE as _; } } #[doc(hidden)] impl IntoGlib for SocketMsgFlags { type GlibType = ffi::GSocketMsgFlags; #[inline] fn into_glib(self) -> ffi::GSocketMsgFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SocketMsgFlags { #[inline] unsafe fn from_glib(value: ffi::GSocketMsgFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for SocketMsgFlags { #[inline] fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_msg_flags_get_type()) } } } impl glib::value::ValueType for SocketMsgFlags { type Type = Self; } unsafe impl<'a> glib::value::FromValue<'a> for SocketMsgFlags { type Checker = glib::value::GenericValueTypeChecker; unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_flags(value.to_glib_none().0) as i32) } } impl ToValue for SocketMsgFlags { fn to_value(&self) -> glib::Value { let mut value = glib::Value::for_value_type::(); unsafe { glib::gobject_ffi::g_value_set_flags( value.to_glib_none_mut().0, self.into_glib() as u32, ); } value } fn value_type(&self) -> glib::Type { Self::static_type() } } gio-0.20.1/src/subclass/action_group.rs000064400000000000000000000611531046102023000161350ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{mem, ptr, sync::OnceLock}; use glib::{prelude::*, subclass::prelude::*, translate::*, GString, Quark, Variant, VariantType}; use crate::{ffi, ActionGroup}; pub trait ActionGroupImpl: ObjectImpl { fn action_added(&self, action_name: &str) { self.parent_action_added(action_name); } fn action_enabled_changed(&self, action_name: &str, enabled: bool) { self.parent_action_enabled_changed(action_name, enabled); } fn action_removed(&self, action_name: &str) { self.parent_action_removed(action_name); } fn action_state_changed(&self, action_name: &str, state: &Variant) { self.parent_action_state_changed(action_name, state); } fn activate_action(&self, action_name: &str, parameter: Option<&Variant>) { self.parent_activate_action(action_name, parameter); } fn change_action_state(&self, action_name: &str, value: &Variant) { self.parent_change_action_state(action_name, value) } #[doc(alias = "get_action_enabled")] fn action_is_enabled(&self, action_name: &str) -> bool { self.parent_action_is_enabled(action_name) } #[doc(alias = "get_action_parameter_type")] fn action_parameter_type(&self, action_name: &str) -> Option { self.parent_action_parameter_type(action_name) } #[doc(alias = "get_action_state")] fn action_state(&self, action_name: &str) -> Option { self.parent_action_state(action_name) } #[doc(alias = "get_action_state_hint")] fn action_state_hint(&self, action_name: &str) -> Option { self.parent_action_state_hint(action_name) } #[doc(alias = "get_action_state_type")] fn action_state_type(&self, action_name: &str) -> Option { self.parent_action_state_type(action_name) } fn has_action(&self, action_name: &str) -> bool { self.parent_has_action(action_name) } fn list_actions(&self) -> Vec; fn query_action( &self, action_name: &str, ) -> Option<( bool, Option, Option, Option, Option, )>; } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait ActionGroupImplExt: sealed::Sealed + ObjectSubclass { fn parent_action_added(&self, action_name: &str) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; if let Some(func) = (*parent_iface).action_added { func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); } } } fn parent_action_enabled_changed(&self, action_name: &str, enabled: bool) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; if let Some(func) = (*parent_iface).action_enabled_changed { func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, enabled.into_glib(), ); } } } fn parent_action_removed(&self, action_name: &str) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; if let Some(func) = (*parent_iface).action_removed { func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); } } } fn parent_action_state_changed(&self, action_name: &str, state: &Variant) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; if let Some(func) = (*parent_iface).action_state_changed { func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, state.to_glib_none().0, ); } } } fn parent_activate_action(&self, action_name: &str, parameter: Option<&Variant>) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .activate_action .expect("no parent \"activate_action\" implementation"); func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, parameter.to_glib_none().0, ); } } fn parent_change_action_state(&self, action_name: &str, value: &Variant) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .change_action_state .expect("no parent \"change_action_state\" implementation"); func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, value.to_glib_none().0, ); } } fn parent_action_is_enabled(&self, action_name: &str) -> bool { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .get_action_enabled .expect("no parent \"action_is_enabled\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib(ret) } } fn parent_action_parameter_type(&self, action_name: &str) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .get_action_parameter_type .expect("no parent \"get_action_parameter_type\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state(&self, action_name: &str) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .get_action_state .expect("no parent \"get_action_state\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state_hint(&self, action_name: &str) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .get_action_state_hint .expect("no parent \"get_action_state_hint\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state_type(&self, action_name: &str) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .get_action_state_type .expect("no parent \"get_action_state_type\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_has_action(&self, action_name: &str) -> bool { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .has_action .expect("no parent \"has_action\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); from_glib(ret) } } fn parent_list_actions(&self) -> Vec { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .list_actions .expect("no parent \"list_actions\" implementation"); let ret = func(self.obj().unsafe_cast_ref::().to_glib_none().0); FromGlibPtrContainer::from_glib_none(ret) } } fn parent_query_action( &self, action_name: &str, ) -> Option<( bool, Option, Option, Option, Option, )> { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionGroupInterface; let func = (*parent_iface) .query_action .expect("no parent \"query_action\" implementation"); let mut enabled = mem::MaybeUninit::uninit(); let mut parameter_type = ptr::null(); let mut state_type = ptr::null(); let mut state_hint = ptr::null_mut(); let mut state = ptr::null_mut(); let ret: bool = from_glib(func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, enabled.as_mut_ptr(), &mut parameter_type, &mut state_type, &mut state_hint, &mut state, )); if !ret { None } else { Some(( from_glib(enabled.assume_init()), from_glib_none(parameter_type), from_glib_none(state_type), from_glib_none(state_hint), from_glib_none(state), )) } } } } impl ActionGroupImplExt for T {} unsafe impl IsImplementable for ActionGroup { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.action_added = Some(action_group_action_added::); iface.action_enabled_changed = Some(action_group_action_enabled_changed::); iface.action_removed = Some(action_group_action_removed::); iface.action_state_changed = Some(action_group_action_state_changed::); iface.activate_action = Some(action_group_activate_action::); iface.change_action_state = Some(action_group_change_action_state::); iface.get_action_enabled = Some(action_group_get_action_enabled::); iface.get_action_parameter_type = Some(action_group_get_action_parameter_type::); iface.get_action_state = Some(action_group_get_action_state::); iface.get_action_state_hint = Some(action_group_get_action_state_hint::); iface.get_action_state_type = Some(action_group_get_action_state_type::); iface.has_action = Some(action_group_has_action::); iface.list_actions = Some(action_group_list_actions::); iface.query_action = Some(action_group_query_action::); } } unsafe extern "C" fn action_group_has_action( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let action_name = GString::from_glib_borrow(action_nameptr); let imp = instance.imp(); imp.has_action(&action_name).into_glib() } unsafe extern "C" fn action_group_get_action_enabled( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_is_enabled(&action_name).into_glib() } // rustdoc-stripper-ignore-next /// Struct to hold a pointer and free it on `Drop::drop` struct PtrHolder(*mut T, F); impl Drop for PtrHolder { fn drop(&mut self) { (self.1)(self.0) } } unsafe extern "C" fn action_group_get_action_parameter_type( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> *const glib::ffi::GVariantType { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.action_parameter_type(&action_name); if let Some(param_type) = ret { let parameter_type_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-get-action-parameter") }) }; let param_type = param_type.into_glib_ptr(); wrap.set_qdata( parameter_type_quark, PtrHolder(param_type, |ptr| glib::ffi::g_free(ptr as *mut _)), ); param_type } else { ptr::null() } } unsafe extern "C" fn action_group_get_action_state_type( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> *const glib::ffi::GVariantType { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let ret = imp.action_state_type(&action_name); if let Some(state_type) = ret { let instance = imp.obj(); let state_type_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-get-action-state-type") }) }; let state_type = state_type.into_glib_ptr(); instance.set_qdata( state_type_quark, PtrHolder(state_type, |ptr| glib::ffi::g_free(ptr as *mut _)), ); state_type } else { ptr::null() } } unsafe extern "C" fn action_group_get_action_state_hint( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> *mut glib::ffi::GVariant { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let ret = imp.action_state_hint(&action_name); if let Some(state_hint) = ret { let instance = imp.obj(); let state_hint_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-get-action-state-hint") }) }; let state_hint_ptr = state_hint.into_glib_ptr(); instance.set_qdata( state_hint_quark, PtrHolder(state_hint_ptr, |ptr| glib::ffi::g_variant_unref(ptr)), ); state_hint_ptr } else { ptr::null_mut() } } unsafe extern "C" fn action_group_get_action_state( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) -> *mut glib::ffi::GVariant { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let ret = imp.action_state(&action_name); if let Some(state) = ret { let instance = imp.obj(); let state_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| Quark::from_str("gtk-rs-subclass-action-group-get-action-state")) }; let state_ptr = state.into_glib_ptr(); instance.set_qdata( state_quark, PtrHolder(state_ptr, |ptr| glib::ffi::g_variant_unref(ptr)), ); state_ptr } else { ptr::null_mut() } } unsafe extern "C" fn action_group_change_action_state( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let state = Variant::from_glib_borrow(stateptr); imp.change_action_state(&action_name, &state) } unsafe extern "C" fn action_group_activate_action( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, parameterptr: *mut glib::ffi::GVariant, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let param: Borrowed> = from_glib_borrow(parameterptr); imp.activate_action(&action_name, param.as_ref().as_ref()) } unsafe extern "C" fn action_group_action_added( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_added(&action_name) } unsafe extern "C" fn action_group_action_removed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_removed(&action_name) } unsafe extern "C" fn action_group_action_enabled_changed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, enabled: glib::ffi::gboolean, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_enabled_changed(&action_name, from_glib(enabled)) } unsafe extern "C" fn action_group_action_state_changed( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, stateptr: *mut glib::ffi::GVariant, ) { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let state = Variant::from_glib_borrow(stateptr); imp.action_state_changed(&action_name, &state) } unsafe extern "C" fn action_group_list_actions( action_group: *mut ffi::GActionGroup, ) -> *mut *mut libc::c_char { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let actions = imp.list_actions(); { let instance = imp.obj(); let actions_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| Quark::from_str("gtk-rs-subclass-action-group-list-actions")) }; let actionsptr = actions.to_glib_full(); instance.set_qdata(actions_quark, actionsptr); actionsptr } } unsafe extern "C" fn action_group_query_action( action_group: *mut ffi::GActionGroup, action_nameptr: *const libc::c_char, enabled: *mut glib::ffi::gboolean, parameter_type: *mut *const glib::ffi::GVariantType, state_type: *mut *const glib::ffi::GVariantType, state_hint: *mut *mut glib::ffi::GVariant, state: *mut *mut glib::ffi::GVariant, ) -> glib::ffi::gboolean { let instance = &*(action_group as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); let ret = imp.query_action(&action_name); if let Some((rs_enabled, rs_parameter_type, rs_state_type, rs_state_hint, rs_state)) = ret { let instance = imp.obj(); if !enabled.is_null() { *enabled = rs_enabled.into_glib(); } if !parameter_type.is_null() { if let Some(rs_parameter_type) = rs_parameter_type { let param_type_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-query-action-parameter-type") }) }; let ret = rs_parameter_type.into_glib_ptr(); instance.set_qdata( param_type_quark, PtrHolder(ret, |ptr| glib::ffi::g_free(ptr as *mut _)), ); *parameter_type = ret; } else { *parameter_type = ptr::null_mut(); } } if !state_type.is_null() { if let Some(rs_state_type) = rs_state_type { let state_type_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-query-action-state-type") }) }; let ret = rs_state_type.into_glib_ptr(); instance.set_qdata( state_type_quark, PtrHolder(ret, |ptr| glib::ffi::g_free(ptr as *mut _)), ); *state_type = ret; } else { *state_type = ptr::null_mut(); } } if !state_hint.is_null() { if let Some(rs_state_hint) = rs_state_hint { let state_hint_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-query-action-state-hint") }) }; let ret = rs_state_hint.into_glib_ptr(); instance.set_qdata( state_hint_quark, PtrHolder(ret, |ptr| glib::ffi::g_variant_unref(ptr)), ); *state_hint = ret; } else { *state_hint = ptr::null_mut(); } } if !state.is_null() { if let Some(rs_state) = rs_state { let state_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| { Quark::from_str("gtk-rs-subclass-action-group-query-action-state") }) }; let ret = rs_state.into_glib_ptr(); instance.set_qdata( state_quark, PtrHolder(ret, |ptr| glib::ffi::g_variant_unref(ptr)), ); *state = ret; } else { *state = ptr::null_mut(); } } true } else { false } .into_glib() } gio-0.20.1/src/subclass/action_map.rs000064400000000000000000000105531046102023000155540ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{collections::HashMap, sync::OnceLock}; use glib::{prelude::*, subclass::prelude::*, translate::*, GString, Quark}; use crate::{ffi, Action, ActionMap}; pub trait ActionMapImpl: ObjectImpl { fn lookup_action(&self, action_name: &str) -> Option; fn add_action(&self, action: &Action); fn remove_action(&self, action_name: &str); } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait ActionMapImplExt: sealed::Sealed + ObjectSubclass { fn parent_lookup_action(&self, name: &str) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionMapInterface; let func = (*parent_iface) .lookup_action .expect("no parent \"lookup_action\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_add_action(&self, action: &Action) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionMapInterface; let func = (*parent_iface) .add_action .expect("no parent \"add_action\" implementation"); func( self.obj().unsafe_cast_ref::().to_glib_none().0, action.to_glib_none().0, ); } } fn parent_remove_action(&self, action_name: &str) { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GActionMapInterface; let func = (*parent_iface) .remove_action .expect("no parent \"remove_action\" implementation"); func( self.obj().unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); } } } impl ActionMapImplExt for T {} unsafe impl IsImplementable for ActionMap where ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.lookup_action = Some(action_map_lookup_action::); iface.add_action = Some(action_map_add_action::); iface.remove_action = Some(action_map_remove_action::); } } unsafe extern "C" fn action_map_lookup_action( action_map: *mut ffi::GActionMap, action_nameptr: *const libc::c_char, ) -> *mut ffi::GAction { let instance = &*(action_map as *mut T::Instance); let action_name = GString::from_glib_borrow(action_nameptr); let imp = instance.imp(); let ret = imp.lookup_action(&action_name); if let Some(action) = ret { let instance = imp.obj(); let actionptr = action.to_glib_none().0; let action_map_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| Quark::from_str("gtk-rs-subclass-action-map-lookup-action")) }; let mut map = instance .steal_qdata::>(action_map_quark) .unwrap_or_default(); map.insert(action_name.to_string(), action); instance.set_qdata(action_map_quark, map); actionptr } else { std::ptr::null_mut() } } unsafe extern "C" fn action_map_add_action( action_map: *mut ffi::GActionMap, actionptr: *mut ffi::GAction, ) { let instance = &*(action_map as *mut T::Instance); let imp = instance.imp(); let action: Borrowed = from_glib_borrow(actionptr); imp.add_action(&action); } unsafe extern "C" fn action_map_remove_action( action_map: *mut ffi::GActionMap, action_nameptr: *const libc::c_char, ) { let instance = &*(action_map as *mut T::Instance); let imp = instance.imp(); let action_name = GString::from_glib_borrow(action_nameptr); imp.remove_action(&action_name); } gio-0.20.1/src/subclass/application.rs000064400000000000000000000361221046102023000157450ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ffi::OsString, fmt, ops::Deref, ptr}; use glib::{prelude::*, subclass::prelude::*, translate::*, ExitCode, VariantDict}; use libc::{c_char, c_int, c_void}; use crate::{ffi, Application}; pub struct ArgumentList { pub(crate) ptr: *mut *mut *mut c_char, items: Vec, } impl ArgumentList { pub(crate) fn new(arguments: *mut *mut *mut c_char) -> Self { Self { ptr: arguments, items: unsafe { FromGlibPtrContainer::from_glib_none(ptr::read(arguments)) }, } } pub(crate) fn refresh(&mut self) { self.items = unsafe { FromGlibPtrContainer::from_glib_none(ptr::read(self.ptr)) }; } // remove the item at index `idx` and shift the raw array pub fn remove(&mut self, idx: usize) { unsafe { let n_args = glib::ffi::g_strv_length(*self.ptr) as usize; assert_eq!(n_args, self.items.len()); assert!(idx < n_args); self.items.remove(idx); glib::ffi::g_free(*(*self.ptr).add(idx) as *mut c_void); for i in idx..n_args - 1 { ptr::write((*self.ptr).add(i), *(*self.ptr).add(i + 1)) } ptr::write((*self.ptr).add(n_args - 1), ptr::null_mut()); } } } impl Deref for ArgumentList { type Target = [OsString]; #[inline] fn deref(&self) -> &Self::Target { self.items.as_slice() } } impl fmt::Debug for ArgumentList { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { self.items.fmt(formatter) } } impl From for Vec { fn from(list: ArgumentList) -> Vec { list.items } } pub trait ApplicationImpl: ObjectImpl + ApplicationImplExt { fn activate(&self) { self.parent_activate() } fn after_emit(&self, platform_data: &glib::Variant) { self.parent_after_emit(platform_data) } fn before_emit(&self, platform_data: &glib::Variant) { self.parent_before_emit(platform_data) } fn command_line(&self, command_line: &crate::ApplicationCommandLine) -> ExitCode { self.parent_command_line(command_line) } fn local_command_line(&self, arguments: &mut ArgumentList) -> Option { self.parent_local_command_line(arguments) } fn open(&self, files: &[crate::File], hint: &str) { self.parent_open(files, hint) } fn quit_mainloop(&self) { self.parent_quit_mainloop() } fn run_mainloop(&self) { self.parent_run_mainloop() } fn shutdown(&self) { self.parent_shutdown() } fn startup(&self) { self.parent_startup() } fn handle_local_options(&self, options: &VariantDict) -> ExitCode { self.parent_handle_local_options(options) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait ApplicationImplExt: sealed::Sealed + ObjectSubclass { fn parent_activate(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .activate .expect("No parent class implementation for \"activate\""); f(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_after_emit(&self, platform_data: &glib::Variant) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .after_emit .expect("No parent class implementation for \"after_emit\""); f( self.obj().unsafe_cast_ref::().to_glib_none().0, platform_data.to_glib_none().0, ) } } fn parent_before_emit(&self, platform_data: &glib::Variant) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .before_emit .expect("No parent class implementation for \"before_emit\""); f( self.obj().unsafe_cast_ref::().to_glib_none().0, platform_data.to_glib_none().0, ) } } fn parent_command_line(&self, command_line: &crate::ApplicationCommandLine) -> ExitCode { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .command_line .expect("No parent class implementation for \"command_line\""); f( self.obj().unsafe_cast_ref::().to_glib_none().0, command_line.to_glib_none().0, ) .into() } } fn parent_local_command_line(&self, arguments: &mut ArgumentList) -> Option { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .local_command_line .expect("No parent class implementation for \"local_command_line\""); let mut exit_status = 0; let res = f( self.obj().unsafe_cast_ref::().to_glib_none().0, arguments.ptr, &mut exit_status, ); arguments.refresh(); match res { glib::ffi::GFALSE => None, _ => Some(exit_status.into()), } } } fn parent_open(&self, files: &[crate::File], hint: &str) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .open .expect("No parent class implementation for \"open\""); f( self.obj().unsafe_cast_ref::().to_glib_none().0, files.to_glib_none().0, files.len() as i32, hint.to_glib_none().0, ) } } fn parent_quit_mainloop(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .quit_mainloop .expect("No parent class implementation for \"quit_mainloop\""); f(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_run_mainloop(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .run_mainloop .expect("No parent class implementation for \"run_mainloop\""); f(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_shutdown(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .shutdown .expect("No parent class implementation for \"shutdown\""); f(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_startup(&self) { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; let f = (*parent_class) .startup .expect("No parent class implementation for \"startup\""); f(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_handle_local_options(&self, options: &VariantDict) -> ExitCode { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; if let Some(f) = (*parent_class).handle_local_options { f( self.obj().unsafe_cast_ref::().to_glib_none().0, options.to_glib_none().0, ) .into() } else { // Continue default handling ExitCode::from(-1) } } } } impl ApplicationImplExt for T {} unsafe impl IsSubclassable for Application { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.activate = Some(application_activate::); klass.after_emit = Some(application_after_emit::); klass.before_emit = Some(application_before_emit::); klass.command_line = Some(application_command_line::); klass.local_command_line = Some(application_local_command_line::); klass.open = Some(application_open::); klass.quit_mainloop = Some(application_quit_mainloop::); klass.run_mainloop = Some(application_run_mainloop::); klass.shutdown = Some(application_shutdown::); klass.startup = Some(application_startup::); klass.handle_local_options = Some(application_handle_local_options::); } } unsafe extern "C" fn application_activate(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.activate() } unsafe extern "C" fn application_after_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.after_emit(&from_glib_borrow(platform_data)) } unsafe extern "C" fn application_before_emit( ptr: *mut ffi::GApplication, platform_data: *mut glib::ffi::GVariant, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.before_emit(&from_glib_borrow(platform_data)) } unsafe extern "C" fn application_command_line( ptr: *mut ffi::GApplication, command_line: *mut ffi::GApplicationCommandLine, ) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.command_line(&from_glib_borrow(command_line)).into() } unsafe extern "C" fn application_local_command_line( ptr: *mut ffi::GApplication, arguments: *mut *mut *mut c_char, exit_status: *mut i32, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let mut args = ArgumentList::new(arguments); let res = imp.local_command_line(&mut args).map(i32::from); args.refresh(); match res { Some(ret) => { *exit_status = ret; glib::ffi::GTRUE } None => glib::ffi::GFALSE, } } unsafe extern "C" fn application_open( ptr: *mut ffi::GApplication, files: *mut *mut ffi::GFile, num_files: i32, hint: *const c_char, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let files: Vec = FromGlibContainer::from_glib_none_num(files, num_files as usize); imp.open(files.as_slice(), &glib::GString::from_glib_borrow(hint)) } unsafe extern "C" fn application_quit_mainloop(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.quit_mainloop() } unsafe extern "C" fn application_run_mainloop(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.run_mainloop() } unsafe extern "C" fn application_shutdown(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.shutdown() } unsafe extern "C" fn application_startup(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.startup() } unsafe extern "C" fn application_handle_local_options( ptr: *mut ffi::GApplication, options: *mut glib::ffi::GVariantDict, ) -> c_int { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.handle_local_options(&from_glib_borrow(options)).into() } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; const EXIT_STATUS: i32 = 20; mod imp { use super::*; #[derive(Default)] pub struct SimpleApplication; #[glib::object_subclass] impl ObjectSubclass for SimpleApplication { const NAME: &'static str = "SimpleApplication"; type Type = super::SimpleApplication; type ParentType = Application; } impl ObjectImpl for SimpleApplication {} impl ApplicationImpl for SimpleApplication { fn command_line(&self, _cmd_line: &crate::ApplicationCommandLine) -> ExitCode { #[cfg(not(target_os = "windows"))] { let arguments = _cmd_line.arguments(); // NOTE: on windows argc and argv are ignored, even if the arguments // were passed explicitly. // // Source: https://gitlab.gnome.org/GNOME/glib/-/blob/e64a93269d09302d7a4facbc164b7fe9c2ad0836/gio/gapplication.c#L2513-2515 assert_eq!(arguments.to_vec(), &["--global-1", "--global-2"]); }; EXIT_STATUS.into() } fn local_command_line(&self, arguments: &mut ArgumentList) -> Option { let mut rm = Vec::new(); for (i, line) in arguments.iter().enumerate() { // TODO: we need https://github.com/rust-lang/rust/issues/49802 let l = line.to_str().unwrap(); if l.starts_with("--local-") { rm.push(i) } } rm.reverse(); for i in rm.iter() { arguments.remove(*i); } None } } } glib::wrapper! { pub struct SimpleApplication(ObjectSubclass) @implements crate::Application; } #[test] fn test_simple_application() { let app = glib::Object::builder::() .property("application-id", "org.gtk-rs.SimpleApplication") .property("flags", crate::ApplicationFlags::empty()) .build(); app.set_inactivity_timeout(10000); assert_eq!( app.run_with_args(&["--local-1", "--global-1", "--local-2", "--global-2"]), EXIT_STATUS.into() ); } } gio-0.20.1/src/subclass/async_initable.rs000064400000000000000000000313131046102023000164230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{future::Future, pin::Pin, ptr}; use glib::{prelude::*, subclass::prelude::*, thread_guard::ThreadGuard, translate::*, Error}; use crate::{ ffi, AsyncInitable, AsyncResult, Cancellable, CancellableFuture, GioFutureResult, LocalTask, }; pub trait AsyncInitableImpl: ObjectImpl { fn init_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { self.parent_init_future(io_priority) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait AsyncInitableImplExt: sealed::Sealed + AsyncInitableImpl + ObjectSubclass { fn parent_init_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>> { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GAsyncInitableIface; let init_async = (*parent_iface) .init_async .expect("no parent \"init_async\" implementation"); unsafe extern "C" fn parent_init_future_callback( source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) where T: AsyncInitableImpl, { let type_data = T::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GAsyncInitableIface; let init_finish = (*parent_iface) .init_finish .expect("no parent \"init_finish\" implementation"); let r: Box>>> = Box::from_raw(user_data as *mut _); let r = r.into_inner(); let mut error = ptr::null_mut(); init_finish(source_object as *mut _, res, &mut error); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; r.resolve(result); } Box::pin(crate::GioFuture::new( &*self.obj(), move |obj, cancellable, res| { let user_data: Box>>> = Box::new(ThreadGuard::new(res)); let user_data = Box::into_raw(user_data); init_async( obj.unsafe_cast_ref::().to_glib_none().0, io_priority.into_glib(), cancellable.to_glib_none().0, Some(parent_init_future_callback::), user_data as *mut _, ); }, )) } } } impl AsyncInitableImplExt for T {} unsafe impl IsImplementable for AsyncInitable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.init_async = Some(async_initable_init_async::); iface.init_finish = Some(async_initable_init_finish); } } unsafe extern "C" fn async_initable_init_async( initable: *mut ffi::GAsyncInitable, io_priority: std::os::raw::c_int, cancellable: *mut ffi::GCancellable, callback: ffi::GAsyncReadyCallback, user_data: glib::ffi::gpointer, ) { let instance = &*(initable as *mut T::Instance); let imp = instance.imp(); let cancellable = Option::::from_glib_none(cancellable); let task = callback.map(|callback| { let task = LocalTask::new( Some(imp.obj().unsafe_cast_ref::()), cancellable.as_ref(), move |task, obj| { let result: *mut crate::ffi::GAsyncResult = task.upcast_ref::().to_glib_none().0; let obj: *mut glib::gobject_ffi::GObject = obj.to_glib_none().0; callback(obj, result, user_data); }, ); task.set_check_cancellable(true); task.set_return_on_cancel(true); task }); glib::MainContext::ref_thread_default().spawn_local(async move { let io_priority = from_glib(io_priority); let res = if let Some(cancellable) = cancellable { CancellableFuture::new(imp.init_future(io_priority), cancellable) .await .map_err(|cancelled| cancelled.into()) .and_then(|res| res) } else { imp.init_future(io_priority).await }; if let Some(task) = task { task.return_result(res.map(|_t| true)); } }); } unsafe extern "C" fn async_initable_init_finish( initable: *mut ffi::GAsyncInitable, res: *mut ffi::GAsyncResult, error: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let res = from_glib_none::<_, AsyncResult>(res); let task = res .downcast::>() .expect("GAsyncResult is not a GTask"); if !LocalTask::::is_valid( &task, Some(from_glib_borrow::<_, AsyncInitable>(initable).as_ref()), ) { panic!("Task is not valid for source object"); } match task.propagate() { Ok(v) => { debug_assert!(v); true.into_glib() } Err(e) => { if !error.is_null() { *error = e.into_glib_ptr(); } false.into_glib() } } } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; pub mod imp { use std::cell::Cell; use super::*; pub struct AsyncInitableTestType(pub Cell); #[glib::object_subclass] impl ObjectSubclass for AsyncInitableTestType { const NAME: &'static str = "AsyncInitableTestType"; type Type = super::AsyncInitableTestType; type Interfaces = (AsyncInitable,); fn new() -> Self { Self(Cell::new(0)) } } impl AsyncInitableImpl for AsyncInitableTestType { fn init_future( &self, _io_priority: glib::Priority, ) -> Pin> + 'static>> { let imp = glib::subclass::ObjectImplRef::new(self); Box::pin(async move { glib::timeout_future_seconds(0).await; imp.0.set(0x123456789abcdef); Ok(()) }) } } impl ObjectImpl for AsyncInitableTestType {} } pub mod ffi { use super::*; pub type AsyncInitableTestType = ::Instance; pub unsafe extern "C" fn async_initable_test_type_get_value( this: *mut AsyncInitableTestType, ) -> u64 { let this = super::AsyncInitableTestType::from_glib_borrow(this); this.imp().0.get() } } glib::wrapper! { pub struct AsyncInitableTestType(ObjectSubclass) @implements AsyncInitable; } #[allow(clippy::new_without_default)] impl AsyncInitableTestType { pub async fn new() -> Self { AsyncInitable::new_future(glib::Priority::default()) .await .expect("Failed creation/initialization of AsyncInitableTestType object") } pub unsafe fn new_uninit() -> Self { // This creates an uninitialized AsyncInitableTestType object, for testing // purposes. In real code, using AsyncInitable::new_future (like the new() method // does) is recommended. glib::Object::new_internal(Self::static_type(), &mut []) .downcast() .unwrap() } pub fn value(&self) -> u64 { self.imp().0.get() } } #[test] fn test_async_initable_with_init() { glib::MainContext::new().block_on(async { let res = unsafe { let test = AsyncInitableTestType::new_uninit(); assert_ne!(0x123456789abcdef, test.value()); test.init_future(glib::Priority::default()) .await .map(|_| test) }; assert!(res.is_ok()); let test = res.unwrap(); assert_eq!(0x123456789abcdef, test.value()); }); } #[test] fn test_async_initable_with_initable_new() { glib::MainContext::new().block_on(async { let test = AsyncInitableTestType::new().await; assert_eq!(0x123456789abcdef, test.value()); }); } #[test] #[should_panic = ""] fn test_async_initable_new_failure() { glib::MainContext::new().block_on(async { let value: u32 = 2; let _ = AsyncInitable::builder::() .property("invalid-property", value) .build_future(glib::Priority::default()) .await; unreachable!(); }); } #[test] fn test_async_initable_with_initable_with_type() { glib::MainContext::new().block_on(async { let test = AsyncInitable::with_type_future( AsyncInitableTestType::static_type(), glib::Priority::default(), ) .await .expect("Failed creation/initialization of AsyncInitableTestType object from type") .downcast::() .expect("Failed downcast of AsyncInitableTestType object"); assert_eq!(0x123456789abcdef, test.value()); }); } #[test] fn test_async_initable_with_async_initable_with_values() { glib::MainContext::new().block_on(async { let test = AsyncInitable::with_type_future( AsyncInitableTestType::static_type(), glib::Priority::default(), ) .await .expect("Failed creation/initialization of AsyncInitableTestType object from values") .downcast::() .expect("Failed downcast of AsyncInitableTestType object"); assert_eq!(0x123456789abcdef, test.value()); }); } #[test] fn test_async_initable_through_ffi() { use futures_channel::oneshot; glib::MainContext::new().block_on(async { unsafe { let test = AsyncInitableTestType::new_uninit(); let test: *mut ffi::AsyncInitableTestType = test.as_ptr(); assert_ne!( 0x123456789abcdef, ffi::async_initable_test_type_get_value(test) ); let (tx, rx) = oneshot::channel::>(); let user_data = Box::new(ThreadGuard::new(tx)); unsafe extern "C" fn init_async_callback( source_object: *mut glib::gobject_ffi::GObject, res: *mut crate::ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let tx: Box>>> = Box::from_raw(user_data as *mut _); let tx = tx.into_inner(); let mut error = ptr::null_mut(); let ret = crate::ffi::g_async_initable_init_finish( source_object as *mut _, res, &mut error, ); assert_eq!(ret, glib::ffi::GTRUE); let result = if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }; tx.send(result).unwrap(); } crate::ffi::g_async_initable_init_async( test as *mut crate::ffi::GAsyncInitable, glib::ffi::G_PRIORITY_DEFAULT, std::ptr::null_mut(), Some(init_async_callback), Box::into_raw(user_data) as *mut _, ); let result = rx.await.unwrap(); assert!(result.is_ok()); assert_eq!( 0x123456789abcdef, ffi::async_initable_test_type_get_value(test) ); } }); } } gio-0.20.1/src/subclass/initable.rs000064400000000000000000000150311046102023000152250ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, Initable}; pub trait InitableImpl: ObjectImpl { fn init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_init(cancellable) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait InitableImplExt: sealed::Sealed + ObjectSubclass { fn parent_init(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GInitableIface; let func = (*parent_iface) .init .expect("no parent \"init\" implementation"); let mut err = ptr::null_mut(); func( self.obj().unsafe_cast_ref::().to_glib_none().0, cancellable.to_glib_none().0, &mut err, ); if err.is_null() { Ok(()) } else { Err(from_glib_full(err)) } } } } impl InitableImplExt for T {} unsafe impl IsImplementable for Initable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.init = Some(initable_init::); } } unsafe extern "C" fn initable_init( initable: *mut ffi::GInitable, cancellable: *mut ffi::GCancellable, error: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(initable as *mut T::Instance); let imp = instance.imp(); match imp.init( Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(()) => glib::ffi::GTRUE, Err(e) => { if !error.is_null() { *error = e.into_glib_ptr(); } glib::ffi::GFALSE } } } #[cfg(test)] mod tests { use super::*; use crate::{prelude::*, Cancellable, Initable}; pub mod imp { use std::cell::Cell; use super::*; pub struct InitableTestType(pub Cell); #[glib::object_subclass] impl ObjectSubclass for InitableTestType { const NAME: &'static str = "InitableTestType"; type Type = super::InitableTestType; type Interfaces = (Initable,); fn new() -> Self { Self(Cell::new(0)) } } impl InitableImpl for InitableTestType { fn init(&self, _cancellable: Option<&Cancellable>) -> Result<(), glib::Error> { self.0.set(0x123456789abcdef); Ok(()) } } impl ObjectImpl for InitableTestType {} } pub mod ffi { use super::*; pub type InitableTestType = ::Instance; pub unsafe extern "C" fn initable_test_type_get_value(this: *mut InitableTestType) -> u64 { let this = super::InitableTestType::from_glib_borrow(this); this.imp().0.get() } } glib::wrapper! { pub struct InitableTestType(ObjectSubclass) @implements Initable; } #[allow(clippy::new_without_default)] impl InitableTestType { pub fn new() -> Self { Initable::new(Option::<&Cancellable>::None) .expect("Failed creation/initialization of InitableTestType object") } pub unsafe fn new_uninit() -> Self { // This creates an uninitialized InitableTestType object, for testing // purposes. In real code, using Initable::new (like the new() method // does) is recommended. glib::Object::new_internal(Self::static_type(), &mut []) .downcast() .unwrap() } pub fn value(&self) -> u64 { self.imp().0.get() } } #[test] fn test_initable_with_init() { let res = unsafe { let test = InitableTestType::new_uninit(); assert_ne!(0x123456789abcdef, test.value()); test.init(Option::<&Cancellable>::None).map(|_| test) }; assert!(res.is_ok()); let test = res.unwrap(); assert_eq!(0x123456789abcdef, test.value()); } #[test] fn test_initable_with_initable_new() { let test = InitableTestType::new(); assert_eq!(0x123456789abcdef, test.value()); } #[test] #[should_panic = ""] fn test_initable_new_failure() { let value: u32 = 2; let _ = Initable::builder::() .property("invalid-property", value) .build(Option::<&Cancellable>::None); unreachable!(); } #[test] fn test_initable_with_initable_with_type() { let test = Initable::with_type( InitableTestType::static_type(), Option::<&Cancellable>::None, ) .expect("Failed creation/initialization of InitableTestType object from type") .downcast::() .expect("Failed downcast of InitableTestType object"); assert_eq!(0x123456789abcdef, test.value()); } #[test] fn test_initable_with_initable_with_values() { let test = Initable::with_type( InitableTestType::static_type(), Option::<&Cancellable>::None, ) .expect("Failed creation/initialization of InitableTestType object from values") .downcast::() .expect("Failed downcast of InitableTestType object"); assert_eq!(0x123456789abcdef, test.value()); } #[test] fn test_initable_through_ffi() { unsafe { let test = InitableTestType::new_uninit(); let test: *mut ffi::InitableTestType = test.as_ptr(); let mut error: *mut glib::ffi::GError = std::ptr::null_mut(); assert_ne!(0x123456789abcdef, ffi::initable_test_type_get_value(test)); let result = crate::ffi::g_initable_init( test as *mut crate::ffi::GInitable, std::ptr::null_mut(), &mut error, ); assert_eq!(glib::ffi::GTRUE, result); assert_eq!(error, ptr::null_mut()); assert_eq!(0x123456789abcdef, ffi::initable_test_type_get_value(test)); } } } gio-0.20.1/src/subclass/input_stream.rs000064400000000000000000000237361046102023000161630ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, InputStream}; pub trait InputStreamImpl: ObjectImpl + InputStreamImplExt + Send { fn read(&self, buffer: &mut [u8], cancellable: Option<&Cancellable>) -> Result { self.parent_read(buffer, cancellable) } fn close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(cancellable) } fn skip(&self, count: usize, cancellable: Option<&Cancellable>) -> Result { self.parent_skip(count, cancellable) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait InputStreamImplExt: sealed::Sealed + ObjectSubclass { fn parent_read( &self, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GInputStreamClass; let f = (*parent_class) .read_fn .expect("No parent class implementation for \"read\""); let mut err = ptr::null_mut(); let res = f( self.obj().unsafe_cast_ref::().to_glib_none().0, buffer.as_mut_ptr() as glib::ffi::gpointer, buffer.len(), cancellable.to_glib_none().0, &mut err, ); if res == -1 { Err(from_glib_full(err)) } else { debug_assert!(res >= 0); let res = res as usize; debug_assert!(res <= buffer.len()); Ok(res) } } } fn parent_close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GInputStreamClass; let mut err = ptr::null_mut(); if let Some(f) = (*parent_class).close_fn { if from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, cancellable.to_glib_none().0, &mut err, )) { Ok(()) } else { Err(from_glib_full(err)) } } else { Ok(()) } } } fn parent_skip(&self, count: usize, cancellable: Option<&Cancellable>) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GInputStreamClass; let mut err = ptr::null_mut(); let f = (*parent_class) .skip .expect("No parent class implementation for \"skip\""); let res = f( self.obj().unsafe_cast_ref::().to_glib_none().0, count, cancellable.to_glib_none().0, &mut err, ); if res == -1 { Err(from_glib_full(err)) } else { debug_assert!(res >= 0); let res = res as usize; debug_assert!(res <= count); Ok(res) } } } } impl InputStreamImplExt for T {} unsafe impl IsSubclassable for InputStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.read_fn = Some(stream_read::); klass.close_fn = Some(stream_close::); klass.skip = Some(stream_skip::); } } unsafe extern "C" fn stream_read( ptr: *mut ffi::GInputStream, buffer: glib::ffi::gpointer, count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.read( if count == 0 { &mut [] } else { std::slice::from_raw_parts_mut(buffer as *mut u8, count) }, Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(res) => { assert!(res <= isize::MAX as usize); assert!(res <= count); res as isize } Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } -1 } } } unsafe extern "C" fn stream_close( ptr: *mut ffi::GInputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.close( Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } unsafe extern "C" fn stream_skip( ptr: *mut ffi::GInputStream, count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.skip( count, Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(res) => { assert!(res <= isize::MAX as usize); assert!(res <= count); res as isize } Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } -1 } } } #[cfg(test)] mod tests { use std::cell::RefCell; use super::*; use crate::{prelude::*, subclass::prelude::*}; mod imp { use super::*; #[derive(Default)] pub struct SimpleInputStream { pub pos: RefCell, } #[glib::object_subclass] impl ObjectSubclass for SimpleInputStream { const NAME: &'static str = "SimpleInputStream"; type Type = super::SimpleInputStream; type ParentType = InputStream; type Interfaces = (crate::Seekable,); } impl ObjectImpl for SimpleInputStream {} impl InputStreamImpl for SimpleInputStream { fn read( &self, buffer: &mut [u8], _cancellable: Option<&Cancellable>, ) -> Result { let mut pos = self.pos.borrow_mut(); for b in buffer.iter_mut() { *b = ((*pos) % 255) as u8; *pos += 1; } Ok(buffer.len()) } } impl SeekableImpl for SimpleInputStream { fn tell(&self) -> i64 { *self.pos.borrow() as i64 } fn can_seek(&self) -> bool { true } fn seek( &self, offset: i64, type_: glib::SeekType, _cancellable: Option<&Cancellable>, ) -> Result<(), glib::Error> { let mut pos = self.pos.borrow_mut(); match type_ { glib::SeekType::Set => { *pos = offset as usize; Ok(()) } glib::SeekType::Cur => { if offset < 0 { *pos -= (-offset) as usize; } else { *pos += offset as usize; } Ok(()) } glib::SeekType::End => Err(glib::Error::new( crate::IOErrorEnum::NotSupported, "Can't seek relative to end", )), _ => unreachable!(), } } fn can_truncate(&self) -> bool { false } fn truncate( &self, _offset: i64, _cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unimplemented!() } } } glib::wrapper! { pub struct SimpleInputStream(ObjectSubclass) @extends InputStream; } #[test] fn test_simple_stream() { let stream = glib::Object::new::(); let mut buf = [0; 16]; assert_eq!(stream.read(&mut buf, crate::Cancellable::NONE), Ok(16)); assert_eq!( &buf, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] ); assert_eq!(stream.skip(2, crate::Cancellable::NONE), Ok(2)); assert_eq!(stream.read(&mut buf, crate::Cancellable::NONE), Ok(16)); assert_eq!( &buf, &[18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33] ); let seekable = stream.dynamic_cast_ref::().unwrap(); assert_eq!(seekable.tell(), 34); assert!(seekable.can_seek()); assert_eq!( seekable.seek(0, glib::SeekType::Set, crate::Cancellable::NONE), Ok(()) ); assert_eq!(seekable.tell(), 0); assert_eq!(stream.read(&mut buf, crate::Cancellable::NONE), Ok(16)); assert_eq!( &buf, &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] ); assert_eq!(stream.close(crate::Cancellable::NONE), Ok(())); } } gio-0.20.1/src/subclass/io_stream.rs000064400000000000000000000123631046102023000154250ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ptr, sync::OnceLock}; use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, IOStream, InputStream, OutputStream}; pub trait IOStreamImpl: ObjectImpl + IOStreamImplExt + Send { fn input_stream(&self) -> InputStream { self.parent_input_stream() } fn output_stream(&self) -> OutputStream { self.parent_output_stream() } fn close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(cancellable) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait IOStreamImplExt: sealed::Sealed + ObjectSubclass { fn parent_input_stream(&self) -> InputStream { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GIOStreamClass; let f = (*parent_class) .get_input_stream .expect("No parent class implementation for \"input_stream\""); from_glib_none(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) } } fn parent_output_stream(&self) -> OutputStream { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GIOStreamClass; let f = (*parent_class) .get_output_stream .expect("No parent class implementation for \"output_stream\""); from_glib_none(f(self.obj().unsafe_cast_ref::().to_glib_none().0)) } } fn parent_close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GIOStreamClass; let mut err = ptr::null_mut(); if let Some(f) = (*parent_class).close_fn { if from_glib(f( self.obj().unsafe_cast_ref::().to_glib_none().0, cancellable.to_glib_none().0, &mut err, )) { Ok(()) } else { Err(from_glib_full(err)) } } else { Ok(()) } } } } impl IOStreamImplExt for T {} unsafe impl IsSubclassable for IOStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.get_input_stream = Some(stream_get_input_stream::); klass.get_output_stream = Some(stream_get_output_stream::); klass.close_fn = Some(stream_close::); } } unsafe extern "C" fn stream_get_input_stream( ptr: *mut ffi::GIOStream, ) -> *mut ffi::GInputStream { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let ret = imp.input_stream(); let instance = imp.obj(); // Ensure that a) the stream stays alive as long as the IO stream instance and // b) that the same stream is returned every time. This is a requirement by the // IO stream API. let input_stream_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| glib::Quark::from_str("gtk-rs-subclass-input-stream")) }; if let Some(old_stream) = instance.qdata::(input_stream_quark) { assert_eq!( old_stream.as_ref(), &ret, "Did not return same input stream again" ); } instance.set_qdata(input_stream_quark, ret.clone()); ret.to_glib_none().0 } unsafe extern "C" fn stream_get_output_stream( ptr: *mut ffi::GIOStream, ) -> *mut ffi::GOutputStream { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let ret = imp.output_stream(); let instance = imp.obj(); // Ensure that a) the stream stays alive as long as the IO stream instance and // b) that the same stream is returned every time. This is a requirement by the // IO stream API. let output_stream_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| glib::Quark::from_str("gtk-rs-subclass-output-stream")) }; if let Some(old_stream) = instance.qdata::(output_stream_quark) { assert_eq!( old_stream.as_ref(), &ret, "Did not return same output stream again" ); } instance.set_qdata(output_stream_quark, ret.clone()); ret.to_glib_none().0 } unsafe extern "C" fn stream_close( ptr: *mut ffi::GIOStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.close( Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } gio-0.20.1/src/subclass/list_model.rs000064400000000000000000000105701046102023000155740ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::sync::OnceLock; use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, ListModel}; pub trait ListModelImpl: ObjectImpl { #[doc(alias = "get_item_type")] fn item_type(&self) -> glib::Type; #[doc(alias = "get_n_items")] fn n_items(&self) -> u32; #[doc(alias = "get_item")] fn item(&self, position: u32) -> Option; } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait ListModelImplExt: sealed::Sealed + ObjectSubclass { fn parent_item_type(&self) -> glib::Type { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GListModelInterface; let func = (*parent_iface) .get_item_type .expect("no parent \"item_type\" implementation"); let ret = func(self.obj().unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_n_items(&self) -> u32 { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GListModelInterface; let func = (*parent_iface) .get_n_items .expect("no parent \"n_items\" implementation"); func(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_item(&self, position: u32) -> Option { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GListModelInterface; let func = (*parent_iface) .get_item .expect("no parent \"get_item\" implementation"); let ret = func( self.obj().unsafe_cast_ref::().to_glib_none().0, position, ); from_glib_full(ret) } } } impl ListModelImplExt for T {} unsafe impl IsImplementable for ListModel where ::Type: IsA, { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.get_item_type = Some(list_model_get_item_type::); iface.get_n_items = Some(list_model_get_n_items::); iface.get_item = Some(list_model_get_item::); } } unsafe extern "C" fn list_model_get_item_type( list_model: *mut ffi::GListModel, ) -> glib::ffi::GType where ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); let type_ = imp.item_type().into_glib(); // Store the type so we can enforce that it doesn't change. let instance = imp.obj(); let type_quark = { static QUARK: OnceLock = OnceLock::new(); *QUARK.get_or_init(|| glib::Quark::from_str("gtk-rs-subclass-list-model-item-type")) }; match instance.qdata(type_quark) { Some(old_type) => { assert_eq!( type_, *old_type.as_ref(), "ListModel's get_item_type cannot be changed" ); } None => { instance.set_qdata(type_quark, type_); } } type_ } unsafe extern "C" fn list_model_get_n_items( list_model: *mut ffi::GListModel, ) -> u32 where ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); imp.n_items() } unsafe extern "C" fn list_model_get_item( list_model: *mut ffi::GListModel, position: u32, ) -> *mut glib::gobject_ffi::GObject where ::Type: IsA, { let instance = &*(list_model as *mut T::Instance); let imp = instance.imp(); let item = imp.item(position); if let Some(ref i) = item { let type_ = imp.item_type(); assert!( i.type_().is_a(type_), "All ListModel items need to be of type {} or a subtype of it", type_.name() ); }; item.into_glib_ptr() } gio-0.20.1/src/subclass/mod.rs000064400000000000000000000021051046102023000142130ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. mod action_group; mod action_map; mod application; mod async_initable; mod initable; mod input_stream; mod io_stream; mod list_model; mod output_stream; mod seekable; mod socket_control_message; pub use self::application::ArgumentList; pub mod prelude { #[doc(hidden)] pub use glib::subclass::prelude::*; pub use super::{ action_group::{ActionGroupImpl, ActionGroupImplExt}, action_map::{ActionMapImpl, ActionMapImplExt}, application::{ApplicationImpl, ApplicationImplExt}, async_initable::{AsyncInitableImpl, AsyncInitableImplExt}, initable::{InitableImpl, InitableImplExt}, input_stream::{InputStreamImpl, InputStreamImplExt}, io_stream::{IOStreamImpl, IOStreamImplExt}, list_model::{ListModelImpl, ListModelImplExt}, output_stream::{OutputStreamImpl, OutputStreamImplExt}, seekable::{SeekableImpl, SeekableImplExt}, socket_control_message::{SocketControlMessageImpl, SocketControlMessageImplExt}, }; } gio-0.20.1/src/subclass/output_stream.rs000064400000000000000000000230241046102023000163520ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, subclass::prelude::*, translate::*, Error}; use crate::{ffi, Cancellable, InputStream, OutputStream, OutputStreamSpliceFlags}; pub trait OutputStreamImpl: ObjectImpl + OutputStreamImplExt + Send { fn write(&self, buffer: &[u8], cancellable: Option<&Cancellable>) -> Result { self.parent_write(buffer, cancellable) } fn close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(cancellable) } fn flush(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_flush(cancellable) } fn splice( &self, input_stream: &InputStream, flags: OutputStreamSpliceFlags, cancellable: Option<&Cancellable>, ) -> Result { self.parent_splice(input_stream, flags, cancellable) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait OutputStreamImplExt: sealed::Sealed + ObjectSubclass { fn parent_write( &self, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GOutputStreamClass; let f = (*parent_class) .write_fn .expect("No parent class implementation for \"write\""); let mut err = ptr::null_mut(); let res = f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, mut_override(buffer.as_ptr()), buffer.len(), cancellable.to_glib_none().0, &mut err, ); if res == -1 { Err(from_glib_full(err)) } else { debug_assert!(res >= 0); let res = res as usize; debug_assert!(res <= buffer.len()); Ok(res) } } } fn parent_close(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GOutputStreamClass; let mut err = ptr::null_mut(); if let Some(f) = (*parent_class).close_fn { if from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, cancellable.to_glib_none().0, &mut err, )) { Ok(()) } else { Err(from_glib_full(err)) } } else { Ok(()) } } } fn parent_flush(&self, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GOutputStreamClass; let mut err = ptr::null_mut(); if let Some(f) = (*parent_class).flush { if from_glib(f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, cancellable.to_glib_none().0, &mut err, )) { Ok(()) } else { Err(from_glib_full(err)) } } else { Ok(()) } } } fn parent_splice( &self, input_stream: &InputStream, flags: OutputStreamSpliceFlags, cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GOutputStreamClass; let mut err = ptr::null_mut(); let f = (*parent_class) .splice .expect("No parent class implementation for \"splice\""); let res = f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, input_stream.to_glib_none().0, flags.into_glib(), cancellable.to_glib_none().0, &mut err, ); if res == -1 { Err(from_glib_full(err)) } else { debug_assert!(res >= 0); let res = res as usize; Ok(res) } } } } impl OutputStreamImplExt for T {} unsafe impl IsSubclassable for OutputStream { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.write_fn = Some(stream_write::); klass.close_fn = Some(stream_close::); klass.flush = Some(stream_flush::); klass.splice = Some(stream_splice::); } } unsafe extern "C" fn stream_write( ptr: *mut ffi::GOutputStream, buffer: *mut u8, count: usize, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> isize { debug_assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.write( if count == 0 { &[] } else { std::slice::from_raw_parts(buffer as *const u8, count) }, Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(res) => { assert!(res <= isize::MAX as usize); assert!(res <= count); res as isize } Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } -1 } } } unsafe extern "C" fn stream_close( ptr: *mut ffi::GOutputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.close( Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } unsafe extern "C" fn stream_flush( ptr: *mut ffi::GOutputStream, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.flush( Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } unsafe extern "C" fn stream_splice( ptr: *mut ffi::GOutputStream, input_stream: *mut ffi::GInputStream, flags: ffi::GOutputStreamSpliceFlags, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> isize { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); match imp.splice( &from_glib_borrow(input_stream), from_glib(flags), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(res) => { assert!(res <= isize::MAX as usize); res as isize } Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } -1 } } } #[cfg(test)] mod tests { use std::cell::RefCell; use super::*; use crate::prelude::*; mod imp { use super::*; #[derive(Default)] pub struct SimpleOutputStream { pub sum: RefCell, } #[glib::object_subclass] impl ObjectSubclass for SimpleOutputStream { const NAME: &'static str = "SimpleOutputStream"; type Type = super::SimpleOutputStream; type ParentType = OutputStream; } impl ObjectImpl for SimpleOutputStream {} impl OutputStreamImpl for SimpleOutputStream { fn write( &self, buffer: &[u8], _cancellable: Option<&Cancellable>, ) -> Result { let mut sum = self.sum.borrow_mut(); for b in buffer { *sum += *b as usize; } Ok(buffer.len()) } } } glib::wrapper! { pub struct SimpleOutputStream(ObjectSubclass) @extends OutputStream; } #[test] fn test_simple_stream() { let stream = glib::Object::new::(); assert_eq!(*stream.imp().sum.borrow(), 0); assert_eq!( stream.write(&[1, 2, 3, 4, 5], crate::Cancellable::NONE), Ok(5) ); assert_eq!(*stream.imp().sum.borrow(), 15); } } gio-0.20.1/src/subclass/seekable.rs000064400000000000000000000144311046102023000152140ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::ptr; use glib::{prelude::*, subclass::prelude::*, translate::*, Error, SeekType}; use crate::{ffi, Cancellable, Seekable}; pub trait SeekableImpl: ObjectImpl + Send { fn tell(&self) -> i64; fn can_seek(&self) -> bool; fn seek( &self, offset: i64, type_: SeekType, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn can_truncate(&self) -> bool; fn truncate(&self, offset: i64, cancellable: Option<&Cancellable>) -> Result<(), Error>; } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait SeekableImplExt: sealed::Sealed + ObjectSubclass { fn parent_tell(&self) -> i64 { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GSeekableIface; let func = (*parent_iface) .tell .expect("no parent \"tell\" implementation"); func(self.obj().unsafe_cast_ref::().to_glib_none().0) } } fn parent_can_seek(&self) -> bool { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GSeekableIface; let func = (*parent_iface) .can_seek .expect("no parent \"can_seek\" implementation"); let ret = func(self.obj().unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_seek( &self, offset: i64, type_: SeekType, cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GSeekableIface; let func = (*parent_iface) .seek .expect("no parent \"seek\" implementation"); let mut err = ptr::null_mut(); func( self.obj().unsafe_cast_ref::().to_glib_none().0, offset, type_.into_glib(), cancellable.to_glib_none().0, &mut err, ); if err.is_null() { Ok(()) } else { Err(from_glib_full(err)) } } } fn parent_can_truncate(&self) -> bool { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GSeekableIface; let func = (*parent_iface) .can_truncate .expect("no parent \"can_truncate\" implementation"); let ret = func(self.obj().unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_truncate(&self, offset: i64, cancellable: Option<&Cancellable>) -> Result<(), Error> { unsafe { let type_data = Self::type_data(); let parent_iface = type_data.as_ref().parent_interface::() as *const ffi::GSeekableIface; let func = (*parent_iface) .truncate_fn .expect("no parent \"truncate\" implementation"); let mut err = ptr::null_mut(); func( self.obj().unsafe_cast_ref::().to_glib_none().0, offset, cancellable.to_glib_none().0, &mut err, ); if err.is_null() { Ok(()) } else { Err(from_glib_full(err)) } } } } impl SeekableImplExt for T {} unsafe impl IsImplementable for Seekable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.tell = Some(seekable_tell::); iface.can_seek = Some(seekable_can_seek::); iface.seek = Some(seekable_seek::); iface.can_truncate = Some(seekable_can_truncate::); iface.truncate_fn = Some(seekable_truncate::); } } unsafe extern "C" fn seekable_tell(seekable: *mut ffi::GSeekable) -> i64 { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); imp.tell() } unsafe extern "C" fn seekable_can_seek( seekable: *mut ffi::GSeekable, ) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); imp.can_seek().into_glib() } unsafe extern "C" fn seekable_seek( seekable: *mut ffi::GSeekable, offset: i64, type_: glib::ffi::GSeekType, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); match imp.seek( offset, from_glib(type_), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(()) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } unsafe extern "C" fn seekable_can_truncate( seekable: *mut ffi::GSeekable, ) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); imp.can_truncate().into_glib() } unsafe extern "C" fn seekable_truncate( seekable: *mut ffi::GSeekable, offset: i64, cancellable: *mut ffi::GCancellable, err: *mut *mut glib::ffi::GError, ) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.imp(); match imp.truncate( offset, Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(()) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_glib_ptr(); } glib::ffi::GFALSE } } } gio-0.20.1/src/subclass/socket_control_message.rs000064400000000000000000000173161046102023000202020ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, SocketControlMessage}; pub trait SocketControlMessageImpl: ObjectImpl + SocketControlMessageImplExt { fn level(&self) -> i32 { self.parent_level() } fn msg_type(&self) -> i32 { self.parent_msg_type() } fn size(&self) -> usize { self.parent_size() } fn serialize(&self, data: &mut [u8]) { self.parent_serialize(data); } fn deserialize(level: i32, type_: i32, data: &[u8]) -> Option { Self::parent_deserialize(level, type_, data) } } mod sealed { pub trait Sealed {} impl Sealed for T {} } pub trait SocketControlMessageImplExt: sealed::Sealed + ObjectSubclass { fn parent_level(&self) -> i32 { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GSocketControlMessageClass; let f = (*parent_class) .get_level .expect("No parent class implementation for \"level\""); f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_msg_type(&self) -> i32 { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GSocketControlMessageClass; let f = (*parent_class) .get_type .expect("No parent class implementation for \"msg_type\""); f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_size(&self) -> usize { unsafe { let data = Self::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GSocketControlMessageClass; let f = (*parent_class) .get_size .expect("No parent class implementation for \"size\""); f(self .obj() .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_serialize(&self, data: &mut [u8]) { unsafe { let type_data = Self::type_data(); let parent_class = type_data.as_ref().parent_class() as *mut ffi::GSocketControlMessageClass; let f = (*parent_class) .serialize .expect("No parent class implementation for \"serialize\""); f( self.obj() .unsafe_cast_ref::() .to_glib_none() .0, data.as_mut_ptr() as _, ) } } fn parent_deserialize(level: i32, type_: i32, data: &[u8]) -> Option { unsafe { let type_data = Self::type_data(); let parent_class = type_data.as_ref().parent_class() as *mut ffi::GSocketControlMessageClass; (*parent_class).deserialize.map(|f| { let message_ptr = f(level, type_, data.len(), data.as_ptr() as _); from_glib_full(message_ptr) }) } } } impl SocketControlMessageImplExt for T {} unsafe impl IsSubclassable for SocketControlMessage { fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); let klass = class.as_mut(); klass.get_level = Some(socket_control_message_get_level::); klass.get_type = Some(socket_control_message_get_type::); klass.get_size = Some(socket_control_message_get_size::); klass.serialize = Some(socket_control_message_serialize::); klass.deserialize = Some(socket_control_message_deserialize::); } } unsafe extern "C" fn socket_control_message_get_level( ptr: *mut ffi::GSocketControlMessage, ) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.level() } unsafe extern "C" fn socket_control_message_get_type( ptr: *mut ffi::GSocketControlMessage, ) -> i32 { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.msg_type() } unsafe extern "C" fn socket_control_message_get_size( ptr: *mut ffi::GSocketControlMessage, ) -> usize { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.size() } unsafe extern "C" fn socket_control_message_serialize( ptr: *mut ffi::GSocketControlMessage, data: glib::ffi::gpointer, ) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); let data = std::slice::from_raw_parts_mut(data as *mut u8, imp.size()); imp.serialize(data); } unsafe extern "C" fn socket_control_message_deserialize( level: i32, type_: i32, size: usize, data: glib::ffi::gpointer, ) -> *mut ffi::GSocketControlMessage { let data = std::slice::from_raw_parts(data as *mut u8, size); T::deserialize(level, type_, data).into_glib_ptr() } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; use std::cell::Cell; use std::mem::size_of; mod imp { use super::*; #[derive(Default)] pub struct TestSocketControlMessage(pub Cell); #[glib::object_subclass] impl ObjectSubclass for TestSocketControlMessage { const NAME: &'static str = "TestSocketControlMessage"; type Type = super::TestSocketControlMessage; type ParentType = SocketControlMessage; } impl ObjectImpl for TestSocketControlMessage {} impl SocketControlMessageImpl for TestSocketControlMessage { fn level(&self) -> i32 { i32::MAX } fn msg_type(&self) -> i32 { i32::MAX } fn size(&self) -> usize { size_of::() } fn serialize(&self, data: &mut [u8]) { data.copy_from_slice(&self.0.get().to_ne_bytes()); } fn deserialize(level: i32, type_: i32, data: &[u8]) -> Option { if level == i32::MAX && type_ == i32::MAX { let obj = glib::Object::new::(); obj.imp().0.set(u64::from_ne_bytes(data.try_into().ok()?)); Some(obj.into()) } else { None } } } } glib::wrapper! { pub struct TestSocketControlMessage(ObjectSubclass) @extends SocketControlMessage; } #[test] fn test_socket_control_message_subclassing() { let obj = glib::Object::new::(); assert_eq!(obj.level(), i32::MAX); assert_eq!(obj.msg_type(), i32::MAX); assert_eq!(obj.size(), size_of::()); obj.imp().0.set(0x12345678abcdefu64); let mut data = [0; size_of::()]; obj.serialize(&mut data); let de = SocketControlMessage::deserialize(i32::MAX, i32::MAX, &data) .expect("deserialize failed"); let de = de .downcast::() .expect("downcast failed"); assert_eq!(de.imp().0.get(), 0x12345678abcdefu64); } } gio-0.20.1/src/subprocess.rs000064400000000000000000000064571046102023000140230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{pin::Pin, ptr}; use glib::{prelude::*, translate::*, GString}; use libc::c_char; use crate::{ffi, Cancellable, Subprocess}; impl Subprocess { #[doc(alias = "g_subprocess_communicate_utf8_async")] pub fn communicate_utf8_async< R: FnOnce(Result<(Option, Option), glib::Error>) + 'static, C: IsA, >( &self, stdin_buf: Option, cancellable: Option<&C>, callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); let has_acquired_main_context = (!is_main_context_owner) .then(|| main_context.acquire().ok()) .flatten(); assert!( is_main_context_owner || has_acquired_main_context.is_some(), "Async operations only allowed if the thread is owning the MainContext" ); let stdin_buf = stdin_buf.to_glib_full(); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box<(glib::thread_guard::ThreadGuard, *mut c_char)> = Box::new((glib::thread_guard::ThreadGuard::new(callback), stdin_buf)); unsafe extern "C" fn communicate_utf8_async_trampoline< R: FnOnce(Result<(Option, Option), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut error = ptr::null_mut(); let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let _ = ffi::g_subprocess_communicate_utf8_finish( _source_object as *mut _, res, &mut stdout_buf, &mut stderr_buf, &mut error, ); let result = if error.is_null() { Ok((from_glib_full(stdout_buf), from_glib_full(stderr_buf))) } else { Err(from_glib_full(error)) }; let callback: Box<(glib::thread_guard::ThreadGuard, *mut c_char)> = Box::from_raw(user_data as *mut _); glib::ffi::g_free(callback.1 as *mut _); (callback.0.into_inner())(result); } unsafe { ffi::g_subprocess_communicate_utf8_async( self.to_glib_none().0, stdin_buf, gcancellable.0, Some(communicate_utf8_async_trampoline::), Box::into_raw(user_data) as *mut _, ); } } pub fn communicate_utf8_future( &self, stdin_buf: Option, ) -> Pin< Box< dyn std::future::Future< Output = Result<(Option, Option), glib::Error>, > + 'static, >, > { Box::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.communicate_utf8_async(stdin_buf, Some(cancellable), move |res| { send.resolve(res); }); }, )) } } gio-0.20.1/src/subprocess_launcher.rs000064400000000000000000000032461046102023000156750ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(any(unix, all(docsrs, unix)))] use std::os::unix::io::IntoRawFd; #[cfg(unix)] use glib::translate::*; #[cfg(unix)] use crate::ffi; use crate::SubprocessLauncher; #[cfg(all(docsrs, not(unix)))] pub trait IntoRawFd: Sized { fn into_raw_fd(self) -> i32 { 0 } } impl SubprocessLauncher { #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_fd")] pub fn take_fd(&self, source_fd: impl IntoRawFd, target_fd: impl IntoRawFd) { unsafe { ffi::g_subprocess_launcher_take_fd( self.to_glib_none().0, source_fd.into_raw_fd(), target_fd.into_raw_fd(), ); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stderr_fd")] pub fn take_stderr_fd(&self, fd: impl IntoRawFd) { unsafe { ffi::g_subprocess_launcher_take_stderr_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stdin_fd")] pub fn take_stdin_fd(&self, fd: impl IntoRawFd) { unsafe { ffi::g_subprocess_launcher_take_stdin_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(unix)] #[cfg_attr(docsrs, doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stdout_fd")] pub fn take_stdout_fd(&self, fd: impl IntoRawFd) { unsafe { ffi::g_subprocess_launcher_take_stdout_fd(self.to_glib_none().0, fd.into_raw_fd()); } } } gio-0.20.1/src/task.rs000064400000000000000000000541111046102023000125630ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{boxed::Box as Box_, future::Future, mem::transmute, panic, ptr}; use glib::{ prelude::*, signal::{connect_raw, SignalHandlerId}, translate::*, }; use futures_channel::oneshot; use crate::{ffi, AsyncResult, Cancellable}; glib::wrapper! { // rustdoc-stripper-ignore-next /// `LocalTask` provides idiomatic access to gio's `GTask` API, for /// instance by being generic over their value type, while not completely departing /// from the underlying C API. `LocalTask` does not require its value to be `Send` /// and `Sync` and thus is useful to to implement gio style asynchronous /// tasks that run in the glib main loop. If you need to run tasks in threads /// see the `Task` type. /// /// The constructors of `LocalTask` and `Task` is marked as unsafe because this API does /// not allow to automatically enforce all the invariants required to be a completely /// safe abstraction. See the `Task` type for more details. #[doc(alias = "GTask")] pub struct LocalTask(Object) @implements AsyncResult; match fn { type_ => || ffi::g_task_get_type(), } } glib::wrapper! { // rustdoc-stripper-ignore-next /// `Task` provides idiomatic access to gio's `GTask` API, for /// instance by being generic over their value type, while not completely departing /// from the underlying C API. `Task` is `Send` and `Sync` and requires its value to /// also be `Send` and `Sync`, thus is useful to to implement gio style asynchronous /// tasks that run in threads. If you need to only run tasks in glib main loop /// see the `LocalTask` type. /// /// The constructors of `LocalTask` and `Task` is marked as unsafe because this API does /// not allow to automatically enforce all the invariants required to be a completely /// safe abstraction. The caller is responsible to ensure the following requirements /// are satisfied /// /// * You should not create a `LocalTask`, upcast it to a `glib::Object` and then /// downcast it to a `Task`, as this will bypass the thread safety requirements /// * You should ensure that the `return_result`, `return_error_if_cancelled` and /// `propagate()` methods are only called once. #[doc(alias = "GTask")] pub struct Task(Object) @implements AsyncResult; match fn { type_ => || ffi::g_task_get_type(), } } macro_rules! task_impl { ($name:ident $(, @bound: $bound:tt)? $(, @safety: $safety:tt)?) => { impl + ValueType $(+ $bound)?> $name { #[doc(alias = "g_task_new")] #[allow(unused_unsafe)] pub unsafe fn new( source_object: Option<&S>, cancellable: Option<&P>, callback: Q, ) -> Self where S: IsA $(+ $bound)?, P: IsA, Q: FnOnce($name, Option<&S>) $(+ $bound)? + 'static, { let callback_data = Box_::new(callback); unsafe extern "C" fn trampoline< S: IsA $(+ $bound)?, V: ValueType $(+ $bound)?, Q: FnOnce($name, Option<&S>) $(+ $bound)? + 'static, >( source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let callback: Box_ = Box::from_raw(user_data as *mut _); let task = AsyncResult::from_glib_none(res) .downcast::<$name>() .unwrap(); let source_object = Option::::from_glib_borrow(source_object); callback( task, source_object.as_ref().as_ref().map(|s| s.unsafe_cast_ref()), ); } let callback = trampoline::; unsafe { from_glib_full(ffi::g_task_new( source_object.map(|p| p.as_ref()).to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, Some(callback), Box_::into_raw(callback_data) as *mut _, )) } } #[doc(alias = "g_task_get_cancellable")] #[doc(alias = "get_cancellable")] pub fn cancellable(&self) -> Option { unsafe { from_glib_none(ffi::g_task_get_cancellable(self.to_glib_none().0)) } } #[doc(alias = "g_task_get_check_cancellable")] #[doc(alias = "get_check_cancellable")] pub fn is_check_cancellable(&self) -> bool { unsafe { from_glib(ffi::g_task_get_check_cancellable(self.to_glib_none().0)) } } #[doc(alias = "g_task_set_check_cancellable")] pub fn set_check_cancellable(&self, check_cancellable: bool) { unsafe { ffi::g_task_set_check_cancellable(self.to_glib_none().0, check_cancellable.into_glib()); } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_task_set_name")] pub fn set_name(&self, name: Option<&str>) { unsafe { ffi::g_task_set_name(self.to_glib_none().0, name.to_glib_none().0); } } #[doc(alias = "g_task_set_return_on_cancel")] pub fn set_return_on_cancel(&self, return_on_cancel: bool) -> bool { unsafe { from_glib(ffi::g_task_set_return_on_cancel( self.to_glib_none().0, return_on_cancel.into_glib(), )) } } #[doc(alias = "g_task_is_valid")] pub fn is_valid( result: &impl IsA, source_object: Option<&impl IsA>, ) -> bool { unsafe { from_glib(ffi::g_task_is_valid( result.as_ref().to_glib_none().0, source_object.map(|p| p.as_ref()).to_glib_none().0, )) } } #[doc(alias = "get_priority")] #[doc(alias = "g_task_get_priority")] pub fn priority(&self) -> glib::source::Priority { unsafe { FromGlib::from_glib(ffi::g_task_get_priority(self.to_glib_none().0)) } } #[doc(alias = "g_task_set_priority")] pub fn set_priority(&self, priority: glib::source::Priority) { unsafe { ffi::g_task_set_priority(self.to_glib_none().0, priority.into_glib()); } } #[doc(alias = "g_task_get_completed")] #[doc(alias = "get_completed")] pub fn is_completed(&self) -> bool { unsafe { from_glib(ffi::g_task_get_completed(self.to_glib_none().0)) } } #[doc(alias = "g_task_get_context")] #[doc(alias = "get_context")] pub fn context(&self) -> glib::MainContext { unsafe { from_glib_none(ffi::g_task_get_context(self.to_glib_none().0)) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_task_get_name")] #[doc(alias = "get_name")] pub fn name(&self) -> Option { unsafe { from_glib_none(ffi::g_task_get_name(self.to_glib_none().0)) } } #[doc(alias = "g_task_get_return_on_cancel")] #[doc(alias = "get_return_on_cancel")] pub fn is_return_on_cancel(&self) -> bool { unsafe { from_glib(ffi::g_task_get_return_on_cancel(self.to_glib_none().0)) } } #[doc(alias = "g_task_had_error")] pub fn had_error(&self) -> bool { unsafe { from_glib(ffi::g_task_had_error(self.to_glib_none().0)) } } #[doc(alias = "completed")] pub fn connect_completed_notify(&self, f: F) -> SignalHandlerId where F: Fn(&$name) $(+ $bound)? + 'static, { unsafe extern "C" fn notify_completed_trampoline( this: *mut ffi::GTask, _param_spec: glib::ffi::gpointer, f: glib::ffi::gpointer, ) where V: ValueType $(+ $bound)?, F: Fn(&$name) + 'static, { let f: &F = &*(f as *const F); f(&from_glib_borrow(this)) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"notify::completed\0".as_ptr() as *const _, Some(transmute::<*const (), unsafe extern "C" fn()>( notify_completed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } // the following functions are marked unsafe since they cannot be called // more than once, but we have no way to enforce that since the task can be cloned #[doc(alias = "g_task_return_error_if_cancelled")] #[allow(unused_unsafe)] pub $($safety)? fn return_error_if_cancelled(&self) -> bool { unsafe { from_glib(ffi::g_task_return_error_if_cancelled(self.to_glib_none().0)) } } #[doc(alias = "g_task_return_value")] #[doc(alias = "g_task_return_boolean")] #[doc(alias = "g_task_return_int")] #[doc(alias = "g_task_return_pointer")] #[doc(alias = "g_task_return_error")] #[allow(unused_unsafe)] pub $($safety)? fn return_result(self, result: Result) { #[cfg(not(feature = "v2_64"))] unsafe extern "C" fn value_free(value: *mut libc::c_void) { let _: glib::Value = from_glib_full(value as *mut glib::gobject_ffi::GValue); } match result { #[cfg(feature = "v2_64")] Ok(v) => unsafe { ffi::g_task_return_value( self.to_glib_none().0, v.to_value().to_glib_none().0 as *mut _, ) }, #[cfg(not(feature = "v2_64"))] Ok(v) => unsafe { let v: glib::Value = v.into(); ffi::g_task_return_pointer( self.to_glib_none().0, >::into_glib_ptr(v) as glib::ffi::gpointer, Some(value_free), ) }, Err(e) => unsafe { ffi::g_task_return_error(self.to_glib_none().0, e.into_glib_ptr()); }, } } #[doc(alias = "g_task_propagate_value")] #[doc(alias = "g_task_propagate_boolean")] #[doc(alias = "g_task_propagate_int")] #[doc(alias = "g_task_propagate_pointer")] #[allow(unused_unsafe)] pub $($safety)? fn propagate(self) -> Result { let mut error = ptr::null_mut(); unsafe { #[cfg(feature = "v2_64")] { let mut value = glib::Value::uninitialized(); ffi::g_task_propagate_value( self.to_glib_none().0, value.to_glib_none_mut().0, &mut error, ); if error.is_null() { Ok(V::from_value(&value)) } else { Err(from_glib_full(error)) } } #[cfg(not(feature = "v2_64"))] { let value = ffi::g_task_propagate_pointer(self.to_glib_none().0, &mut error); if error.is_null() { let value = Option::::from_glib_full( value as *mut glib::gobject_ffi::GValue, ) .expect("Task::propagate() called before Task::return_result()"); Ok(V::from_value(&value)) } else { Err(from_glib_full(error)) } } } } } } } task_impl!(LocalTask); task_impl!(Task, @bound: Send, @safety: unsafe); impl Task { #[doc(alias = "g_task_run_in_thread")] pub fn run_in_thread(&self, task_func: Q) where S: IsA + Send, Q: FnOnce(Self, Option<&S>, Option<&Cancellable>) + Send + 'static, { let task_func_data = Box_::new(task_func); // We store the func pointer into the task data. // We intentionally do not expose a way to set the task data in the bindings. // If we detect that the task data is set, there is not much we can do, so we panic. unsafe { assert!( ffi::g_task_get_task_data(self.to_glib_none().0).is_null(), "Task data was manually set or the task was run thread multiple times" ); ffi::g_task_set_task_data( self.to_glib_none().0, Box_::into_raw(task_func_data) as *mut _, None, ); } unsafe extern "C" fn trampoline( task: *mut ffi::GTask, source_object: *mut glib::gobject_ffi::GObject, user_data: glib::ffi::gpointer, cancellable: *mut ffi::GCancellable, ) where V: ValueType + Send, S: IsA + Send, Q: FnOnce(Task, Option<&S>, Option<&Cancellable>) + Send + 'static, { let task = Task::from_glib_none(task); let source_object = Option::::from_glib_borrow(source_object); let cancellable = Option::::from_glib_borrow(cancellable); let task_func: Box_ = Box::from_raw(user_data as *mut _); task_func( task, source_object.as_ref().as_ref().map(|s| s.unsafe_cast_ref()), cancellable.as_ref().as_ref(), ); } let task_func = trampoline::; unsafe { ffi::g_task_run_in_thread(self.to_glib_none().0, Some(task_func)); } } } unsafe impl Send for Task {} unsafe impl Sync for Task {} // rustdoc-stripper-ignore-next /// A handle to a task running on the I/O thread pool. /// /// Like [`std::thread::JoinHandle`] for a blocking I/O task rather than a thread. The return value /// from the task can be retrieved by awaiting on this handle. Dropping the handle "detaches" the /// task, allowing it to complete but discarding the return value. #[derive(Debug)] pub struct JoinHandle { rx: oneshot::Receiver>, } impl JoinHandle { #[inline] fn new() -> (Self, oneshot::Sender>) { let (tx, rx) = oneshot::channel(); (Self { rx }, tx) } } impl Future for JoinHandle { type Output = std::thread::Result; #[inline] fn poll( mut self: std::pin::Pin<&mut Self>, cx: &mut std::task::Context<'_>, ) -> std::task::Poll { std::pin::Pin::new(&mut self.rx) .poll(cx) .map(|r| r.unwrap()) } } impl futures_core::FusedFuture for JoinHandle { #[inline] fn is_terminated(&self) -> bool { self.rx.is_terminated() } } // rustdoc-stripper-ignore-next /// Runs a blocking I/O task on the I/O thread pool. /// /// Calls `func` on the internal Gio thread pool for blocking I/O operations. The thread pool is /// shared with other Gio async I/O operations, and may rate-limit the tasks it receives. Callers /// may want to avoid blocking indefinitely by making sure blocking calls eventually time out. /// /// This function should not be used to spawn async tasks. Instead, use /// [`glib::MainContext::spawn`] or [`glib::MainContext::spawn_local`] to run a future. pub fn spawn_blocking(func: F) -> JoinHandle where T: Send + 'static, F: FnOnce() -> T + Send + 'static, { // use Cancellable::NONE as source obj to fulfill `Send` requirement let task = unsafe { Task::::new(Cancellable::NONE, Cancellable::NONE, |_, _| {}) }; let (join, tx) = JoinHandle::new(); task.run_in_thread(move |task, _: Option<&Cancellable>, _| { let res = panic::catch_unwind(panic::AssertUnwindSafe(func)); let _ = tx.send(res); unsafe { ffi::g_task_return_pointer(task.to_glib_none().0, ptr::null_mut(), None) } }); join } #[cfg(test)] mod test { use super::*; use crate::{prelude::*, test_util::run_async_local}; #[test] fn test_int_async_result() { let fut = run_async_local(|tx, l| { let cancellable = crate::Cancellable::new(); let task = unsafe { crate::LocalTask::new( None, Some(&cancellable), move |t: LocalTask, _b: Option<&glib::Object>| { tx.send(t.propagate()).unwrap(); l.quit(); }, ) }; task.return_result(Ok(100_i32)); }); match fut { Err(_) => panic!(), Ok(i) => assert_eq!(i, 100), } } #[test] fn test_object_async_result() { use glib::subclass::prelude::*; pub struct MySimpleObjectPrivate { pub size: std::cell::RefCell>, } #[glib::object_subclass] impl ObjectSubclass for MySimpleObjectPrivate { const NAME: &'static str = "MySimpleObjectPrivate"; type Type = MySimpleObject; fn new() -> Self { Self { size: std::cell::RefCell::new(Some(100)), } } } impl ObjectImpl for MySimpleObjectPrivate {} glib::wrapper! { pub struct MySimpleObject(ObjectSubclass); } impl MySimpleObject { pub fn new() -> Self { glib::Object::new() } #[doc(alias = "get_size")] pub fn size(&self) -> Option { *self.imp().size.borrow() } pub fn set_size(&self, size: i64) { self.imp().size.borrow_mut().replace(size); } } impl Default for MySimpleObject { fn default() -> Self { Self::new() } } let fut = run_async_local(|tx, l| { let cancellable = crate::Cancellable::new(); let task = unsafe { crate::LocalTask::new( None, Some(&cancellable), move |t: LocalTask, _b: Option<&glib::Object>| { tx.send(t.propagate()).unwrap(); l.quit(); }, ) }; let my_object = MySimpleObject::new(); my_object.set_size(100); task.return_result(Ok(my_object.upcast::())); }); match fut { Err(_) => panic!(), Ok(o) => { let o = o.downcast::().unwrap(); assert_eq!(o.size(), Some(100)); } } } #[test] fn test_error() { let fut = run_async_local(|tx, l| { let cancellable = crate::Cancellable::new(); let task = unsafe { crate::LocalTask::new( None, Some(&cancellable), move |t: LocalTask, _b: Option<&glib::Object>| { tx.send(t.propagate()).unwrap(); l.quit(); }, ) }; task.return_result(Err(glib::Error::new( crate::IOErrorEnum::WouldBlock, "WouldBlock", ))); }); match fut { Err(e) => match e.kind().unwrap() { crate::IOErrorEnum::WouldBlock => {} _ => panic!(), }, Ok(_) => panic!(), } } #[test] fn test_cancelled() { let fut = run_async_local(|tx, l| { let cancellable = crate::Cancellable::new(); let task = unsafe { crate::LocalTask::new( None, Some(&cancellable), move |t: LocalTask, _b: Option<&glib::Object>| { tx.send(t.propagate()).unwrap(); l.quit(); }, ) }; cancellable.cancel(); task.return_error_if_cancelled(); }); match fut { Err(e) => match e.kind().unwrap() { crate::IOErrorEnum::Cancelled => {} _ => panic!(), }, Ok(_) => panic!(), } } } gio-0.20.1/src/test_util.rs000064400000000000000000000016071046102023000136370ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(test)] use std::sync::mpsc::{channel, Sender}; #[cfg(test)] use glib::{MainContext, MainLoop}; #[cfg(test)] pub fn run_async, MainLoop) + Send + 'static>( start: Q, ) -> T { let c = MainContext::new(); let l = MainLoop::new(Some(&c), false); let l_clone = l.clone(); let (tx, rx) = channel(); c.spawn(async move { start(tx, l_clone); }); l.run(); rx.recv().unwrap() } #[cfg(test)] pub fn run_async_local, MainLoop) + Send + 'static>(start: Q) -> T { let c = MainContext::new(); let l = MainLoop::new(Some(&c), false); let l_clone = l.clone(); let (tx, rx) = channel(); c.spawn_local(async move { start(tx, l_clone); }); l.run(); rx.recv().unwrap() } gio-0.20.1/src/threaded_socket_service.rs000064400000000000000000000010541046102023000164670ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::{prelude::*, translate::*}; use crate::{SocketService, ThreadedSocketService}; impl ThreadedSocketService { #[doc(alias = "g_threaded_socket_service_new")] pub fn new(max_threads: Option) -> ThreadedSocketService { let max_threads = max_threads.map(|x| x as i32).unwrap_or(-1); unsafe { SocketService::from_glib_full(crate::ffi::g_threaded_socket_service_new(max_threads)) .unsafe_cast() } } } gio-0.20.1/src/tls_connection.rs000064400000000000000000000034521046102023000146440ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(feature = "v2_66")] use std::ptr; use glib::prelude::*; #[cfg(feature = "v2_60")] use glib::translate::*; #[cfg(feature = "v2_66")] use crate::TlsChannelBindingType; use crate::TlsConnection; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait TlsConnectionExtManual: sealed::Sealed + IsA { #[cfg(feature = "v2_66")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_66")))] #[doc(alias = "g_tls_connection_get_channel_binding_data")] #[doc(alias = "get_channel_binding_data")] fn channel_binding_data( &self, type_: TlsChannelBindingType, ) -> Result { unsafe { let data = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = crate::ffi::g_tls_connection_get_channel_binding_data( self.as_ptr() as *mut _, type_.into_glib(), data, &mut error, ); if error.is_null() { Ok(from_glib_none(data)) } else { Err(from_glib_full(error)) } } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_connection_set_advertised_protocols")] fn set_advertised_protocols(&self, protocols: impl IntoStrV) { unsafe { protocols.run_with_strv(|protocols| { crate::ffi::g_tls_connection_set_advertised_protocols( self.as_ref().to_glib_none().0, protocols.as_ptr() as *mut _, ); }) } } } impl> TlsConnectionExtManual for O {} gio-0.20.1/src/unix_fd_list.rs000064400000000000000000000052251046102023000143120ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; use std::{mem, ptr}; use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsRawFd, IntoRawFd, RawFd}; use crate::{ffi, UnixFDList}; impl UnixFDList { #[doc(alias = "g_unix_fd_list_new_from_array")] pub fn from_array(fds: impl IntoIterator) -> UnixFDList { let fds = fds.into_iter().map(|t| t.into_raw_fd()).collect::>(); unsafe { from_glib_full(ffi::g_unix_fd_list_new_from_array( fds.to_glib_none().0, fds.len() as i32, )) } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixFDListExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_unix_fd_list_append")] fn append(&self, fd: T) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_unix_fd_list_append( self.as_ref().to_glib_none().0, fd.as_raw_fd(), &mut error, ); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_unix_fd_list_get")] fn get(&self, index_: i32) -> Result { unsafe { let mut error = ptr::null_mut(); let ret = ffi::g_unix_fd_list_get(self.as_ref().to_glib_none().0, index_, &mut error); if error.is_null() { Ok(ret) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_unix_fd_list_peek_fds")] fn peek_fds(&self) -> Vec { unsafe { let mut length = mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_none_num( ffi::g_unix_fd_list_peek_fds(self.as_ref().to_glib_none().0, length.as_mut_ptr()), length.assume_init() as usize, ); ret } } #[doc(alias = "g_unix_fd_list_steal_fds")] fn steal_fds(&self) -> Vec { unsafe { let mut length = mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_full_num( ffi::g_unix_fd_list_steal_fds(self.as_ref().to_glib_none().0, length.as_mut_ptr()), length.assume_init() as usize, ); ret } } } impl> UnixFDListExtManual for O {} gio-0.20.1/src/unix_fd_message.rs000064400000000000000000000027601046102023000147640ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, RawFd}; use std::{mem, ptr}; use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsRawFd, RawFd}; use crate::{ffi, UnixFDMessage}; mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixFDMessageExtManual: sealed::Sealed + IsA + Sized { #[doc(alias = "g_unix_fd_message_append_fd")] fn append_fd(&self, fd: T) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); ffi::g_unix_fd_message_append_fd( self.as_ref().to_glib_none().0, fd.as_raw_fd(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_unix_fd_message_steal_fds")] fn steal_fds(&self) -> Vec { unsafe { let mut length = mem::MaybeUninit::uninit(); let ret = FromGlibContainer::from_glib_full_num( ffi::g_unix_fd_message_steal_fds( self.as_ref().to_glib_none().0, length.as_mut_ptr(), ), length.assume_init() as usize, ); ret } } } impl> UnixFDMessageExtManual for O {} gio-0.20.1/src/unix_input_stream.rs000064400000000000000000000046521046102023000154030ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsRawFd, IntoRawFd, RawFd}; use crate::{ffi, InputStream, UnixInputStream}; impl UnixInputStream { // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in fd. /// /// # Safety /// You must not close the fd unless you've previously called [`UnixInputStreamExtManual::set_close_fd`] /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_unix_input_stream_new")] pub unsafe fn take_fd(fd: impl IntoRawFd) -> UnixInputStream { let fd = fd.into_raw_fd(); let close_fd = true.into_glib(); InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() } // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that does not take ownership of the passed in fd. /// /// # Safety /// You may only close the fd if all references to this stream have been dropped. #[doc(alias = "g_unix_input_stream_new")] pub unsafe fn with_fd(fd: T) -> UnixInputStream { let fd = fd.as_raw_fd(); let close_fd = false.into_glib(); InputStream::from_glib_full(ffi::g_unix_input_stream_new(fd, close_fd)).unsafe_cast() } } impl AsRawFd for UnixInputStream { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_unix_input_stream_get_fd(self.to_glib_none().0) as _ } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixInputStreamExtManual: sealed::Sealed + IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// /// # Safety /// If you pass in `false` as the parameter, you may only close the fd if the all references /// to the stream have been dropped. If you pass in `true`, you must never call close. #[doc(alias = "g_unix_input_stream_set_close_fd")] unsafe fn set_close_fd(&self, close_fd: bool) { ffi::g_unix_input_stream_set_close_fd(self.as_ref().to_glib_none().0, close_fd.into_glib()); } } impl> UnixInputStreamExtManual for O {} gio-0.20.1/src/unix_mount_entry.rs000064400000000000000000000136311046102023000152510ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{cmp, mem}; use glib::{translate::*, GString}; use crate::{ffi, Icon, UnixMountEntry}; impl UnixMountEntry { #[doc(alias = "g_unix_mount_at")] #[doc(alias = "new_at")] pub fn for_mount_path>( mount_path: P, ) -> (Option, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_unix_mount_at( mount_path.as_ref().to_glib_none().0, time_read.as_mut_ptr(), )); let time_read = time_read.assume_init(); (ret, time_read) } } #[doc(alias = "g_unix_mount_for")] #[doc(alias = "new_for")] pub fn for_file_path>(file_path: P) -> (Option, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_unix_mount_for( file_path.as_ref().to_glib_none().0, time_read.as_mut_ptr(), )); let time_read = time_read.assume_init(); (ret, time_read) } } #[doc(alias = "g_unix_mounts_get")] #[doc(alias = "get_mounts")] pub fn mounts() -> (Vec, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mounts_get( time_read.as_mut_ptr(), )); let time_read = time_read.assume_init(); (ret, time_read) } } #[doc(alias = "g_unix_mount_compare")] pub fn compare(&self, mount2: &UnixMountEntry) -> i32 { unsafe { ffi::g_unix_mount_compare( mut_override(self.to_glib_none().0), mut_override(mount2.to_glib_none().0), ) } } #[doc(alias = "g_unix_mount_get_device_path")] #[doc(alias = "get_device_path")] pub fn device_path(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_unix_mount_get_device_path(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_get_fs_type")] #[doc(alias = "get_fs_type")] pub fn fs_type(&self) -> GString { unsafe { from_glib_none(ffi::g_unix_mount_get_fs_type(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_get_mount_path")] pub fn unix_mount_get_mount_path(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_unix_mount_get_mount_path(mut_override( self.to_glib_none().0, ))) } } #[cfg(feature = "v2_58")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_58")))] #[doc(alias = "g_unix_mount_get_options")] #[doc(alias = "get_options")] pub fn options(&self) -> Option { unsafe { from_glib_none(ffi::g_unix_mount_get_options(mut_override( self.to_glib_none().0, ))) } } #[cfg(feature = "v2_60")] #[cfg_attr(docsrs, doc(cfg(feature = "v2_60")))] #[doc(alias = "g_unix_mount_get_root_path")] #[doc(alias = "get_root_path")] pub fn root_path(&self) -> Option { unsafe { from_glib_none(ffi::g_unix_mount_get_root_path(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_guess_can_eject")] pub fn guess_can_eject(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_guess_can_eject(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_guess_icon")] pub fn guess_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_unix_mount_guess_icon(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_guess_name")] pub fn guess_name(&self) -> GString { unsafe { from_glib_full(ffi::g_unix_mount_guess_name(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_guess_should_display")] pub fn guess_should_display(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_guess_should_display(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_guess_symbolic_icon")] pub fn guess_symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_unix_mount_guess_symbolic_icon(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_is_readonly")] pub fn is_readonly(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_is_readonly(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mount_is_system_internal")] pub fn is_system_internal(&self) -> bool { unsafe { from_glib(ffi::g_unix_mount_is_system_internal(mut_override( self.to_glib_none().0, ))) } } #[doc(alias = "g_unix_mounts_changed_since")] pub fn is_changed_since(time: u64) -> bool { unsafe { from_glib(ffi::g_unix_mounts_changed_since(time)) } } } impl PartialEq for UnixMountEntry { #[inline] fn eq(&self, other: &Self) -> bool { self.compare(other) == 0 } } impl Eq for UnixMountEntry {} impl PartialOrd for UnixMountEntry { #[inline] fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) } } impl Ord for UnixMountEntry { #[inline] fn cmp(&self, other: &Self) -> cmp::Ordering { self.compare(other).cmp(&0) } } gio-0.20.1/src/unix_mount_point.rs000064400000000000000000000015171046102023000152410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::mem; use glib::translate::*; use crate::{ffi, UnixMountPoint}; impl UnixMountPoint { #[cfg(unix)] #[doc(alias = "g_unix_mount_points_get")] #[doc(alias = "get_mount_points")] pub fn mount_points() -> (Vec, u64) { unsafe { let mut time_read = mem::MaybeUninit::uninit(); let ret = FromGlibPtrContainer::from_glib_full(ffi::g_unix_mount_points_get( time_read.as_mut_ptr(), )); let time_read = time_read.assume_init(); (ret, time_read) } } #[doc(alias = "g_unix_mount_points_changed_since")] pub fn is_changed_since(time: u64) -> bool { unsafe { from_glib(ffi::g_unix_mount_points_changed_since(time)) } } } gio-0.20.1/src/unix_output_stream.rs000064400000000000000000000047261046102023000156060ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(unix)] use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; use glib::{prelude::*, translate::*}; #[cfg(all(not(unix), docsrs))] use socket::{AsRawFd, IntoRawFd, RawFd}; use crate::{ffi, OutputStream, UnixOutputStream}; impl UnixOutputStream { // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in fd. /// /// # Safety /// You must not close the fd unless you've previously called [`UnixOutputStreamExtManual::set_close_fd`] /// on this stream. At which point you may only do so when all references to this stream have /// been dropped. #[doc(alias = "g_unix_output_stream_new")] pub unsafe fn take_fd(fd: impl IntoRawFd) -> UnixOutputStream { let fd = fd.into_raw_fd(); let close_fd = true.into_glib(); OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() } // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that does not take ownership of the passed in fd. /// /// # Safety /// You may only close the fd if all references to this stream have been dropped. #[doc(alias = "g_unix_output_stream_new")] pub unsafe fn with_fd(fd: T) -> UnixOutputStream { let fd = fd.as_raw_fd(); let close_fd = false.into_glib(); OutputStream::from_glib_full(ffi::g_unix_output_stream_new(fd, close_fd)).unsafe_cast() } } impl AsRawFd for UnixOutputStream { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_unix_output_stream_get_fd(self.to_glib_none().0) as _ } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixOutputStreamExtManual: sealed::Sealed + IsA + Sized { // rustdoc-stripper-ignore-next /// Sets whether the fd of this stream will be closed when the stream is closed. /// /// # Safety /// If you pass in `false` as the parameter, you may only close the fd if the all references /// to the stream have been dropped. If you pass in `true`, you must never call close. #[doc(alias = "g_unix_output_stream_set_close_fd")] unsafe fn set_close_fd(&self, close_fd: bool) { ffi::g_unix_output_stream_set_close_fd( self.as_ref().to_glib_none().0, close_fd.into_glib(), ); } } impl> UnixOutputStreamExtManual for O {} gio-0.20.1/src/unix_socket_address.rs000064400000000000000000000076331046102023000156700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(not(docsrs))] use std::ffi::OsStr; #[cfg(unix)] #[cfg(not(docsrs))] use std::os::unix::ffi::OsStrExt; use std::{path, ptr, slice}; use glib::translate::*; use crate::{ffi, prelude::*, SocketAddress, UnixSocketAddress, UnixSocketAddressType}; #[derive(Debug)] pub enum UnixSocketAddressPath<'a> { Path(&'a path::Path), Anonymous, Abstract(&'a [u8]), AbstractPadded(&'a [u8]), } impl<'a> UnixSocketAddressPath<'a> { fn to_type(&self) -> UnixSocketAddressType { use self::UnixSocketAddressPath::*; match *self { Path(_) => UnixSocketAddressType::Path, Anonymous => UnixSocketAddressType::Anonymous, Abstract(_) => UnixSocketAddressType::Abstract, AbstractPadded(_) => UnixSocketAddressType::AbstractPadded, } } } impl UnixSocketAddress { #[doc(alias = "g_unix_socket_address_new")] pub fn new(path: &path::Path) -> UnixSocketAddress { unsafe { SocketAddress::from_glib_full(ffi::g_unix_socket_address_new(path.to_glib_none().0)) .unsafe_cast() } } #[doc(alias = "g_unix_socket_address_new_with_type")] pub fn with_type(address_type: UnixSocketAddressPath) -> Self { use self::UnixSocketAddressPath::*; let type_ = address_type.to_type(); let new = |ptr, len| unsafe { SocketAddress::from_glib_full(ffi::g_unix_socket_address_new_with_type( ptr, len, type_.into_glib(), )) .unsafe_cast() }; match address_type { Path(path) => new(path.to_glib_none().0, -1), Abstract(path) | AbstractPadded(path) => new( path.to_glib_none().0 as *mut libc::c_char, path.len() as i32, ), Anonymous => new(ptr::null_mut(), 0), } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait UnixSocketAddressExtManual: sealed::Sealed + IsA + 'static { #[doc(alias = "g_unix_socket_address_get_path")] #[doc(alias = "get_path")] fn path(&self) -> Option { use self::UnixSocketAddressPath::*; let path = unsafe { let path = ffi::g_unix_socket_address_get_path(self.as_ref().to_glib_none().0); if path.is_null() || self.path_len() == 0 { &[] } else { slice::from_raw_parts(path as *const u8, self.path_len()) } }; match self.address_type() { UnixSocketAddressType::Anonymous => Some(Anonymous), #[cfg(not(docsrs))] UnixSocketAddressType::Path => Some(Path(path::Path::new(OsStr::from_bytes(path)))), #[cfg(docsrs)] UnixSocketAddressType::Path => unreachable!(), UnixSocketAddressType::Abstract => Some(Abstract(path)), UnixSocketAddressType::AbstractPadded => Some(AbstractPadded(path)), UnixSocketAddressType::Invalid | UnixSocketAddressType::__Unknown(_) => None, } } } impl> UnixSocketAddressExtManual for O {} #[cfg(test)] mod test { use super::*; // Check the actual path and len are correct and are not the underlying OsString #[test] fn check_path() { let mut os_string = std::ffi::OsString::with_capacity(100); os_string.push("/tmp/foo"); let path = os_string.as_ref(); let addr = UnixSocketAddress::new(path); assert_eq!(addr.path_len(), 8); assert_eq!(addr.path_as_array().unwrap().as_ref(), b"/tmp/foo"); let addr = UnixSocketAddress::with_type(UnixSocketAddressPath::Path(path)); assert_eq!(addr.path_len(), 8); assert_eq!(addr.path_as_array().unwrap().as_ref(), b"/tmp/foo"); } } gio-0.20.1/src/win32_input_stream.rs000064400000000000000000000066311046102023000153610ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; use crate::{ffi, InputStream}; glib::wrapper! { pub struct Win32InputStream(Object) @extends InputStream; match fn { type_ => || ffi::g_win32_input_stream_get_type(), } } impl Win32InputStream { pub const NONE: Option<&'static Win32InputStream> = None; // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in handle. /// /// # Safety /// You must not close the handle unless you've previously called [`Win32InputStreamExtManual::set_close_handle`] /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_win32_input_stream_new")] pub unsafe fn take_handle(handle: impl IntoRawHandle) -> Win32InputStream { let handle = handle.into_raw_handle(); let close_handle = true.into_glib(); InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) .unsafe_cast() } // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that does not take ownership of the passed in handle. /// /// # Safety /// You may only close the handle if all references to this stream have been dropped. #[doc(alias = "g_win32_input_stream_new")] pub unsafe fn with_handle(handle: T) -> Win32InputStream { let handle = handle.as_raw_handle(); let close_handle = false.into_glib(); InputStream::from_glib_full(ffi::g_win32_input_stream_new(handle, close_handle)) .unsafe_cast() } } impl AsRawHandle for Win32InputStream { fn as_raw_handle(&self) -> RawHandle { unsafe { ffi::g_win32_input_stream_get_handle(self.to_glib_none().0) as _ } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait Win32InputStreamExt: sealed::Sealed + IsA + Sized { #[doc(alias = "g_win32_input_stream_get_close_handle")] #[doc(alias = "get_close_handle")] fn closes_handle(&self) -> bool { unsafe { from_glib(ffi::g_win32_input_stream_get_close_handle( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_win32_input_stream_get_handle")] #[doc(alias = "get_handle")] fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_input_stream_get_handle( self.as_ref().to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Sets whether the handle of this stream will be closed when the stream is closed. /// /// # Safety /// If you pass in `false` as the parameter, you may only close the handle if the all references /// to the stream have been dropped. If you pass in `true`, you must never call close. #[doc(alias = "g_win32_input_stream_set_close_handle")] unsafe fn set_close_handle(&self, close_handle: bool) { ffi::g_win32_input_stream_set_close_handle( self.as_ref().to_glib_none().0, close_handle.into_glib(), ); } } impl> Win32InputStreamExt for O {} gio-0.20.1/src/win32_output_stream.rs000064400000000000000000000066671046102023000155730ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; use glib::{prelude::*, translate::*}; use crate::{ffi, OutputStream}; glib::wrapper! { pub struct Win32OutputStream(Object) @extends OutputStream; match fn { type_ => || ffi::g_win32_output_stream_get_type(), } } impl Win32OutputStream { pub const NONE: Option<&'static Win32OutputStream> = None; // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that takes ownership of the passed in handle. /// /// # Safety /// You must not close the handle unless you've previously called [`Win32OutputStreamExtManual::set_close_handle`] /// with `true` on this stream. At which point you may only do so when all references to this /// stream have been dropped. #[doc(alias = "g_win32_output_stream_new")] pub unsafe fn take_handle(handle: impl IntoRawHandle) -> Win32OutputStream { let handle = handle.into_raw_handle(); let close_handle = true.into_glib(); OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) .unsafe_cast() } // rustdoc-stripper-ignore-next /// Creates a new [`Self`] that does not take ownership of the passed in handle. /// /// # Safety /// You may only close the handle if all references to this stream have been dropped. #[doc(alias = "g_win32_output_stream_new")] pub unsafe fn with_handle(handle: T) -> Win32OutputStream { let handle = handle.as_raw_handle(); let close_handle = false.into_glib(); OutputStream::from_glib_full(ffi::g_win32_output_stream_new(handle, close_handle)) .unsafe_cast() } } impl AsRawHandle for Win32OutputStream { fn as_raw_handle(&self) -> RawHandle { unsafe { ffi::g_win32_output_stream_get_handle(self.to_glib_none().0) as _ } } } mod sealed { pub trait Sealed {} impl> Sealed for T {} } pub trait Win32OutputStreamExt: sealed::Sealed + IsA + Sized { #[doc(alias = "g_win32_output_stream_get_close_handle")] #[doc(alias = "get_close_handle")] fn closes_handle(&self) -> bool { unsafe { from_glib(ffi::g_win32_output_stream_get_close_handle( self.as_ref().to_glib_none().0, )) } } #[doc(alias = "g_win32_output_stream_get_handle")] #[doc(alias = "get_handle")] fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_output_stream_get_handle( self.as_ref().to_glib_none().0, )) } } // rustdoc-stripper-ignore-next /// Sets whether the handle of this stream will be closed when the stream is closed. /// /// # Safety /// If you pass in `false` as the parameter, you may only close the handle if the all references /// to the stream have been dropped. If you pass in `true`, you must never call close. #[doc(alias = "g_win32_output_stream_set_close_handle")] unsafe fn set_close_handle(&self, close_handle: bool) { ffi::g_win32_output_stream_set_close_handle( self.as_ref().to_glib_none().0, close_handle.into_glib(), ); } } impl> Win32OutputStreamExt for O {} gio-0.20.1/src/write_output_stream.rs000064400000000000000000000247301046102023000157520ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use std::{ any::Any, io::{Seek, Write}, }; use crate::{ prelude::*, read_input_stream::std_error_to_gio_error, subclass::prelude::*, OutputStream, }; mod imp { use std::cell::RefCell; use super::*; pub(super) enum Writer { Write(AnyWriter), WriteSeek(AnyWriter), } #[derive(Default)] pub struct WriteOutputStream { pub(super) write: RefCell>, } #[glib::object_subclass] impl ObjectSubclass for WriteOutputStream { const NAME: &'static str = "WriteOutputStream"; const ALLOW_NAME_CONFLICT: bool = true; type Type = super::WriteOutputStream; type ParentType = OutputStream; type Interfaces = (crate::Seekable,); } impl ObjectImpl for WriteOutputStream {} impl OutputStreamImpl for WriteOutputStream { fn write( &self, buffer: &[u8], _cancellable: Option<&crate::Cancellable>, ) -> Result { let mut write = self.write.borrow_mut(); let write = match *write { None => { return Err(glib::Error::new( crate::IOErrorEnum::Closed, "Alwritey closed", )); } Some(Writer::Write(ref mut write)) => write, Some(Writer::WriteSeek(ref mut write)) => write, }; loop { match std_error_to_gio_error(write.write(buffer)) { None => continue, Some(res) => return res, } } } fn close(&self, _cancellable: Option<&crate::Cancellable>) -> Result<(), glib::Error> { let _ = self.write.take(); Ok(()) } fn flush(&self, _cancellable: Option<&crate::Cancellable>) -> Result<(), glib::Error> { let mut write = self.write.borrow_mut(); let write = match *write { None => { return Err(glib::Error::new( crate::IOErrorEnum::Closed, "Alwritey closed", )); } Some(Writer::Write(ref mut write)) => write, Some(Writer::WriteSeek(ref mut write)) => write, }; loop { match std_error_to_gio_error(write.flush()) { None => continue, Some(res) => return res, } } } } impl SeekableImpl for WriteOutputStream { fn tell(&self) -> i64 { // XXX: stream_position is not stable yet // let mut write = self.write.borrow_mut(); // match *write { // Some(Writer::WriteSeek(ref mut write)) => { // write.stream_position().map(|pos| pos as i64).unwrap_or(-1) // }, // _ => -1, // }; -1 } fn can_seek(&self) -> bool { let write = self.write.borrow(); matches!(*write, Some(Writer::WriteSeek(_))) } fn seek( &self, offset: i64, type_: glib::SeekType, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { use std::io::SeekFrom; let mut write = self.write.borrow_mut(); match *write { Some(Writer::WriteSeek(ref mut write)) => { let pos = match type_ { glib::SeekType::Cur => SeekFrom::Current(offset), glib::SeekType::Set => { if offset < 0 { return Err(glib::Error::new( crate::IOErrorEnum::InvalidArgument, "Invalid Argument", )); } else { SeekFrom::Start(offset as u64) } } glib::SeekType::End => SeekFrom::End(offset), _ => unimplemented!(), }; loop { match std_error_to_gio_error(write.seek(pos)) { None => continue, Some(res) => return res.map(|_| ()), } } } _ => Err(glib::Error::new( crate::IOErrorEnum::NotSupported, "Truncating not supported", )), } } fn can_truncate(&self) -> bool { false } fn truncate( &self, _offset: i64, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { Err(glib::Error::new( crate::IOErrorEnum::NotSupported, "Truncating not supported", )) } } } glib::wrapper! { pub struct WriteOutputStream(ObjectSubclass) @extends crate::OutputStream, @implements crate::Seekable; } impl WriteOutputStream { pub fn new(write: W) -> WriteOutputStream { let obj: Self = glib::Object::new(); *obj.imp().write.borrow_mut() = Some(imp::Writer::Write(AnyWriter::new(write))); obj } pub fn new_seekable(write: W) -> WriteOutputStream { let obj: Self = glib::Object::new(); *obj.imp().write.borrow_mut() = Some(imp::Writer::WriteSeek(AnyWriter::new_seekable(write))); obj } pub fn close_and_take(&self) -> Box { let inner = self.imp().write.take(); let ret = match inner { None => { panic!("Stream already closed or inner taken"); } Some(imp::Writer::Write(write)) => write.writer, Some(imp::Writer::WriteSeek(write)) => write.writer, }; let _ = self.close(crate::Cancellable::NONE); match ret { AnyOrPanic::Any(w) => w, AnyOrPanic::Panic(p) => std::panic::resume_unwind(p), } } } enum AnyOrPanic { Any(Box), Panic(Box), } // Helper struct for dynamically dispatching to any kind of Writer and // catching panics along the way struct AnyWriter { writer: AnyOrPanic, write_fn: fn(s: &mut AnyWriter, buffer: &[u8]) -> std::io::Result, flush_fn: fn(s: &mut AnyWriter) -> std::io::Result<()>, seek_fn: Option std::io::Result>, } impl AnyWriter { fn new(w: W) -> Self { Self { writer: AnyOrPanic::Any(Box::new(w)), write_fn: Self::write_fn::, flush_fn: Self::flush_fn::, seek_fn: None, } } fn new_seekable(w: W) -> Self { Self { writer: AnyOrPanic::Any(Box::new(w)), write_fn: Self::write_fn::, flush_fn: Self::flush_fn::, seek_fn: Some(Self::seek_fn::), } } fn write_fn(s: &mut AnyWriter, buffer: &[u8]) -> std::io::Result { s.with_inner(|w: &mut W| w.write(buffer)) } fn flush_fn(s: &mut AnyWriter) -> std::io::Result<()> { s.with_inner(|w: &mut W| w.flush()) } fn seek_fn( s: &mut AnyWriter, pos: std::io::SeekFrom, ) -> std::io::Result { s.with_inner(|w: &mut W| w.seek(pos)) } fn with_inner std::io::Result>( &mut self, func: F, ) -> std::io::Result { match self.writer { AnyOrPanic::Any(ref mut writer) => { let w = writer.downcast_mut::().unwrap(); match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| func(w))) { Ok(res) => res, Err(panic) => { self.writer = AnyOrPanic::Panic(panic); Err(std::io::Error::new(std::io::ErrorKind::Other, "Panicked")) } } } AnyOrPanic::Panic(_) => Err(std::io::Error::new( std::io::ErrorKind::Other, "Panicked before", )), } } fn write(&mut self, buffer: &[u8]) -> std::io::Result { (self.write_fn)(self, buffer) } fn flush(&mut self) -> std::io::Result<()> { (self.flush_fn)(self) } fn seek(&mut self, pos: std::io::SeekFrom) -> std::io::Result { if let Some(ref seek_fn) = self.seek_fn { seek_fn(self, pos) } else { unreachable!() } } } #[cfg(test)] mod tests { use std::io::Cursor; use super::*; #[test] fn test_write() { let cursor = Cursor::new(vec![]); let stream = WriteOutputStream::new(cursor); assert_eq!( stream.write(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], crate::Cancellable::NONE), Ok(10) ); let inner = stream.close_and_take(); assert!(inner.is::>>()); let inner = inner.downcast_ref::>>().unwrap(); assert_eq!(inner.get_ref(), &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); } #[test] fn test_write_seek() { let cursor = Cursor::new(vec![]); let stream = WriteOutputStream::new_seekable(cursor); assert_eq!( stream.write(&[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], crate::Cancellable::NONE), Ok(10) ); assert!(stream.can_seek()); assert_eq!( stream.seek(0, glib::SeekType::Set, crate::Cancellable::NONE), Ok(()) ); assert_eq!( stream.write( &[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], crate::Cancellable::NONE ), Ok(10) ); let inner = stream.close_and_take(); assert!(inner.is::>>()); let inner = inner.downcast_ref::>>().unwrap(); assert_eq!(inner.get_ref(), &[11, 12, 13, 14, 15, 16, 17, 18, 19, 20]); } } gio-0.20.1/tests/check_gir.rs000064400000000000000000000003461046102023000141130ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[test] fn check_gir_file() { let res = gir_format_check::check_gir_file("Gir.toml"); println!("{res}"); assert_eq!(res.nb_errors, 0); } gio-0.20.1/tests/com.github.gtk-rs.test.gschema.xml000064400000000000000000000005241046102023000202000ustar 00000000000000 "Good" true gio-0.20.1/tests/std_io_copy.rs000064400000000000000000000007771046102023000145200ustar 00000000000000use gio::prelude::*; #[test] fn std_io_copy_with_gio() { let bytes = glib::Bytes::from_owned([1, 2, 3]); let mut read = gio::MemoryInputStream::from_bytes(&bytes).into_read(); let mut write = gio::MemoryOutputStream::new_resizable().into_write(); let result = std::io::copy(&mut read, &mut write); let out_stream = write.into_output_stream(); out_stream.close(gio::Cancellable::NONE).unwrap(); assert_eq!(result.unwrap(), 3); assert_eq!(out_stream.steal_as_bytes(), bytes); }