gio-0.14.8/.cargo_vcs_info.json0000644000000001120000000000100116760ustar { "git": { "sha1": "9364a9538de344056ea14c2678229f76b197161e" } } gio-0.14.8/COPYRIGHT000064400000000000000000000012130072674642500120140ustar 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.14.8/Cargo.toml0000644000000037160000000000100077110ustar # 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 = "2018" name = "gio" version = "0.14.8" authors = ["The gtk-rs Project Developers"] build = "build.rs" exclude = ["gir-files/*"] 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] features = ["dox"] [lib] name = "gio" [dependencies.bitflags] version = "1.0" [dependencies.ffi] version = "0.14.0" package = "gio-sys" [dependencies.futures-channel] version = "0.3" [dependencies.futures-core] version = "0.3" default-features = false [dependencies.futures-io] version = "0.3" [dependencies.glib] version = "0.14.0" [dependencies.libc] version = "0.2" [dependencies.once_cell] version = "1.0" [dependencies.thiserror] version = "1" [dev-dependencies.futures-util] version = "0.3" features = ["io"] [dev-dependencies.gir-format-check] version = "^0.1" [dev-dependencies.serial_test] version = "0.5" [features] dox = ["ffi/dox", "glib/dox"] v2_50 = ["ffi/v2_50", "glib/v2_50"] v2_52 = ["v2_50", "ffi/v2_52", "glib/v2_52"] v2_54 = ["v2_52", "ffi/v2_54", "glib/v2_54"] v2_56 = ["v2_54", "ffi/v2_56", "glib/v2_56"] v2_58 = ["v2_56", "ffi/v2_58", "glib/v2_58"] v2_60 = ["v2_58", "ffi/v2_60", "glib/v2_60"] v2_62 = ["v2_60", "ffi/v2_62", "glib/v2_62"] v2_64 = ["v2_62", "ffi/v2_64", "glib/v2_64"] v2_66 = ["v2_64", "ffi/v2_66", "glib/v2_66"] gio-0.14.8/Cargo.toml.orig000064400000000000000000000025260072674642500134200ustar 00000000000000[package] name = "gio" license = "MIT" homepage = "https://gtk-rs.org/" authors = ["The gtk-rs Project Developers"] keywords = ["glib", "gio", "gtk-rs", "gnome"] readme = "README.md" documentation = "https://gtk-rs.org/gtk-rs-core/stable/latest/docs/gio/" version = "0.14.8" description = "Rust bindings for the Gio library" repository = "https://github.com/gtk-rs/gtk-rs-core" exclude = [ "gir-files/*", ] edition = "2018" build = "build.rs" [lib] name = "gio" [features] v2_50 = ["ffi/v2_50", "glib/v2_50"] v2_52 = ["v2_50", "ffi/v2_52", "glib/v2_52"] v2_54 = ["v2_52", "ffi/v2_54", "glib/v2_54"] v2_56 = ["v2_54", "ffi/v2_56", "glib/v2_56"] v2_58 = ["v2_56", "ffi/v2_58", "glib/v2_58"] v2_60 = ["v2_58", "ffi/v2_60", "glib/v2_60"] v2_62 = ["v2_60", "ffi/v2_62", "glib/v2_62"] v2_64 = ["v2_62", "ffi/v2_64", "glib/v2_64"] v2_66 = ["v2_64", "ffi/v2_66", "glib/v2_66"] dox = ["ffi/dox", "glib/dox"] [package.metadata.docs.rs] features = ["dox"] [dependencies] libc = "0.2" bitflags = "1.0" once_cell = "1.0" futures-core = { version = "0.3", default-features = false } futures-channel = "0.3" futures-io = "0.3" ffi = {package = "gio-sys", path = "./sys", version = "0.14.0"} glib = {version = "0.14.0", path = "../glib"} thiserror = "1" [dev-dependencies] futures-util = { version = "0.3", features = ["io"] } gir-format-check = "^0.1" serial_test = "0.5" gio-0.14.8/Gir.toml000064400000000000000000000756260072674642500121620ustar 00000000000000[options] girs_directories = ["../gir-files"] library = "Gio" version = "2.0" min_cfg_version = "2.48" target_path = "." work_mode = "normal" single_version_file = true deprecate_by_min_version = true trust_return_value_nullability = true generate = [ "Gio.Action", "Gio.ActionMap", "Gio.AppInfoCreateFlags", "Gio.AppInfoMonitor", "Gio.ApplicationFlags", "Gio.AskPasswordFlags", "Gio.AsyncResult", "Gio.BusNameOwnerFlags", "Gio.BusNameWatcherFlags", "Gio.BusType", "Gio.BytesIcon", "Gio.ConverterFlags", "Gio.ConverterResult", "Gio.CredentialsType", "Gio.DataStreamByteOrder", "Gio.DataStreamNewlineType", "Gio.DBusActionGroup", "Gio.DBusArgInfo", "Gio.DBusAuthObserver", "Gio.DBusCallFlags", "Gio.DBusCapabilityFlags", "Gio.DBusConnectionFlags", "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.DBusPropertyInfo", "Gio.DBusProxyFlags", "Gio.DBusSendMessageFlags", "Gio.DBusServer", "Gio.DBusServerFlags", "Gio.DBusSignalFlags", "Gio.DBusSignalInfo", "Gio.Drive", "Gio.DriveStartFlags", "Gio.DriveStartStopType", "Gio.Emblem", "Gio.EmblemedIcon", "Gio.EmblemOrigin", "Gio.FileAttributeStatus", "Gio.FileAttributeType", "Gio.FileCopyFlags", "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.IOErrorEnum", "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.PropertyAction", "Gio.Proxy", "Gio.ProxyResolver", "Gio.RemoteActionGroup", "Gio.Resolver", "Gio.ResolverNameLookupFlags", "Gio.ResolverRecordType", "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.SocketAddressEnumerator", "Gio.SocketClient", "Gio.SocketClientEvent", "Gio.SocketConnectable", "Gio.SocketConnection", "Gio.SocketFamily", "Gio.SocketListener", "Gio.SocketListenerEvent", "Gio.SocketProtocol", "Gio.SocketService", "Gio.SocketType", "Gio.SrvTarget", "Gio.SubprocessFlags", "Gio.TcpConnection", "Gio.TlsAuthenticationMode", "Gio.TlsBackend", "Gio.TlsCertificate", "Gio.TlsCertificateFlags", "Gio.TlsCertificateRequestFlags", "Gio.TlsChannelBindingType", "Gio.TlsClientConnection", "Gio.TlsDatabase", "Gio.TlsDatabaseLookupFlags", "Gio.TlsDatabaseVerifyFlags", "Gio.TlsFileDatabase", "Gio.TlsInteraction", "Gio.TlsInteractionResult", "Gio.TlsPasswordFlags", "Gio.TlsRehandshakeMode", "Gio.TlsServerConnection", "Gio.VolumeMonitor", "Gio.ZlibCompressor", "Gio.ZlibCompressorFormat", "Gio.ZlibDecompressor", ] ignore = [ ] manual = [ "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.String", "GLib.Variant", "GLib.VariantDict", "GLib.VariantType", "GObject.Closure", "GObject.Object", "GObject.Value", ] [[object]] name = "Gio.*" status = "generate" [[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]] name = "Gio.ActionGroup" status = "generate" [[object.function]] name = "query_action" ignore = true [[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]] 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.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" [[object.function]] name = "reset" #undefined behaviour ignore = true [[object.function]] name = "source_new" # Needs manual bindings for setting callback, etc ignore = 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" [[object.function]] name = "get_unix_user" cfg_condition = "unix" [object.function.return] use_return_for_result = true [[object.function]] name = "set_unix_user" cfg_condition = "unix" [[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" #redudant 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_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.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" [[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]] name = "Gio.DesktopAppInfo" status = "generate" 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]] name = "Gio.FileAttributeMatcher" status = "generate" [[object.function]] name = "enumerate_next" # Better API with `IntoIter` ignore = true [[object]] name = "Gio.FileEnumerator" status = "generate" [[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]] 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" 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.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" # 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 manual_traits = ["ListStoreExtManual"] [[object.function]] name = "insert_sorted" manual = true doc_trait_name = "ListStoreExtManual" [[object.function]] name = "sort" manual = true doc_trait_name = "ListStoreExtManual" [[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 shoud use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" # Users shoud 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 shoud use `next` (automatically renamed from `get_next`). ignore= true [[object.function]] name = "get_value" # Users shoud 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]] 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]] name = "Gio.ProxyAddress" status = "generate" concurrency = "send+sync" [[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" [[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 = "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.Socket" status = "generate" concurrency = "send-unique" 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.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.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]] name = "Gio.Task" status = "generate" [[object.function]] name = "new" #wrong prototype manual = true [[object.function]] name = "return_error" #wrong mutability manual = true [[object.function]] name = "get_priority" #wrong priority type manual = true [[object.function]] name = "set_priority" #wrong priority type manual = true [[object.function]] name = "get_task_data" #high level bindings should not manually touch task data ignore = true [[object.function]] name = "set_task_data" #high level bindings should not manually touch task data ignore = true [[object.function]] name = "run_in_thread" #needs custom impl for task func manual = true [[object.function]] name = "return_boolean" #not needed ignore = true [[object.function]] name = "propagate_boolean" #not needed ignore = true [[object.function]] name = "return_int" #not needed ignore = true [[object.function]] name = "propagate_int" #not needed ignore = true [[object.function]] name = "return_pointer" #not needed ignore = true [[object.function]] name = "propagate_pointer" #not needed ignore = true [[object.function]] name = "return_value" #wrong mutability manual = true [[object.function]] name = "propagate_value" #wrong mutability manual = true [[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.TlsConnection" status = "generate" manual_traits = ["TlsConnectionExtManual"] [[object.function]] name = "get_channel_binding_data" # Gir confuses the mutability of the data manual = true [[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.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.UnixInputStream" status = "generate" cfg_condition = "unix" manual_traits = ["UnixInputStreamExtManual"] [[object.function]] name = "new" # has to use RawFd manual = true [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks manual = true doc_trait_name = "UnixInputStreamExtManual" [[object.function]] name = "get_fd" # has to use RawFd manual = true doc_trait_name = "UnixInputStreamExtManual" [[object.property]] name = "fd" # has to use RawFd ignore = true [[object.property]] name = "close-fd" ignore = true [[object]] name = "Gio.UnixMountEntry" status = "generate" version = "2.54" cfg_condition = "unix" [[object.derive]] name = "Debug" [[object]] name = "Gio.UnixMountPoint" status = "generate" version = "2.54" 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 [[object.function]] name = "set_close_fd" # Can cause file descriptor leaks manual = true doc_trait_name = "UnixOutputStreamExtManual" [[object.function]] name = "get_fd" # has to use RawFd manual = true doc_trait_name = "UnixOutputStreamExtManual" [[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_icon" [object.function.return] nullable = false [[object.function]] name = "get_mount" # Avoid clash with the `mount` operation. bypass_auto_rename = true [[object.function]] name = "get_name" [object.function.return] nullable = false [[object.function]] name = "get_symbolic_icon" [object.function.return] nullable = false [[object]] name = "Gio.Win32InputStream" status = "manual" cfg_condition = "windows" manual_traits = ["Win32InputStreamExtManual"] [[object]] name = "Gio.Win32OutputStream" status = "manual" cfg_condition = "windows" manual_traits = ["Win32OutputStreamExtManual"] gio-0.14.8/LICENSE000064400000000000000000000020000072674642500115210ustar 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.14.8/README.md000064400000000000000000000021770072674642500120120ustar 00000000000000# gio __Rust__ bindings and wrappers for __GIO__, part of [gtk-rs-core](https://github.com/gtk-rs/gtk-rs-core). ## Minimum supported Rust version Currently, the minimum supported Rust version is `1.51.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://developer.gnome.org/gio/stable/) * [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.14.8/build.rs000064400000000000000000000002260072674642500121710ustar 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.14.8/src/app_info.rs000064400000000000000000000104060072674642500134550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::AppInfo; #[cfg(any(feature = "v2_60", feature = "dox"))] use crate::AppLaunchContext; #[cfg(any(feature = "v2_60", feature = "dox"))] use crate::Cancellable; use glib::object::IsA; #[cfg(any(feature = "v2_60", feature = "dox"))] use glib::translate::*; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg(any(feature = "v2_60", feature = "dox"))] use std::boxed::Box as Box_; #[cfg(any(feature = "v2_60", feature = "dox"))] use std::pin::Pin; #[cfg(any(feature = "v2_60", feature = "dox"))] use std::ptr; pub trait AppInfoExtManual: 'static { #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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>) + Send + 'static, >( &self, uris: &[&str], context: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn launch_uris_async_future + Clone + 'static>( &self, uris: &[&str], context: Option<&P>, ) -> Pin> + 'static>>; } impl> AppInfoExtManual for O { #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn launch_uris_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, uris: &[&str], context: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_<(R, *mut *mut libc::c_char)> = Box_::new((callback, uris.to_glib_full())); unsafe extern "C" fn launch_uris_async_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_<(R, *mut *mut libc::c_char)> = Box_::from_raw(user_data as *mut _); (callback.0)(result); glib::ffi::g_strfreev(callback.1); } 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn launch_uris_async_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); }, ); }, )) } } gio-0.14.8/src/application.rs000064400000000000000000000042440072674642500141700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Application; use crate::File; use glib::object::Cast; use glib::object::IsA; use glib::signal::{connect_raw, SignalHandlerId}; use glib::translate::*; use glib::GString; use std::boxed::Box as Box_; use std::mem::transmute; pub trait ApplicationExtManual { #[doc(alias = "g_application_run")] fn run(&self) -> i32; #[doc(alias = "g_application_run")] fn run_with_args>(&self, args: &[S]) -> i32; fn connect_open(&self, f: F) -> SignalHandlerId; } impl> ApplicationExtManual for O { fn run(&self) -> i32 { self.run_with_args(&std::env::args().collect::>()) } fn run_with_args>(&self, args: &[S]) -> i32 { let argv: Vec<&str> = args.iter().map(|a| a.as_ref()).collect(); let argc = argv.len() as i32; unsafe { ffi::g_application_run(self.as_ref().to_glib_none().0, argc, argv.to_glib_none().0) } } 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::<_, unsafe extern "C" fn()>( open_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.14.8/src/auto/action.rs000064400000000000000000000220360072674642500141110ustar 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GAction")] pub struct Action(Interface); match fn { type_ => || ffi::g_action_get_type(), } } impl Action { #[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, glib::Variant), glib::Error> { unsafe { let mut action_name = ptr::null_mut(); let mut target_value = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = ffi::g_action_parse_detailed_name( detailed_name.to_glib_none().0, &mut action_name, &mut target_value, &mut error, ); 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, )) } } } pub const NONE_ACTION: Option<&Action> = None; pub trait ActionExt: 'static { #[doc(alias = "g_action_activate")] fn activate(&self, parameter: Option<&glib::Variant>); #[doc(alias = "g_action_change_state")] fn change_state(&self, value: &glib::Variant); #[doc(alias = "g_action_get_enabled")] #[doc(alias = "get_enabled")] fn is_enabled(&self) -> bool; #[doc(alias = "g_action_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_action_get_parameter_type")] #[doc(alias = "get_parameter_type")] fn parameter_type(&self) -> Option; #[doc(alias = "g_action_get_state")] #[doc(alias = "get_state")] fn state(&self) -> Option; #[doc(alias = "g_action_get_state_hint")] #[doc(alias = "get_state_hint")] fn state_hint(&self) -> Option; #[doc(alias = "g_action_get_state_type")] #[doc(alias = "get_state_type")] fn state_type(&self) -> Option; #[doc(alias = "enabled")] fn connect_enabled_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "name")] fn connect_name_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "parameter-type")] fn connect_parameter_type_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "state")] fn connect_state_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "state-type")] fn connect_state_type_notify(&self, f: F) -> SignalHandlerId; } impl> ActionExt for O { fn activate(&self, parameter: Option<&glib::Variant>) { unsafe { ffi::g_action_activate(self.as_ref().to_glib_none().0, parameter.to_glib_none().0); } } 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); } } fn is_enabled(&self) -> bool { unsafe { from_glib(ffi::g_action_get_enabled(self.as_ref().to_glib_none().0)) } } fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_action_get_name(self.as_ref().to_glib_none().0)) } } fn parameter_type(&self) -> Option { unsafe { from_glib_none(ffi::g_action_get_parameter_type( self.as_ref().to_glib_none().0, )) } } fn state(&self) -> Option { unsafe { from_glib_full(ffi::g_action_get_state(self.as_ref().to_glib_none().0)) } } fn state_hint(&self) -> Option { unsafe { from_glib_full(ffi::g_action_get_state_hint(self.as_ref().to_glib_none().0)) } } fn state_type(&self) -> Option { unsafe { from_glib_none(ffi::g_action_get_state_type(self.as_ref().to_glib_none().0)) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_parameter_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_state_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Action { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Action") } } gio-0.14.8/src/auto/action_group.rs000064400000000000000000000303730072674642500153300ustar 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GActionGroup")] pub struct ActionGroup(Interface); match fn { type_ => || ffi::g_action_group_get_type(), } } pub const NONE_ACTION_GROUP: Option<&ActionGroup> = None; pub trait ActionGroupExt: 'static { #[doc(alias = "g_action_group_action_added")] fn action_added(&self, action_name: &str); #[doc(alias = "g_action_group_action_enabled_changed")] fn action_enabled_changed(&self, action_name: &str, enabled: bool); #[doc(alias = "g_action_group_action_removed")] fn action_removed(&self, action_name: &str); #[doc(alias = "g_action_group_action_state_changed")] fn action_state_changed(&self, action_name: &str, state: &glib::Variant); #[doc(alias = "g_action_group_activate_action")] fn activate_action(&self, action_name: &str, parameter: Option<&glib::Variant>); #[doc(alias = "g_action_group_change_action_state")] fn change_action_state(&self, action_name: &str, value: &glib::Variant); #[doc(alias = "g_action_group_get_action_enabled")] #[doc(alias = "get_action_enabled")] fn is_action_enabled(&self, action_name: &str) -> bool; #[doc(alias = "g_action_group_get_action_parameter_type")] #[doc(alias = "get_action_parameter_type")] fn action_parameter_type(&self, action_name: &str) -> Option; #[doc(alias = "g_action_group_get_action_state")] #[doc(alias = "get_action_state")] fn action_state(&self, action_name: &str) -> Option; #[doc(alias = "g_action_group_get_action_state_hint")] #[doc(alias = "get_action_state_hint")] fn action_state_hint(&self, action_name: &str) -> Option; #[doc(alias = "g_action_group_get_action_state_type")] #[doc(alias = "get_action_state_type")] fn action_state_type(&self, action_name: &str) -> Option; #[doc(alias = "g_action_group_has_action")] fn has_action(&self, action_name: &str) -> bool; #[doc(alias = "g_action_group_list_actions")] fn list_actions(&self) -> Vec; #[doc(alias = "action-added")] fn connect_action_added( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; #[doc(alias = "action-enabled-changed")] fn connect_action_enabled_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; #[doc(alias = "action-removed")] fn connect_action_removed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; #[doc(alias = "action-state-changed")] fn connect_action_state_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; } impl> ActionGroupExt for O { 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, ); } } 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(), ); } } 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, ); } } 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, ); } } 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, ); } } 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, ); } } 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, )) } } 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, )) } } 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, )) } } 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, )) } } 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, )) } } 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, )) } } fn list_actions(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_action_group_list_actions( self.as_ref().to_glib_none().0, )) } } 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( action_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( action_enabled_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( action_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( action_state_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ActionGroup") } } gio-0.14.8/src/auto/action_map.rs000064400000000000000000000041610072674642500147450ustar 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::Action; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GActionMap")] pub struct ActionMap(Interface); match fn { type_ => || ffi::g_action_map_get_type(), } } pub const NONE_ACTION_MAP: Option<&ActionMap> = None; pub trait ActionMapExt: 'static { #[doc(alias = "g_action_map_add_action")] fn add_action>(&self, action: &P); //#[doc(alias = "g_action_map_add_action_entries")] //fn add_action_entries(&self, entries: /*Ignored*/&[&ActionEntry], user_data: /*Unimplemented*/Option); #[doc(alias = "g_action_map_lookup_action")] fn lookup_action(&self, action_name: &str) -> Option; #[doc(alias = "g_action_map_remove_action")] fn remove_action(&self, action_name: &str); } impl> ActionMapExt for O { fn add_action>(&self, action: &P) { unsafe { ffi::g_action_map_add_action( self.as_ref().to_glib_none().0, action.as_ref().to_glib_none().0, ); } } //fn add_action_entries(&self, entries: /*Ignored*/&[&ActionEntry], user_data: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_action_map_add_action_entries() } //} 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, )) } } 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 fmt::Display for ActionMap { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ActionMap") } } gio-0.14.8/src/auto/app_info.rs000064400000000000000000000406520072674642500144330ustar 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::AppInfoCreateFlags; use crate::AppLaunchContext; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] use crate::AsyncResult; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] use crate::Cancellable; use crate::File; use crate::Icon; use glib::object::IsA; use glib::translate::*; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] use std::boxed::Box as Box_; use std::fmt; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GAppInfo")] pub struct AppInfo(Interface); match fn { type_ => || ffi::g_app_info_get_type(), } } impl AppInfo { #[doc(alias = "g_app_info_create_from_commandline")] pub fn create_from_commandline>( commandline: P, application_name: Option<&str>, flags: AppInfoCreateFlags, ) -> Result { unsafe { let mut error = 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(), )) } } #[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, )) } } #[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<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_app_info_launch_default_for_uri_async")] pub fn launch_default_for_uri_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( uri: &str, context: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn launch_default_for_uri_async_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 _, ); } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] pub fn launch_default_for_uri_async_future + Clone + 'static>( uri: &str, context: Option<&P>, ) -> 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); } } } pub const NONE_APP_INFO: Option<&AppInfo> = None; pub trait AppInfoExt: 'static { #[doc(alias = "g_app_info_add_supports_type")] fn add_supports_type(&self, content_type: &str) -> Result<(), glib::Error>; #[doc(alias = "g_app_info_can_delete")] fn can_delete(&self) -> bool; #[doc(alias = "g_app_info_can_remove_supports_type")] fn can_remove_supports_type(&self) -> bool; #[doc(alias = "g_app_info_delete")] fn delete(&self) -> bool; #[doc(alias = "g_app_info_dup")] fn dup(&self) -> AppInfo; #[doc(alias = "g_app_info_equal")] fn equal>(&self, appinfo2: &P) -> bool; #[doc(alias = "g_app_info_get_commandline")] #[doc(alias = "get_commandline")] fn commandline(&self) -> Option; #[doc(alias = "g_app_info_get_description")] #[doc(alias = "get_description")] fn description(&self) -> Option; #[doc(alias = "g_app_info_get_display_name")] #[doc(alias = "get_display_name")] fn display_name(&self) -> glib::GString; #[doc(alias = "g_app_info_get_executable")] #[doc(alias = "get_executable")] fn executable(&self) -> std::path::PathBuf; #[doc(alias = "g_app_info_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Option; #[doc(alias = "g_app_info_get_id")] #[doc(alias = "get_id")] fn id(&self) -> Option; #[doc(alias = "g_app_info_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_app_info_get_supported_types")] #[doc(alias = "get_supported_types")] fn supported_types(&self) -> Vec; #[doc(alias = "g_app_info_launch")] fn launch>( &self, files: &[File], context: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_app_info_launch_uris")] fn launch_uris>( &self, uris: &[&str], context: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_app_info_remove_supports_type")] fn remove_supports_type(&self, content_type: &str) -> Result<(), glib::Error>; #[doc(alias = "g_app_info_set_as_default_for_extension")] fn set_as_default_for_extension>( &self, extension: P, ) -> Result<(), glib::Error>; #[doc(alias = "g_app_info_set_as_default_for_type")] fn set_as_default_for_type(&self, content_type: &str) -> Result<(), glib::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>; #[doc(alias = "g_app_info_should_show")] fn should_show(&self) -> bool; #[doc(alias = "g_app_info_supports_files")] fn supports_files(&self) -> bool; #[doc(alias = "g_app_info_supports_uris")] fn supports_uris(&self) -> bool; } impl> AppInfoExt for O { fn add_supports_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_app_info_add_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn can_delete(&self) -> bool { unsafe { from_glib(ffi::g_app_info_can_delete(self.as_ref().to_glib_none().0)) } } 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, )) } } fn delete(&self) -> bool { unsafe { from_glib(ffi::g_app_info_delete(self.as_ref().to_glib_none().0)) } } fn dup(&self) -> AppInfo { unsafe { from_glib_full(ffi::g_app_info_dup(self.as_ref().to_glib_none().0)) } } fn equal>(&self, appinfo2: &P) -> bool { unsafe { from_glib(ffi::g_app_info_equal( self.as_ref().to_glib_none().0, appinfo2.as_ref().to_glib_none().0, )) } } fn commandline(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_commandline( self.as_ref().to_glib_none().0, )) } } fn description(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_description( self.as_ref().to_glib_none().0, )) } } fn display_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_app_info_get_display_name( self.as_ref().to_glib_none().0, )) } } fn executable(&self) -> std::path::PathBuf { unsafe { from_glib_none(ffi::g_app_info_get_executable( self.as_ref().to_glib_none().0, )) } } fn icon(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_icon(self.as_ref().to_glib_none().0)) } } fn id(&self) -> Option { unsafe { from_glib_none(ffi::g_app_info_get_id(self.as_ref().to_glib_none().0)) } } fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_app_info_get_name(self.as_ref().to_glib_none().0)) } } fn supported_types(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_app_info_get_supported_types( self.as_ref().to_glib_none().0, )) } } fn launch>( &self, files: &[File], context: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn launch_uris>( &self, uris: &[&str], context: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn remove_supports_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_app_info_remove_supports_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_default_for_extension>( &self, extension: P, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_default_for_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_app_info_set_as_default_for_type( self.as_ref().to_glib_none().0, content_type.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_as_last_used_for_type(&self, content_type: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn should_show(&self) -> bool { unsafe { from_glib(ffi::g_app_info_should_show(self.as_ref().to_glib_none().0)) } } fn supports_files(&self) -> bool { unsafe { from_glib(ffi::g_app_info_supports_files( self.as_ref().to_glib_none().0, )) } } fn supports_uris(&self) -> bool { unsafe { from_glib(ffi::g_app_info_supports_uris( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for AppInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("AppInfo") } } gio-0.14.8/src/auto/app_info_monitor.rs000064400000000000000000000031320072674642500161720ustar 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 glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for AppInfoMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("AppInfoMonitor") } } gio-0.14.8/src/auto/app_launch_context.rs000064400000000000000000000144030072674642500165110ustar 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::AppInfo; use crate::File; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GAppLaunchContext")] pub struct AppLaunchContext(Object); match fn { type_ => || ffi::g_app_launch_context_get_type(), } } impl AppLaunchContext { #[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() } } pub const NONE_APP_LAUNCH_CONTEXT: Option<&AppLaunchContext> = None; pub trait AppLaunchContextExt: 'static { #[doc(alias = "g_app_launch_context_get_display")] #[doc(alias = "get_display")] fn display>(&self, info: &P, files: &[File]) -> Option; #[doc(alias = "g_app_launch_context_get_environment")] #[doc(alias = "get_environment")] fn environment(&self) -> Vec; #[doc(alias = "g_app_launch_context_get_startup_notify_id")] #[doc(alias = "get_startup_notify_id")] fn startup_notify_id>(&self, info: &P, files: &[File]) -> Option; #[doc(alias = "g_app_launch_context_launch_failed")] fn launch_failed(&self, startup_notify_id: &str); #[doc(alias = "g_app_launch_context_setenv")] fn setenv, Q: AsRef>(&self, variable: P, value: Q); #[doc(alias = "g_app_launch_context_unsetenv")] fn unsetenv>(&self, variable: P); #[doc(alias = "launch-failed")] fn connect_launch_failed(&self, f: F) -> SignalHandlerId; #[doc(alias = "launched")] fn connect_launched( &self, f: F, ) -> SignalHandlerId; } impl> AppLaunchContextExt for O { fn display>(&self, info: &P, 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, )) } } fn environment(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_app_launch_context_get_environment( self.as_ref().to_glib_none().0, )) } } fn startup_notify_id>( &self, info: &P, 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, )) } } 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, ); } } fn setenv, Q: AsRef>(&self, variable: P, value: Q) { 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, ); } } fn unsetenv>(&self, variable: P) { unsafe { ffi::g_app_launch_context_unsetenv( self.as_ref().to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( launch_failed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( launched_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for AppLaunchContext { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("AppLaunchContext") } } gio-0.14.8/src/auto/application.rs000064400000000000000000000760220072674642500151430ustar 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::ActionGroup; use crate::ActionMap; use crate::ApplicationCommandLine; use crate::ApplicationFlags; use crate::Cancellable; use crate::DBusConnection; use crate::File; use crate::Notification; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GApplication")] pub struct Application(Object) @implements ActionGroup, ActionMap; match fn { type_ => || ffi::g_application_get_type(), } } impl Application { #[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`] which can be used to create [`Application`] objects. pub fn builder() -> ApplicationBuilder { ApplicationBuilder::default() } #[doc(alias = "g_application_get_default")] #[doc(alias = "get_default")] 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, )) } } } #[derive(Clone, Default)] // 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 pub struct ApplicationBuilder { action_group: Option, application_id: Option, flags: Option, inactivity_timeout: Option, resource_base_path: Option, } impl ApplicationBuilder { // rustdoc-stripper-ignore-next /// Create a new [`ApplicationBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`Application`]. pub fn build(self) -> Application { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref action_group) = self.action_group { properties.push(("action-group", action_group)); } if let Some(ref application_id) = self.application_id { properties.push(("application-id", application_id)); } if let Some(ref flags) = self.flags { properties.push(("flags", flags)); } if let Some(ref inactivity_timeout) = self.inactivity_timeout { properties.push(("inactivity-timeout", inactivity_timeout)); } if let Some(ref resource_base_path) = self.resource_base_path { properties.push(("resource-base-path", resource_base_path)); } glib::Object::new::(&properties) .expect("Failed to create an instance of Application") } pub fn action_group>(mut self, action_group: &P) -> Self { self.action_group = Some(action_group.clone().upcast()); self } pub fn application_id(mut self, application_id: &str) -> Self { self.application_id = Some(application_id.to_string()); self } pub fn flags(mut self, flags: ApplicationFlags) -> Self { self.flags = Some(flags); self } pub fn inactivity_timeout(mut self, inactivity_timeout: u32) -> Self { self.inactivity_timeout = Some(inactivity_timeout); self } pub fn resource_base_path(mut self, resource_base_path: &str) -> Self { self.resource_base_path = Some(resource_base_path.to_string()); self } } pub const NONE_APPLICATION: Option<&Application> = None; pub trait ApplicationExt: 'static { #[doc(alias = "g_application_activate")] fn activate(&self); #[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>, ); //#[doc(alias = "g_application_add_main_option_entries")] //fn add_main_option_entries(&self, entries: /*Ignored*/&[&glib::OptionEntry]); //#[doc(alias = "g_application_add_option_group")] //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup); #[doc(alias = "g_application_bind_busy_property")] fn bind_busy_property>(&self, object: &P, property: &str); #[doc(alias = "g_application_get_application_id")] #[doc(alias = "get_application_id")] fn application_id(&self) -> Option; #[doc(alias = "g_application_get_dbus_connection")] #[doc(alias = "get_dbus_connection")] fn dbus_connection(&self) -> Option; #[doc(alias = "g_application_get_dbus_object_path")] #[doc(alias = "get_dbus_object_path")] fn dbus_object_path(&self) -> Option; #[doc(alias = "g_application_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> ApplicationFlags; #[doc(alias = "g_application_get_inactivity_timeout")] #[doc(alias = "get_inactivity_timeout")] fn inactivity_timeout(&self) -> u32; #[doc(alias = "g_application_get_is_busy")] #[doc(alias = "get_is_busy")] fn is_busy(&self) -> bool; #[doc(alias = "g_application_get_is_registered")] #[doc(alias = "get_is_registered")] fn is_registered(&self) -> bool; #[doc(alias = "g_application_get_is_remote")] #[doc(alias = "get_is_remote")] fn is_remote(&self) -> bool; #[doc(alias = "g_application_get_resource_base_path")] #[doc(alias = "get_resource_base_path")] fn resource_base_path(&self) -> Option; #[doc(alias = "g_application_hold")] fn hold(&self); #[doc(alias = "g_application_mark_busy")] fn mark_busy(&self); #[doc(alias = "g_application_open")] fn open(&self, files: &[File], hint: &str); #[doc(alias = "g_application_quit")] fn quit(&self); #[doc(alias = "g_application_register")] fn register>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_application_release")] fn release(&self); #[doc(alias = "g_application_send_notification")] fn send_notification(&self, id: Option<&str>, notification: &Notification); #[doc(alias = "g_application_set_application_id")] fn set_application_id(&self, application_id: Option<&str>); #[doc(alias = "g_application_set_default")] fn set_default(&self); #[doc(alias = "g_application_set_flags")] fn set_flags(&self, flags: ApplicationFlags); #[doc(alias = "g_application_set_inactivity_timeout")] fn set_inactivity_timeout(&self, inactivity_timeout: u32); #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_application_set_option_context_description")] fn set_option_context_description(&self, description: Option<&str>); #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_application_set_option_context_parameter_string")] fn set_option_context_parameter_string(&self, parameter_string: Option<&str>); #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_application_set_option_context_summary")] fn set_option_context_summary(&self, summary: Option<&str>); #[doc(alias = "g_application_set_resource_base_path")] fn set_resource_base_path(&self, resource_path: Option<&str>); #[doc(alias = "g_application_unbind_busy_property")] fn unbind_busy_property>(&self, object: &P, property: &str); #[doc(alias = "g_application_unmark_busy")] fn unmark_busy(&self); #[doc(alias = "g_application_withdraw_notification")] fn withdraw_notification(&self, id: &str); #[doc(alias = "action-group")] fn set_action_group>(&self, action_group: Option<&P>); #[doc(alias = "activate")] fn connect_activate(&self, f: F) -> SignalHandlerId; #[doc(alias = "command-line")] fn connect_command_line i32 + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "handle-local-options")] fn connect_handle_local_options i32 + 'static>( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "name-lost")] fn connect_name_lost bool + 'static>(&self, f: F) -> SignalHandlerId; #[doc(alias = "shutdown")] fn connect_shutdown(&self, f: F) -> SignalHandlerId; #[doc(alias = "startup")] fn connect_startup(&self, f: F) -> SignalHandlerId; #[doc(alias = "action-group")] fn connect_action_group_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "application-id")] fn connect_application_id_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "flags")] fn connect_flags_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "inactivity-timeout")] fn connect_inactivity_timeout_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "is-busy")] fn connect_is_busy_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "is-registered")] fn connect_is_registered_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "is-remote")] fn connect_is_remote_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "resource-base-path")] fn connect_resource_base_path_notify(&self, f: F) -> SignalHandlerId; } impl> ApplicationExt for O { fn activate(&self) { unsafe { ffi::g_application_activate(self.as_ref().to_glib_none().0); } } 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, ); } } //fn add_main_option_entries(&self, entries: /*Ignored*/&[&glib::OptionEntry]) { // unsafe { TODO: call ffi:g_application_add_main_option_entries() } //} //fn add_option_group(&self, group: /*Ignored*/&glib::OptionGroup) { // unsafe { TODO: call ffi:g_application_add_option_group() } //} fn bind_busy_property>(&self, object: &P, 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, ); } } fn application_id(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_application_id( self.as_ref().to_glib_none().0, )) } } fn dbus_connection(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_dbus_connection( self.as_ref().to_glib_none().0, )) } } fn dbus_object_path(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_dbus_object_path( self.as_ref().to_glib_none().0, )) } } fn flags(&self) -> ApplicationFlags { unsafe { from_glib(ffi::g_application_get_flags(self.as_ref().to_glib_none().0)) } } fn inactivity_timeout(&self) -> u32 { unsafe { ffi::g_application_get_inactivity_timeout(self.as_ref().to_glib_none().0) } } fn is_busy(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_busy( self.as_ref().to_glib_none().0, )) } } fn is_registered(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_registered( self.as_ref().to_glib_none().0, )) } } fn is_remote(&self) -> bool { unsafe { from_glib(ffi::g_application_get_is_remote( self.as_ref().to_glib_none().0, )) } } fn resource_base_path(&self) -> Option { unsafe { from_glib_none(ffi::g_application_get_resource_base_path( self.as_ref().to_glib_none().0, )) } } fn hold(&self) { unsafe { ffi::g_application_hold(self.as_ref().to_glib_none().0); } } fn mark_busy(&self) { unsafe { ffi::g_application_mark_busy(self.as_ref().to_glib_none().0); } } fn open(&self, files: &[File], hint: &str) { let n_files = files.len() as i32; unsafe { ffi::g_application_open( self.as_ref().to_glib_none().0, files.to_glib_none().0, n_files, hint.to_glib_none().0, ); } } fn quit(&self) { unsafe { ffi::g_application_quit(self.as_ref().to_glib_none().0); } } fn register>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_application_register( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn release(&self) { unsafe { ffi::g_application_release(self.as_ref().to_glib_none().0); } } 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, ); } } 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, ); } } fn set_default(&self) { unsafe { ffi::g_application_set_default(self.as_ref().to_glib_none().0); } } fn set_flags(&self, flags: ApplicationFlags) { unsafe { ffi::g_application_set_flags(self.as_ref().to_glib_none().0, flags.into_glib()); } } fn set_inactivity_timeout(&self, inactivity_timeout: u32) { unsafe { ffi::g_application_set_inactivity_timeout( self.as_ref().to_glib_none().0, inactivity_timeout, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] 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, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] 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, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] 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, ); } } 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, ); } } fn unbind_busy_property>(&self, object: &P, 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, ); } } fn unmark_busy(&self) { unsafe { ffi::g_application_unmark_busy(self.as_ref().to_glib_none().0); } } fn withdraw_notification(&self, id: &str) { unsafe { ffi::g_application_withdraw_notification( self.as_ref().to_glib_none().0, id.to_glib_none().0, ); } } fn set_action_group>(&self, action_group: Option<&P>) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"action-group\0".as_ptr() as *const _, action_group.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( activate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( command_line_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( handle_local_options_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 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(transmute::<_, unsafe extern "C" fn()>( name_lost_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( shutdown_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( startup_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_action_group_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_action_group_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::action-group\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_action_group_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_application_id_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_inactivity_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_busy_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_registered_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_remote_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_resource_base_path_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Application { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Application") } } gio-0.14.8/src/auto/application_command_line.rs000064400000000000000000000156440072674642500176530ustar 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::File; use crate::InputStream; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GApplicationCommandLine")] pub struct ApplicationCommandLine(Object); match fn { type_ => || ffi::g_application_command_line_get_type(), } } pub const NONE_APPLICATION_COMMAND_LINE: Option<&ApplicationCommandLine> = None; pub trait ApplicationCommandLineExt: 'static { #[doc(alias = "g_application_command_line_create_file_for_arg")] fn create_file_for_arg>(&self, arg: P) -> File; #[doc(alias = "g_application_command_line_get_arguments")] #[doc(alias = "get_arguments")] fn arguments(&self) -> Vec; #[doc(alias = "g_application_command_line_get_cwd")] #[doc(alias = "get_cwd")] fn cwd(&self) -> Option; #[doc(alias = "g_application_command_line_get_environ")] #[doc(alias = "get_environ")] fn environ(&self) -> Vec; #[doc(alias = "g_application_command_line_get_exit_status")] #[doc(alias = "get_exit_status")] fn exit_status(&self) -> i32; #[doc(alias = "g_application_command_line_get_is_remote")] #[doc(alias = "get_is_remote")] fn is_remote(&self) -> bool; #[doc(alias = "g_application_command_line_get_options_dict")] #[doc(alias = "get_options_dict")] fn options_dict(&self) -> glib::VariantDict; #[doc(alias = "g_application_command_line_get_platform_data")] #[doc(alias = "get_platform_data")] fn platform_data(&self) -> Option; #[doc(alias = "g_application_command_line_get_stdin")] #[doc(alias = "get_stdin")] fn stdin(&self) -> Option; #[doc(alias = "g_application_command_line_getenv")] fn getenv>(&self, name: P) -> Option; //#[doc(alias = "g_application_command_line_print")] //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); //#[doc(alias = "g_application_command_line_printerr")] //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); #[doc(alias = "g_application_command_line_set_exit_status")] fn set_exit_status(&self, exit_status: i32); #[doc(alias = "is-remote")] fn connect_is_remote_notify(&self, f: F) -> SignalHandlerId; } impl> ApplicationCommandLineExt for O { fn create_file_for_arg>(&self, arg: P) -> 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, )) } } fn arguments(&self) -> Vec { unsafe { let mut argc = 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 usize, ); ret } } fn cwd(&self) -> Option { unsafe { from_glib_none(ffi::g_application_command_line_get_cwd( self.as_ref().to_glib_none().0, )) } } fn environ(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_application_command_line_get_environ( self.as_ref().to_glib_none().0, )) } } fn exit_status(&self) -> i32 { unsafe { ffi::g_application_command_line_get_exit_status(self.as_ref().to_glib_none().0) } } fn is_remote(&self) -> bool { unsafe { from_glib(ffi::g_application_command_line_get_is_remote( self.as_ref().to_glib_none().0, )) } } 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, )) } } fn platform_data(&self) -> Option { unsafe { from_glib_full(ffi::g_application_command_line_get_platform_data( self.as_ref().to_glib_none().0, )) } } fn stdin(&self) -> Option { unsafe { from_glib_full(ffi::g_application_command_line_get_stdin( self.as_ref().to_glib_none().0, )) } } fn getenv>(&self, name: P) -> 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, )) } } //fn print(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:g_application_command_line_print() } //} //fn printerr(&self, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:g_application_command_line_printerr() } //} 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, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_remote_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ApplicationCommandLine { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ApplicationCommandLine") } } gio-0.14.8/src/auto/async_result.rs000064400000000000000000000043350072674642500153510ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GAsyncResult")] pub struct AsyncResult(Interface); match fn { type_ => || ffi::g_async_result_get_type(), } } pub const NONE_ASYNC_RESULT: Option<&AsyncResult> = None; pub trait AsyncResultExt: 'static { #[doc(alias = "g_async_result_get_source_object")] #[doc(alias = "get_source_object")] fn source_object(&self) -> Option; //#[doc(alias = "g_async_result_get_user_data")] //#[doc(alias = "get_user_data")] //fn user_data(&self) -> /*Unimplemented*/Option; //#[doc(alias = "g_async_result_is_tagged")] //fn is_tagged(&self, source_tag: /*Unimplemented*/Option) -> bool; #[doc(alias = "g_async_result_legacy_propagate_error")] fn legacy_propagate_error(&self) -> Result<(), glib::Error>; } impl> AsyncResultExt for O { fn source_object(&self) -> Option { unsafe { from_glib_full(ffi::g_async_result_get_source_object( self.as_ref().to_glib_none().0, )) } } //fn user_data(&self) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_async_result_get_user_data() } //} //fn is_tagged(&self, source_tag: /*Unimplemented*/Option) -> bool { // unsafe { TODO: call ffi:g_async_result_is_tagged() } //} fn legacy_propagate_error(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_async_result_legacy_propagate_error( self.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl fmt::Display for AsyncResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("AsyncResult") } } gio-0.14.8/src/auto/buffered_input_stream.rs000064400000000000000000000241450072674642500172130ustar 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::AsyncResult; use crate::Cancellable; use crate::FilterInputStream; use crate::InputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::pin::Pin; use std::ptr; 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 { #[doc(alias = "g_buffered_input_stream_new")] pub fn new>(base_stream: &P) -> 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: &P, 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`] which can be used to create [`BufferedInputStream`] objects. pub fn builder() -> BufferedInputStreamBuilder { BufferedInputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct BufferedInputStreamBuilder { buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl BufferedInputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`BufferedInputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`BufferedInputStream`]. pub fn build(self) -> BufferedInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of BufferedInputStream") } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_BUFFERED_INPUT_STREAM: Option<&BufferedInputStream> = None; pub trait BufferedInputStreamExt: 'static { #[doc(alias = "g_buffered_input_stream_fill")] fn fill>( &self, count: isize, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_buffered_input_stream_fill_async")] fn fill_async, Q: FnOnce(Result) + Send + 'static>( &self, count: isize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn fill_async_future( &self, count: isize, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_buffered_input_stream_get_available")] #[doc(alias = "get_available")] fn available(&self) -> usize; #[doc(alias = "g_buffered_input_stream_get_buffer_size")] #[doc(alias = "get_buffer_size")] fn buffer_size(&self) -> usize; #[doc(alias = "g_buffered_input_stream_peek_buffer")] fn peek_buffer(&self) -> Vec; #[doc(alias = "g_buffered_input_stream_read_byte")] fn read_byte>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_buffered_input_stream_set_buffer_size")] fn set_buffer_size(&self, size: usize); #[doc(alias = "buffer-size")] fn connect_buffer_size_notify(&self, f: F) -> SignalHandlerId; } impl> BufferedInputStreamExt for O { fn fill>( &self, count: isize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn fill_async, Q: FnOnce(Result) + Send + 'static>( &self, count: isize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn fill_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn available(&self) -> usize { unsafe { ffi::g_buffered_input_stream_get_available(self.as_ref().to_glib_none().0) } } fn buffer_size(&self) -> usize { unsafe { ffi::g_buffered_input_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } fn peek_buffer(&self) -> Vec { unsafe { let mut count = 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 usize, ); ret } } fn read_byte>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn set_buffer_size(&self, size: usize) { unsafe { ffi::g_buffered_input_stream_set_buffer_size(self.as_ref().to_glib_none().0, 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(transmute::<_, unsafe extern "C" fn()>( notify_buffer_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for BufferedInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("BufferedInputStream") } } gio-0.14.8/src/auto/buffered_output_stream.rs000064400000000000000000000167110072674642500174140ustar 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::FilterOutputStream; use crate::OutputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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 { #[doc(alias = "g_buffered_output_stream_new")] pub fn new>(base_stream: &P) -> 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: &P, 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`] which can be used to create [`BufferedOutputStream`] objects. pub fn builder() -> BufferedOutputStreamBuilder { BufferedOutputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct BufferedOutputStreamBuilder { auto_grow: Option, buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl BufferedOutputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`BufferedOutputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`BufferedOutputStream`]. pub fn build(self) -> BufferedOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref auto_grow) = self.auto_grow { properties.push(("auto-grow", auto_grow)); } if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of BufferedOutputStream") } pub fn auto_grow(mut self, auto_grow: bool) -> Self { self.auto_grow = Some(auto_grow); self } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_BUFFERED_OUTPUT_STREAM: Option<&BufferedOutputStream> = None; pub trait BufferedOutputStreamExt: 'static { #[doc(alias = "g_buffered_output_stream_get_auto_grow")] #[doc(alias = "get_auto_grow")] fn auto_grows(&self) -> bool; #[doc(alias = "g_buffered_output_stream_get_buffer_size")] #[doc(alias = "get_buffer_size")] fn buffer_size(&self) -> usize; #[doc(alias = "g_buffered_output_stream_set_auto_grow")] fn set_auto_grow(&self, auto_grow: bool); #[doc(alias = "g_buffered_output_stream_set_buffer_size")] fn set_buffer_size(&self, size: usize); #[doc(alias = "auto-grow")] fn connect_auto_grow_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "buffer-size")] fn connect_buffer_size_notify(&self, f: F) -> SignalHandlerId; } impl> BufferedOutputStreamExt for O { fn auto_grows(&self) -> bool { unsafe { from_glib(ffi::g_buffered_output_stream_get_auto_grow( self.as_ref().to_glib_none().0, )) } } fn buffer_size(&self) -> usize { unsafe { ffi::g_buffered_output_stream_get_buffer_size(self.as_ref().to_glib_none().0) } } 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(), ); } } fn set_buffer_size(&self, size: usize) { unsafe { ffi::g_buffered_output_stream_set_buffer_size(self.as_ref().to_glib_none().0, size); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_auto_grow_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_buffer_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for BufferedOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("BufferedOutputStream") } } gio-0.14.8/src/auto/bytes_icon.rs000064400000000000000000000017100072674642500147660ustar 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::Icon; use crate::LoadableIcon; use glib::translate::*; use std::fmt; 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)) } } } impl fmt::Display for BytesIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("BytesIcon") } } gio-0.14.8/src/auto/cancellable.rs000064400000000000000000000120660072674642500150630ustar 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GCancellable")] pub struct Cancellable(Object); match fn { type_ => || ffi::g_cancellable_get_type(), } } impl Cancellable { #[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 {} pub const NONE_CANCELLABLE: Option<&Cancellable> = None; pub trait CancellableExt: 'static { #[doc(alias = "g_cancellable_cancel")] fn cancel(&self); //#[doc(alias = "g_cancellable_connect")] //fn connect(&self, callback: P, data: /*Unimplemented*/Option) -> libc::c_ulong; #[doc(alias = "g_cancellable_disconnect")] fn disconnect(&self, handler_id: libc::c_ulong); #[doc(alias = "g_cancellable_get_fd")] #[doc(alias = "get_fd")] fn fd(&self) -> i32; #[doc(alias = "g_cancellable_is_cancelled")] fn is_cancelled(&self) -> bool; //#[doc(alias = "g_cancellable_make_pollfd")] //fn make_pollfd(&self, pollfd: /*Ignored*/&mut glib::PollFD) -> bool; #[doc(alias = "g_cancellable_pop_current")] fn pop_current(&self); #[doc(alias = "g_cancellable_push_current")] fn push_current(&self); #[doc(alias = "g_cancellable_release_fd")] fn release_fd(&self); #[doc(alias = "g_cancellable_set_error_if_cancelled")] fn set_error_if_cancelled(&self) -> Result<(), glib::Error>; #[doc(alias = "cancelled")] fn connect_cancelled(&self, f: F) -> SignalHandlerId; } impl> CancellableExt for O { fn cancel(&self) { unsafe { ffi::g_cancellable_cancel(self.as_ref().to_glib_none().0); } } //fn connect(&self, callback: P, data: /*Unimplemented*/Option) -> libc::c_ulong { // unsafe { TODO: call ffi:g_cancellable_connect() } //} fn disconnect(&self, handler_id: libc::c_ulong) { unsafe { ffi::g_cancellable_disconnect(self.as_ref().to_glib_none().0, handler_id); } } fn fd(&self) -> i32 { unsafe { ffi::g_cancellable_get_fd(self.as_ref().to_glib_none().0) } } fn is_cancelled(&self) -> bool { unsafe { from_glib(ffi::g_cancellable_is_cancelled( self.as_ref().to_glib_none().0, )) } } //fn make_pollfd(&self, pollfd: /*Ignored*/&mut glib::PollFD) -> bool { // unsafe { TODO: call ffi:g_cancellable_make_pollfd() } //} fn pop_current(&self) { unsafe { ffi::g_cancellable_pop_current(self.as_ref().to_glib_none().0); } } fn push_current(&self) { unsafe { ffi::g_cancellable_push_current(self.as_ref().to_glib_none().0); } } fn release_fd(&self) { unsafe { ffi::g_cancellable_release_fd(self.as_ref().to_glib_none().0); } } fn set_error_if_cancelled(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_cancellable_set_error_if_cancelled( self.as_ref().to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect_cancelled(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn cancelled_trampoline< P: IsA, F: Fn(&P) + Send + Sync + 'static, >( this: *mut ffi::GCancellable, f: glib::ffi::gpointer, ) { let f: &F = &*(f as *const F); f(Cancellable::from_glib_borrow(this).unsafe_cast_ref()) } unsafe { let f: Box_ = Box_::new(f); connect_raw( self.as_ptr() as *mut _, b"cancelled\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( cancelled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Cancellable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Cancellable") } } gio-0.14.8/src/auto/charset_converter.rs000064400000000000000000000142660072674642500163620ustar 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::Converter; use crate::Initable; use glib::object::Cast; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; 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 = 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`] which can be used to create [`CharsetConverter`] objects. pub fn builder() -> CharsetConverterBuilder { CharsetConverterBuilder::default() } #[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")] 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")] 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"from-charset\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `from-charset` getter") } } #[doc(alias = "to-charset")] pub fn to_charset(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"to-charset\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `to-charset` getter") } } #[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(transmute::<_, unsafe extern "C" fn()>( notify_use_fallback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } #[derive(Clone, Default)] // 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 pub struct CharsetConverterBuilder { from_charset: Option, to_charset: Option, use_fallback: Option, } impl CharsetConverterBuilder { // rustdoc-stripper-ignore-next /// Create a new [`CharsetConverterBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`CharsetConverter`]. pub fn build(self) -> CharsetConverter { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref from_charset) = self.from_charset { properties.push(("from-charset", from_charset)); } if let Some(ref to_charset) = self.to_charset { properties.push(("to-charset", to_charset)); } if let Some(ref use_fallback) = self.use_fallback { properties.push(("use-fallback", use_fallback)); } glib::Object::new::(&properties) .expect("Failed to create an instance of CharsetConverter") } pub fn from_charset(mut self, from_charset: &str) -> Self { self.from_charset = Some(from_charset.to_string()); self } pub fn to_charset(mut self, to_charset: &str) -> Self { self.to_charset = Some(to_charset.to_string()); self } pub fn use_fallback(mut self, use_fallback: bool) -> Self { self.use_fallback = Some(use_fallback); self } } impl fmt::Display for CharsetConverter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("CharsetConverter") } } gio-0.14.8/src/auto/constants.rs000064400000000000000000000767370072674642500146710ustar 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 std::ffi::CStr; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE")] pub static DRIVE_IDENTIFIER_KIND_UNIX_DEVICE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_DELETE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_DELETE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_EXECUTE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_READ")] pub static FILE_ATTRIBUTE_ACCESS_CAN_READ: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_READ) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME")] pub static FILE_ATTRIBUTE_ACCESS_CAN_RENAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_RENAME) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH")] pub static FILE_ATTRIBUTE_ACCESS_CAN_TRASH: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_TRASH) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE")] pub static FILE_ATTRIBUTE_ACCESS_CAN_WRITE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE")] pub static FILE_ATTRIBUTE_DOS_IS_ARCHIVE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_DOS_IS_ARCHIVE) .to_str() .unwrap() }); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT")] pub static FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_DOS_IS_SYSTEM")] pub static FILE_ATTRIBUTE_DOS_IS_SYSTEM: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_DOS_IS_SYSTEM) .to_str() .unwrap() }); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG")] pub static FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_DOS_REPARSE_POINT_TAG) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ETAG_VALUE")] pub static FILE_ATTRIBUTE_ETAG_VALUE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ETAG_VALUE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_FREE")] pub static FILE_ATTRIBUTE_FILESYSTEM_FREE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_FREE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_READONLY")] pub static FILE_ATTRIBUTE_FILESYSTEM_READONLY: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_READONLY) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE")] pub static FILE_ATTRIBUTE_FILESYSTEM_REMOTE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_SIZE")] pub static FILE_ATTRIBUTE_FILESYSTEM_SIZE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_SIZE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_TYPE")] pub static FILE_ATTRIBUTE_FILESYSTEM_TYPE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_TYPE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_USED")] pub static FILE_ATTRIBUTE_FILESYSTEM_USED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_USED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW")] pub static FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_FILESYSTEM_USE_PREVIEW) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_GVFS_BACKEND")] pub static FILE_ATTRIBUTE_GVFS_BACKEND: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_GVFS_BACKEND) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ID_FILE")] pub static FILE_ATTRIBUTE_ID_FILE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ID_FILE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_ID_FILESYSTEM")] pub static FILE_ATTRIBUTE_ID_FILESYSTEM: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_ID_FILESYSTEM) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_EJECT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_MOUNT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_POLL) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_START: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_START_DEGRADED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_STOP) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT")] pub static FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_CAN_UNMOUNT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI")] pub static FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_HAL_UDI) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC")] pub static FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_IS_MEDIA_CHECK_AUTOMATIC) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE")] pub static FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_START_STOP_TYPE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE")] pub static FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE")] pub static FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_MOUNTABLE_UNIX_DEVICE_FILE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_GROUP")] pub static FILE_ATTRIBUTE_OWNER_GROUP: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_OWNER_GROUP) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_USER")] pub static FILE_ATTRIBUTE_OWNER_USER: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_OWNER_USER) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_OWNER_USER_REAL")] pub static FILE_ATTRIBUTE_OWNER_USER_REAL: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_OWNER_USER_REAL) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_PREVIEW_ICON")] pub static FILE_ATTRIBUTE_PREVIEW_ICON: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_PREVIEW_ICON) .to_str() .unwrap() }); #[cfg(any(feature = "v2_52", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_52")))] #[doc(alias = "G_FILE_ATTRIBUTE_RECENT_MODIFIED")] pub static FILE_ATTRIBUTE_RECENT_MODIFIED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_RECENT_MODIFIED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_SELINUX_CONTEXT")] pub static FILE_ATTRIBUTE_SELINUX_CONTEXT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_SELINUX_CONTEXT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE")] pub static FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_ALLOCATED_SIZE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_COPY_NAME")] pub static FILE_ATTRIBUTE_STANDARD_COPY_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_COPY_NAME) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION")] pub static FILE_ATTRIBUTE_STANDARD_DESCRIPTION: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME")] pub static FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME")] pub static FILE_ATTRIBUTE_STANDARD_EDIT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_EDIT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_ICON")] pub static FILE_ATTRIBUTE_STANDARD_ICON: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_ICON) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP")] pub static FILE_ATTRIBUTE_STANDARD_IS_BACKUP: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN")] pub static FILE_ATTRIBUTE_STANDARD_IS_HIDDEN: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK")] pub static FILE_ATTRIBUTE_STANDARD_IS_SYMLINK: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_SYMLINK) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL")] pub static FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_VIRTUAL) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE")] pub static FILE_ATTRIBUTE_STANDARD_IS_VOLATILE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_IS_VOLATILE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_NAME")] pub static FILE_ATTRIBUTE_STANDARD_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_NAME) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SIZE")] pub static FILE_ATTRIBUTE_STANDARD_SIZE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_SIZE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER")] pub static FILE_ATTRIBUTE_STANDARD_SORT_ORDER: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_SORT_ORDER) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON")] pub static FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_SYMBOLIC_ICON) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET")] pub static FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_TARGET_URI")] pub static FILE_ATTRIBUTE_STANDARD_TARGET_URI: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_TARGET_URI) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_STANDARD_TYPE")] pub static FILE_ATTRIBUTE_STANDARD_TYPE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_STANDARD_TYPE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAILING_FAILED")] pub static FILE_ATTRIBUTE_THUMBNAILING_FAILED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_THUMBNAILING_FAILED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID")] pub static FILE_ATTRIBUTE_THUMBNAIL_IS_VALID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_IS_VALID) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_THUMBNAIL_PATH")] pub static FILE_ATTRIBUTE_THUMBNAIL_PATH: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_THUMBNAIL_PATH) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_ACCESS")] pub static FILE_ATTRIBUTE_TIME_ACCESS: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_ACCESS) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_ACCESS_USEC")] pub static FILE_ATTRIBUTE_TIME_ACCESS_USEC: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CHANGED")] pub static FILE_ATTRIBUTE_TIME_CHANGED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_CHANGED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CHANGED_USEC")] pub static FILE_ATTRIBUTE_TIME_CHANGED_USEC: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_CHANGED_USEC) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CREATED")] pub static FILE_ATTRIBUTE_TIME_CREATED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_CREATED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_CREATED_USEC")] pub static FILE_ATTRIBUTE_TIME_CREATED_USEC: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_CREATED_USEC) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_MODIFIED")] pub static FILE_ATTRIBUTE_TIME_MODIFIED: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_MODIFIED) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC")] pub static FILE_ATTRIBUTE_TIME_MODIFIED_USEC: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_DELETION_DATE")] pub static FILE_ATTRIBUTE_TRASH_DELETION_DATE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TRASH_DELETION_DATE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT")] pub static FILE_ATTRIBUTE_TRASH_ITEM_COUNT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TRASH_ITEM_COUNT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_TRASH_ORIG_PATH")] pub static FILE_ATTRIBUTE_TRASH_ORIG_PATH: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_TRASH_ORIG_PATH) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_BLOCKS")] pub static FILE_ATTRIBUTE_UNIX_BLOCKS: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_BLOCKS) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE")] pub static FILE_ATTRIBUTE_UNIX_BLOCK_SIZE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_BLOCK_SIZE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_DEVICE")] pub static FILE_ATTRIBUTE_UNIX_DEVICE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_DEVICE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_GID")] pub static FILE_ATTRIBUTE_UNIX_GID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_GID) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_INODE")] pub static FILE_ATTRIBUTE_UNIX_INODE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_INODE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT")] pub static FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_IS_MOUNTPOINT) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_MODE")] pub static FILE_ATTRIBUTE_UNIX_MODE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_MODE) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_NLINK")] pub static FILE_ATTRIBUTE_UNIX_NLINK: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_NLINK) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_RDEV")] pub static FILE_ATTRIBUTE_UNIX_RDEV: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_RDEV) .to_str() .unwrap() }); #[doc(alias = "G_FILE_ATTRIBUTE_UNIX_UID")] pub static FILE_ATTRIBUTE_UNIX_UID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_FILE_ATTRIBUTE_UNIX_UID) .to_str() .unwrap() }); #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] #[doc(alias = "G_MEMORY_MONITOR_EXTENSION_POINT_NAME")] pub static MEMORY_MONITOR_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MEMORY_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_MENU_ATTRIBUTE_ACTION")] pub static MENU_ATTRIBUTE_ACTION: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_ATTRIBUTE_ACTION) .to_str() .unwrap() }); #[doc(alias = "G_MENU_ATTRIBUTE_ACTION_NAMESPACE")] pub static MENU_ATTRIBUTE_ACTION_NAMESPACE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_ATTRIBUTE_ACTION_NAMESPACE) .to_str() .unwrap() }); #[doc(alias = "G_MENU_ATTRIBUTE_ICON")] pub static MENU_ATTRIBUTE_ICON: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_ATTRIBUTE_ICON).to_str().unwrap() }); #[doc(alias = "G_MENU_ATTRIBUTE_LABEL")] pub static MENU_ATTRIBUTE_LABEL: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_ATTRIBUTE_LABEL) .to_str() .unwrap() }); #[doc(alias = "G_MENU_ATTRIBUTE_TARGET")] pub static MENU_ATTRIBUTE_TARGET: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_ATTRIBUTE_TARGET) .to_str() .unwrap() }); #[doc(alias = "G_MENU_LINK_SECTION")] pub static MENU_LINK_SECTION: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_LINK_SECTION).to_str().unwrap() }); #[doc(alias = "G_MENU_LINK_SUBMENU")] pub static MENU_LINK_SUBMENU: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_MENU_LINK_SUBMENU).to_str().unwrap() }); #[doc(alias = "G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME")] pub static NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_NATIVE_VOLUME_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_NETWORK_MONITOR_EXTENSION_POINT_NAME")] pub static NETWORK_MONITOR_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_NETWORK_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_PROXY_EXTENSION_POINT_NAME")] pub static PROXY_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_PROXY_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_PROXY_RESOLVER_EXTENSION_POINT_NAME")] pub static PROXY_RESOLVER_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_PROXY_RESOLVER_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_SETTINGS_BACKEND_EXTENSION_POINT_NAME")] pub static SETTINGS_BACKEND_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_SETTINGS_BACKEND_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_TLS_BACKEND_EXTENSION_POINT_NAME")] pub static TLS_BACKEND_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_TLS_BACKEND_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT")] pub static TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_CLIENT) .to_str() .unwrap() }); #[doc(alias = "G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER")] pub static TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_TLS_DATABASE_PURPOSE_AUTHENTICATE_SERVER) .to_str() .unwrap() }); #[doc(alias = "G_VFS_EXTENSION_POINT_NAME")] pub static VFS_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VFS_EXTENSION_POINT_NAME) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_CLASS")] pub static VOLUME_IDENTIFIER_KIND_CLASS: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_CLASS) .to_str() .unwrap() }); #[cfg_attr(feature = "v2_58", deprecated = "Since 2.58")] #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_HAL_UDI")] pub static VOLUME_IDENTIFIER_KIND_HAL_UDI: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_HAL_UDI) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_LABEL")] pub static VOLUME_IDENTIFIER_KIND_LABEL: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_LABEL) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT")] pub static VOLUME_IDENTIFIER_KIND_NFS_MOUNT: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_NFS_MOUNT) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE")] pub static VOLUME_IDENTIFIER_KIND_UNIX_DEVICE: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_IDENTIFIER_KIND_UUID")] pub static VOLUME_IDENTIFIER_KIND_UUID: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_IDENTIFIER_KIND_UUID) .to_str() .unwrap() }); #[doc(alias = "G_VOLUME_MONITOR_EXTENSION_POINT_NAME")] pub static VOLUME_MONITOR_EXTENSION_POINT_NAME: once_cell::sync::Lazy<&'static str> = once_cell::sync::Lazy::new(|| unsafe { CStr::from_ptr(ffi::G_VOLUME_MONITOR_EXTENSION_POINT_NAME) .to_str() .unwrap() }); gio-0.14.8/src/auto/converter.rs000064400000000000000000000015310072674642500146400ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GConverter")] pub struct Converter(Interface); match fn { type_ => || ffi::g_converter_get_type(), } } pub const NONE_CONVERTER: Option<&Converter> = None; pub trait ConverterExt: 'static { #[doc(alias = "g_converter_reset")] fn reset(&self); } impl> ConverterExt for O { fn reset(&self) { unsafe { ffi::g_converter_reset(self.as_ref().to_glib_none().0); } } } impl fmt::Display for Converter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Converter") } } gio-0.14.8/src/auto/converter_input_stream.rs000064400000000000000000000076730072674642500174470ustar 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::Converter; use crate::FilterInputStream; use crate::InputStream; use crate::PollableInputStream; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; 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 { #[doc(alias = "g_converter_input_stream_new")] pub fn new, Q: IsA>( base_stream: &P, converter: &Q, ) -> 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`] which can be used to create [`ConverterInputStream`] objects. pub fn builder() -> ConverterInputStreamBuilder { ConverterInputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct ConverterInputStreamBuilder { converter: Option, base_stream: Option, close_base_stream: Option, } impl ConverterInputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`ConverterInputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`ConverterInputStream`]. pub fn build(self) -> ConverterInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref converter) = self.converter { properties.push(("converter", converter)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of ConverterInputStream") } pub fn converter>(mut self, converter: &P) -> Self { self.converter = Some(converter.clone().upcast()); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_CONVERTER_INPUT_STREAM: Option<&ConverterInputStream> = None; pub trait ConverterInputStreamExt: 'static { #[doc(alias = "g_converter_input_stream_get_converter")] #[doc(alias = "get_converter")] fn converter(&self) -> Converter; } impl> ConverterInputStreamExt for O { fn converter(&self) -> Converter { unsafe { from_glib_none(ffi::g_converter_input_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ConverterInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ConverterInputStream") } } gio-0.14.8/src/auto/converter_output_stream.rs000064400000000000000000000077440072674642500176470ustar 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::Converter; use crate::FilterOutputStream; use crate::OutputStream; use crate::PollableOutputStream; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; 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 { #[doc(alias = "g_converter_output_stream_new")] pub fn new, Q: IsA>( base_stream: &P, converter: &Q, ) -> 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`] which can be used to create [`ConverterOutputStream`] objects. pub fn builder() -> ConverterOutputStreamBuilder { ConverterOutputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct ConverterOutputStreamBuilder { converter: Option, base_stream: Option, close_base_stream: Option, } impl ConverterOutputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`ConverterOutputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`ConverterOutputStream`]. pub fn build(self) -> ConverterOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref converter) = self.converter { properties.push(("converter", converter)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of ConverterOutputStream") } pub fn converter>(mut self, converter: &P) -> Self { self.converter = Some(converter.clone().upcast()); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_CONVERTER_OUTPUT_STREAM: Option<&ConverterOutputStream> = None; pub trait ConverterOutputStreamExt: 'static { #[doc(alias = "g_converter_output_stream_get_converter")] #[doc(alias = "get_converter")] fn converter(&self) -> Converter; } impl> ConverterOutputStreamExt for O { fn converter(&self) -> Converter { unsafe { from_glib_none(ffi::g_converter_output_stream_get_converter( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ConverterOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ConverterOutputStream") } } gio-0.14.8/src/auto/credentials.rs000064400000000000000000000070670072674642500151400ustar 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 glib::translate::*; use std::fmt; use std::ptr; 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_get_native")] //#[doc(alias = "get_native")] //pub fn native(&self, native_type: CredentialsType) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_credentials_get_native() } //} #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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 = 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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 = 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_is_same_user")] pub fn is_same_user(&self, other_credentials: &Credentials) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_credentials_is_same_user( self.to_glib_none().0, other_credentials.to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } //#[doc(alias = "g_credentials_set_native")] //pub fn set_native(&self, native_type: CredentialsType, native: /*Unimplemented*/Fundamental: Pointer) { // unsafe { TODO: call ffi:g_credentials_set_native() } //} #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_credentials_set_unix_user")] pub fn set_unix_user(&self, uid: u32) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_credentials_set_unix_user(self.to_glib_none().0, uid, &mut error); 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 fmt::Display for Credentials { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.to_str()) } } gio-0.14.8/src/auto/data_input_stream.rs000064400000000000000000000306240072674642500163410ustar 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::AsyncResult; use crate::BufferedInputStream; use crate::Cancellable; use crate::DataStreamByteOrder; use crate::DataStreamNewlineType; use crate::FilterInputStream; use crate::InputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; 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 { #[doc(alias = "g_data_input_stream_new")] pub fn new>(base_stream: &P) -> 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`] which can be used to create [`DataInputStream`] objects. pub fn builder() -> DataInputStreamBuilder { DataInputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct DataInputStreamBuilder { byte_order: Option, newline_type: Option, buffer_size: Option, base_stream: Option, close_base_stream: Option, } impl DataInputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`DataInputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`DataInputStream`]. pub fn build(self) -> DataInputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref byte_order) = self.byte_order { properties.push(("byte-order", byte_order)); } if let Some(ref newline_type) = self.newline_type { properties.push(("newline-type", newline_type)); } if let Some(ref buffer_size) = self.buffer_size { properties.push(("buffer-size", buffer_size)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of DataInputStream") } pub fn byte_order(mut self, byte_order: DataStreamByteOrder) -> Self { self.byte_order = Some(byte_order); self } pub fn newline_type(mut self, newline_type: DataStreamNewlineType) -> Self { self.newline_type = Some(newline_type); self } pub fn buffer_size(mut self, buffer_size: u32) -> Self { self.buffer_size = Some(buffer_size); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_DATA_INPUT_STREAM: Option<&DataInputStream> = None; pub trait DataInputStreamExt: 'static { #[doc(alias = "g_data_input_stream_get_byte_order")] #[doc(alias = "get_byte_order")] fn byte_order(&self) -> DataStreamByteOrder; #[doc(alias = "g_data_input_stream_get_newline_type")] #[doc(alias = "get_newline_type")] fn newline_type(&self) -> DataStreamNewlineType; #[doc(alias = "g_data_input_stream_read_byte")] fn read_byte>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_int16")] fn read_int16>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_int32")] fn read_int32>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_int64")] fn read_int64>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_uint16")] fn read_uint16>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_uint32")] fn read_uint32>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_read_uint64")] fn read_uint64>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_data_input_stream_set_byte_order")] fn set_byte_order(&self, order: DataStreamByteOrder); #[doc(alias = "g_data_input_stream_set_newline_type")] fn set_newline_type(&self, type_: DataStreamNewlineType); #[doc(alias = "byte-order")] fn connect_byte_order_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "newline-type")] fn connect_newline_type_notify(&self, f: F) -> SignalHandlerId; } impl> DataInputStreamExt for O { fn byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(ffi::g_data_input_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } fn newline_type(&self) -> DataStreamNewlineType { unsafe { from_glib(ffi::g_data_input_stream_get_newline_type( self.as_ref().to_glib_none().0, )) } } fn read_byte>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn read_int16>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn read_int32>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn read_int64>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn read_uint16>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn read_uint32>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn read_uint64>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } 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(), ); } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_byte_order_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_newline_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for DataInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DataInputStream") } } gio-0.14.8/src/auto/data_output_stream.rs000064400000000000000000000265430072674642500165470ustar 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::Cancellable; use crate::DataStreamByteOrder; use crate::FilterOutputStream; use crate::OutputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; 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 { #[doc(alias = "g_data_output_stream_new")] pub fn new>(base_stream: &P) -> 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`] which can be used to create [`DataOutputStream`] objects. pub fn builder() -> DataOutputStreamBuilder { DataOutputStreamBuilder::default() } } #[derive(Clone, Default)] // 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 pub struct DataOutputStreamBuilder { byte_order: Option, base_stream: Option, close_base_stream: Option, } impl DataOutputStreamBuilder { // rustdoc-stripper-ignore-next /// Create a new [`DataOutputStreamBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`DataOutputStream`]. pub fn build(self) -> DataOutputStream { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref byte_order) = self.byte_order { properties.push(("byte-order", byte_order)); } if let Some(ref base_stream) = self.base_stream { properties.push(("base-stream", base_stream)); } if let Some(ref close_base_stream) = self.close_base_stream { properties.push(("close-base-stream", close_base_stream)); } glib::Object::new::(&properties) .expect("Failed to create an instance of DataOutputStream") } pub fn byte_order(mut self, byte_order: DataStreamByteOrder) -> Self { self.byte_order = Some(byte_order); self } pub fn base_stream>(mut self, base_stream: &P) -> Self { self.base_stream = Some(base_stream.clone().upcast()); self } pub fn close_base_stream(mut self, close_base_stream: bool) -> Self { self.close_base_stream = Some(close_base_stream); self } } pub const NONE_DATA_OUTPUT_STREAM: Option<&DataOutputStream> = None; pub trait DataOutputStreamExt: 'static { #[doc(alias = "g_data_output_stream_get_byte_order")] #[doc(alias = "get_byte_order")] fn byte_order(&self) -> DataStreamByteOrder; #[doc(alias = "g_data_output_stream_put_byte")] fn put_byte>( &self, data: u8, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_int16")] fn put_int16>( &self, data: i16, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_int32")] fn put_int32>( &self, data: i32, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_int64")] fn put_int64>( &self, data: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_string")] fn put_string>( &self, str: &str, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_uint16")] fn put_uint16>( &self, data: u16, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_uint32")] fn put_uint32>( &self, data: u32, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_put_uint64")] fn put_uint64>( &self, data: u64, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_data_output_stream_set_byte_order")] fn set_byte_order(&self, order: DataStreamByteOrder); #[doc(alias = "byte-order")] fn connect_byte_order_notify(&self, f: F) -> SignalHandlerId; } impl> DataOutputStreamExt for O { fn byte_order(&self) -> DataStreamByteOrder { unsafe { from_glib(ffi::g_data_output_stream_get_byte_order( self.as_ref().to_glib_none().0, )) } } fn put_byte>( &self, data: u8, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int16>( &self, data: i16, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int32>( &self, data: i32, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_int64>( &self, data: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_string>( &self, str: &str, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint16>( &self, data: u16, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint32>( &self, data: u32, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn put_uint64>( &self, data: u64, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_byte_order_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for DataOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DataOutputStream") } } gio-0.14.8/src/auto/dbus_action_group.rs000064400000000000000000000021120072674642500163330ustar 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::ActionGroup; use crate::DBusConnection; use crate::RemoteActionGroup; use glib::translate::*; use std::fmt; 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, )) } } } impl fmt::Display for DBusActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusActionGroup") } } gio-0.14.8/src/auto/dbus_arg_info.rs000064400000000000000000000007060072674642500154350ustar 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 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.14.8/src/auto/dbus_auth_observer.rs000064400000000000000000000102550072674642500165210ustar 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::Credentials; use crate::IOStream; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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: &P, 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(transmute::<_, 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(transmute::<_, unsafe extern "C" fn()>( authorize_authenticated_peer_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for DBusAuthObserver { fn default() -> Self { Self::new() } } impl fmt::Display for DBusAuthObserver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusAuthObserver") } } gio-0.14.8/src/auto/dbus_connection.rs000064400000000000000000001105100072674642500160030ustar 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::AsyncResult; use crate::Cancellable; use crate::Credentials; use crate::DBusAuthObserver; use crate::DBusCallFlags; use crate::DBusCapabilityFlags; use crate::DBusConnectionFlags; use crate::DBusMessage; use crate::DBusSendMessageFlags; use crate::IOStream; use crate::Initable; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use crate::UnixFDList; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GDBusConnection")] pub struct DBusConnection(Object) @implements 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<&P>, ) -> Result { unsafe { let mut error = 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, Q: IsA>( stream: &P, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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< P: IsA, Q: FnOnce(Result) + Send + '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<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn call_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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<&P>, ) -> Result { unsafe { let mut error = 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_dbus_connection_call_with_unix_fd_list")] pub fn call_with_unix_fd_list< P: IsA, Q: IsA, R: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + Send + '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<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn call_with_unix_fd_list_trampoline< R: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + Send + '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 out_fd_list = 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 _); 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub fn call_with_unix_fd_list_future + Clone + '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<&P>, ) -> 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_dbus_connection_call_with_unix_fd_list_sync")] pub fn call_with_unix_fd_list_sync, Q: IsA>( &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<&P>, cancellable: Option<&Q>, ) -> Result<(glib::Variant, UnixFDList), glib::Error> { unsafe { let mut out_fd_list = ptr::null_mut(); let mut error = 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, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn close_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_dbus_connection_close_sync( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); 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 = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_flush")] pub fn flush, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn flush_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_dbus_connection_flush_sync( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); 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")] pub fn exits_on_close(&self) -> bool { unsafe { from_glib(ffi::g_dbus_connection_get_exit_on_close( self.to_glib_none().0, )) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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")] 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")] 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_register_object")] //pub fn register_object(&self, object_path: &str, interface_info: &DBusInterfaceInfo, vtable: /*Ignored*/Option<&DBusInterfaceVTable>, user_data: /*Unimplemented*/Option) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:g_dbus_connection_register_object() } //} #[doc(alias = "g_dbus_connection_send_message")] pub fn send_message( &self, message: &DBusMessage, flags: DBusSendMessageFlags, ) -> Result { unsafe { let mut out_serial = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = 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, ); let out_serial = out_serial.assume_init(); if error.is_null() { Ok(out_serial) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_send_message_with_reply")] pub fn send_message_with_reply< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, cancellable: Option<&P>, callback: Q, ) -> u32 { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn send_message_with_reply_trampoline< Q: FnOnce(Result) + Send + '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_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 _); callback(result); } let callback = send_message_with_reply_trampoline::; unsafe { let mut out_serial = 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 _, ); let out_serial = out_serial.assume_init(); out_serial } } 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<&P>, ) -> Result<(DBusMessage, u32), glib::Error> { unsafe { let mut out_serial = mem::MaybeUninit::uninit(); let mut error = 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, ); let out_serial = out_serial.assume_init(); if error.is_null() { Ok((from_glib_full(ret), out_serial)) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_dbus_connection_set_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); } } pub fn get_property_flags(&self) -> DBusConnectionFlags { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"flags\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `flags` getter") } } #[doc(alias = "g_dbus_connection_new")] pub fn new< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( stream: &P, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn new_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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 + Clone + 'static>( stream: &P, 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< P: IsA, Q: FnOnce(Result) + Send + 'static, >( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn for_address_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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(transmute::<_, 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(transmute::<_, 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(transmute::<_, 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(transmute::<_, 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(transmute::<_, unsafe extern "C" fn()>( notify_unique_name_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } unsafe impl Send for DBusConnection {} unsafe impl Sync for DBusConnection {} impl fmt::Display for DBusConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusConnection") } } gio-0.14.8/src/auto/dbus_interface.rs000064400000000000000000000034160072674642500156120ustar 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::DBusInterfaceInfo; use crate::DBusObject; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GDBusInterface")] pub struct DBusInterface(Interface); match fn { type_ => || ffi::g_dbus_interface_get_type(), } } pub const NONE_DBUS_INTERFACE: Option<&DBusInterface> = None; pub trait DBusInterfaceExt: 'static { #[doc(alias = "g_dbus_interface_dup_object")] #[doc(alias = "dup_object")] fn get(&self) -> Option; #[doc(alias = "g_dbus_interface_get_info")] #[doc(alias = "get_info")] fn info(&self) -> DBusInterfaceInfo; #[doc(alias = "g_dbus_interface_set_object")] fn set_object>(&self, object: Option<&P>); } impl> DBusInterfaceExt for O { fn get(&self) -> Option { unsafe { from_glib_full(ffi::g_dbus_interface_dup_object( self.as_ref().to_glib_none().0, )) } } fn info(&self) -> DBusInterfaceInfo { unsafe { from_glib_none(ffi::g_dbus_interface_get_info( self.as_ref().to_glib_none().0, )) } } fn set_object>(&self, object: Option<&P>) { 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 fmt::Display for DBusInterface { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusInterface") } } gio-0.14.8/src/auto/dbus_interface_info.rs000064400000000000000000000036510072674642500166260ustar 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::DBusMethodInfo; use crate::DBusPropertyInfo; use crate::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: &mut glib::String) { unsafe { ffi::g_dbus_interface_info_generate_xml( self.to_glib_none().0, indent, string_builder.to_glib_none_mut().0, ); } } #[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.14.8/src/auto/dbus_interface_skeleton.rs000064400000000000000000000216550072674642500175230ustar 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::DBusConnection; use crate::DBusInterface; use crate::DBusInterfaceSkeletonFlags; use crate::DBusMethodInvocation; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GDBusInterfaceSkeleton")] pub struct DBusInterfaceSkeleton(Object) @implements DBusInterface; match fn { type_ => || ffi::g_dbus_interface_skeleton_get_type(), } } pub const NONE_DBUS_INTERFACE_SKELETON: Option<&DBusInterfaceSkeleton> = None; pub trait DBusInterfaceSkeletonExt: 'static { #[doc(alias = "g_dbus_interface_skeleton_export")] fn export(&self, connection: &DBusConnection, object_path: &str) -> Result<(), glib::Error>; #[doc(alias = "g_dbus_interface_skeleton_flush")] fn flush(&self); #[doc(alias = "g_dbus_interface_skeleton_get_connection")] #[doc(alias = "get_connection")] fn connection(&self) -> Option; #[doc(alias = "g_dbus_interface_skeleton_get_connections")] #[doc(alias = "get_connections")] fn connections(&self) -> Vec; #[doc(alias = "g_dbus_interface_skeleton_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> DBusInterfaceSkeletonFlags; #[doc(alias = "g_dbus_interface_skeleton_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> Option; #[doc(alias = "g_dbus_interface_skeleton_get_properties")] #[doc(alias = "get_properties")] fn properties(&self) -> glib::Variant; //#[doc(alias = "g_dbus_interface_skeleton_get_vtable")] //#[doc(alias = "get_vtable")] //fn vtable(&self) -> /*Ignored*/DBusInterfaceVTable; #[doc(alias = "g_dbus_interface_skeleton_has_connection")] fn has_connection(&self, connection: &DBusConnection) -> bool; #[doc(alias = "g_dbus_interface_skeleton_set_flags")] fn set_flags(&self, flags: DBusInterfaceSkeletonFlags); #[doc(alias = "g_dbus_interface_skeleton_unexport")] fn unexport(&self); #[doc(alias = "g_dbus_interface_skeleton_unexport_from_connection")] fn unexport_from_connection(&self, connection: &DBusConnection); #[doc(alias = "g-flags")] fn g_flags(&self) -> DBusInterfaceSkeletonFlags; #[doc(alias = "g-flags")] fn set_g_flags(&self, g_flags: DBusInterfaceSkeletonFlags); #[doc(alias = "g-authorize-method")] fn connect_g_authorize_method bool + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "g-flags")] fn connect_g_flags_notify(&self, f: F) -> SignalHandlerId; } impl> DBusInterfaceSkeletonExt for O { fn export(&self, connection: &DBusConnection, object_path: &str) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn flush(&self) { unsafe { ffi::g_dbus_interface_skeleton_flush(self.as_ref().to_glib_none().0); } } fn connection(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_skeleton_get_connection( self.as_ref().to_glib_none().0, )) } } fn connections(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_interface_skeleton_get_connections( self.as_ref().to_glib_none().0, )) } } fn flags(&self) -> DBusInterfaceSkeletonFlags { unsafe { from_glib(ffi::g_dbus_interface_skeleton_get_flags( self.as_ref().to_glib_none().0, )) } } fn object_path(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_interface_skeleton_get_object_path( self.as_ref().to_glib_none().0, )) } } fn properties(&self) -> glib::Variant { unsafe { from_glib_full(ffi::g_dbus_interface_skeleton_get_properties( self.as_ref().to_glib_none().0, )) } } //fn vtable(&self) -> /*Ignored*/DBusInterfaceVTable { // unsafe { TODO: call ffi:g_dbus_interface_skeleton_get_vtable() } //} 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, )) } } fn set_flags(&self, flags: DBusInterfaceSkeletonFlags) { unsafe { ffi::g_dbus_interface_skeleton_set_flags( self.as_ref().to_glib_none().0, flags.into_glib(), ); } } fn unexport(&self) { unsafe { ffi::g_dbus_interface_skeleton_unexport(self.as_ref().to_glib_none().0); } } 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, ); } } fn g_flags(&self) -> DBusInterfaceSkeletonFlags { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-flags\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-flags` getter") } } fn set_g_flags(&self, g_flags: DBusInterfaceSkeletonFlags) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-flags\0".as_ptr() as *const _, g_flags.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( g_authorize_method_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_g_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for DBusInterfaceSkeleton { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusInterfaceSkeleton") } } gio-0.14.8/src/auto/dbus_menu_model.rs000064400000000000000000000017760072674642500160050ustar 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::DBusConnection; use crate::MenuModel; use glib::translate::*; use std::fmt; 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, )) } } } impl fmt::Display for DBusMenuModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusMenuModel") } } gio-0.14.8/src/auto/dbus_message.rs000064400000000000000000000364270072674642500153060ustar 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::DBusCapabilityFlags; use crate::DBusMessageByteOrder; use crate::DBusMessageFlags; use crate::DBusMessageHeaderField; use crate::DBusMessageType; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use crate::UnixFDList; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::mem; use std::mem::transmute; use std::ptr; 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 usize; unsafe { let mut error = 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 = 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)) } } #[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")] 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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")] //pub fn new_method_error(&self, error_name: &str, error_message_format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> DBusMessage { // unsafe { TODO: call ffi:g_dbus_message_new_method_error() } //} #[doc(alias = "g_dbus_message_new_method_error_literal")] 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")] //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")] 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_dbus_message_set_unix_fd_list")] pub fn set_unix_fd_list>(&self, fd_list: Option<&P>) { 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 = mem::MaybeUninit::uninit(); let mut error = 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 usize, )) } 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 = ptr::null_mut(); let _ = ffi::g_dbus_message_to_gerror(self.to_glib_none().0, &mut error); 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 usize; unsafe { let mut error = 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(transmute::<_, unsafe extern "C" fn()>( notify_locked_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for DBusMessage { fn default() -> Self { Self::new() } } gio-0.14.8/src/auto/dbus_method_info.rs000064400000000000000000000007250072674642500161450ustar 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 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.14.8/src/auto/dbus_method_invocation.rs000064400000000000000000000133440072674642500173640ustar 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::DBusConnection; use crate::DBusMessage; use crate::DBusMethodInfo; use crate::DBusPropertyInfo; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use crate::UnixFDList; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use glib::object::IsA; use glib::translate::*; use std::fmt; 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.to_glib_full(), 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*/Fundamental: 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.to_glib_full(), parameters.to_glib_none().0, ); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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<&P>, ) { unsafe { ffi::g_dbus_method_invocation_return_value_with_unix_fd_list( self.to_glib_full(), parameters.to_glib_none().0, fd_list.map(|p| p.as_ref()).to_glib_none().0, ); } } } impl fmt::Display for DBusMethodInvocation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusMethodInvocation") } } gio-0.14.8/src/auto/dbus_node_info.rs000064400000000000000000000032550072674642500156130ustar 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::DBusInterfaceInfo; use glib::translate::*; use std::ptr; 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 = 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: &mut glib::String) { unsafe { ffi::g_dbus_node_info_generate_xml( self.to_glib_none().0, indent, string_builder.to_glib_none_mut().0, ); } } #[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.14.8/src/auto/dbus_object.rs000064400000000000000000000104330072674642500151150ustar 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::DBusInterface; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GDBusObject")] pub struct DBusObject(Interface); match fn { type_ => || ffi::g_dbus_object_get_type(), } } pub const NONE_DBUS_OBJECT: Option<&DBusObject> = None; pub trait DBusObjectExt: 'static { #[doc(alias = "g_dbus_object_get_interface")] #[doc(alias = "get_interface")] fn interface(&self, interface_name: &str) -> Option; #[doc(alias = "g_dbus_object_get_interfaces")] #[doc(alias = "get_interfaces")] fn interfaces(&self) -> Vec; #[doc(alias = "g_dbus_object_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> glib::GString; #[doc(alias = "interface-added")] fn connect_interface_added( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "interface-removed")] fn connect_interface_removed( &self, f: F, ) -> SignalHandlerId; } impl> DBusObjectExt for O { 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, )) } } fn interfaces(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_dbus_object_get_interfaces( self.as_ref().to_glib_none().0, )) } } fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_object_get_object_path( self.as_ref().to_glib_none().0, )) } } 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(transmute::<_, unsafe extern "C" fn()>( interface_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( interface_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for DBusObject { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusObject") } } gio-0.14.8/src/auto/dbus_property_info.rs000064400000000000000000000007370072674642500165540ustar 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 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.14.8/src/auto/dbus_proxy.rs000064400000000000000000001040200072674642500150240ustar 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::AsyncResult; use crate::BusType; use crate::Cancellable; use crate::DBusCallFlags; use crate::DBusConnection; use crate::DBusInterface; use crate::DBusInterfaceInfo; use crate::DBusProxyFlags; use crate::Initable; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use crate::UnixFDList; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GDBusProxy")] pub struct DBusProxy(Object) @implements DBusInterface, Initable; match fn { type_ => || ffi::g_dbus_proxy_get_type(), } } impl DBusProxy { #[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<&P>, ) -> Result { unsafe { let mut error = 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<&P>, ) -> Result { unsafe { let mut error = 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, Q: FnOnce(Result) + Send + 'static>( connection: &DBusConnection, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: Option<&str>, object_path: &str, interface_name: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn new_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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< P: IsA, Q: FnOnce(Result) + Send + 'static, >( bus_type: BusType, flags: DBusProxyFlags, info: Option<&DBusInterfaceInfo>, name: &str, object_path: &str, interface_name: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn for_bus_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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); }, ); }, )) } } impl fmt::Display for DBusProxy { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&DBusProxyExt::name(self)) } } unsafe impl Send for DBusProxy {} unsafe impl Sync for DBusProxy {} pub const NONE_DBUS_PROXY: Option<&DBusProxy> = None; pub trait DBusProxyExt: 'static { #[doc(alias = "g_dbus_proxy_call")] fn call, Q: FnOnce(Result) + Send + 'static>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&P>, callback: Q, ); fn call_future( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, ) -> Pin> + 'static>>; #[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<&P>, ) -> Result; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list")] fn call_with_unix_fd_list< P: IsA, Q: IsA, R: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + Send + 'static, >( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, cancellable: Option<&Q>, callback: R, ); #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] fn call_with_unix_fd_list_future + Clone + 'static>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, ) -> Pin< Box_< dyn std::future::Future> + 'static, >, >; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_dbus_proxy_call_with_unix_fd_list_sync")] fn call_with_unix_fd_list_sync, Q: IsA>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, cancellable: Option<&Q>, ) -> Result<(glib::Variant, UnixFDList), glib::Error>; #[doc(alias = "g_dbus_proxy_get_cached_property")] #[doc(alias = "get_cached_property")] fn cached_property(&self, property_name: &str) -> Option; #[doc(alias = "g_dbus_proxy_get_cached_property_names")] #[doc(alias = "get_cached_property_names")] fn cached_property_names(&self) -> Vec; #[doc(alias = "g_dbus_proxy_get_connection")] #[doc(alias = "get_connection")] fn connection(&self) -> DBusConnection; #[doc(alias = "g_dbus_proxy_get_default_timeout")] #[doc(alias = "get_default_timeout")] fn default_timeout(&self) -> i32; #[doc(alias = "g_dbus_proxy_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> DBusProxyFlags; #[doc(alias = "g_dbus_proxy_get_interface_info")] #[doc(alias = "get_interface_info")] fn interface_info(&self) -> Option; #[doc(alias = "g_dbus_proxy_get_interface_name")] #[doc(alias = "get_interface_name")] fn interface_name(&self) -> glib::GString; #[doc(alias = "g_dbus_proxy_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_dbus_proxy_get_name_owner")] #[doc(alias = "get_name_owner")] fn name_owner(&self) -> Option; #[doc(alias = "g_dbus_proxy_get_object_path")] #[doc(alias = "get_object_path")] fn object_path(&self) -> glib::GString; #[doc(alias = "g_dbus_proxy_set_cached_property")] fn set_cached_property(&self, property_name: &str, value: Option<&glib::Variant>); #[doc(alias = "g_dbus_proxy_set_default_timeout")] fn set_default_timeout(&self, timeout_msec: i32); #[doc(alias = "g_dbus_proxy_set_interface_info")] fn set_interface_info(&self, info: Option<&DBusInterfaceInfo>); #[doc(alias = "g-connection")] fn g_connection(&self) -> Option; #[doc(alias = "g-default-timeout")] fn g_default_timeout(&self) -> i32; #[doc(alias = "g-default-timeout")] fn set_g_default_timeout(&self, g_default_timeout: i32); #[doc(alias = "g-flags")] fn g_flags(&self) -> DBusProxyFlags; #[doc(alias = "g-interface-info")] fn g_interface_info(&self) -> Option; #[doc(alias = "g-interface-info")] fn set_g_interface_info(&self, g_interface_info: Option<&DBusInterfaceInfo>); #[doc(alias = "g-interface-name")] fn g_interface_name(&self) -> Option; #[doc(alias = "g-name")] fn g_name(&self) -> Option; #[doc(alias = "g-name-owner")] fn g_name_owner(&self) -> Option; #[doc(alias = "g-object-path")] fn g_object_path(&self) -> Option; #[doc(alias = "g-signal")] fn connect_g_signal, &str, &glib::Variant) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "g-default-timeout")] fn connect_g_default_timeout_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "g-interface-info")] fn connect_g_interface_info_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "g-name-owner")] fn connect_g_name_owner_notify( &self, f: F, ) -> SignalHandlerId; } impl> DBusProxyExt for O { fn call, Q: FnOnce(Result) + Send + 'static>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn call_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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); }, ); }, )) } fn call_sync>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] fn call_with_unix_fd_list< P: IsA, Q: IsA, R: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + Send + 'static, >( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn call_with_unix_fd_list_trampoline< R: FnOnce(Result<(glib::Variant, UnixFDList), glib::Error>) + Send + '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 out_fd_list = 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 _); 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] fn call_with_unix_fd_list_future + Clone + 'static>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, ) -> 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] fn call_with_unix_fd_list_sync, Q: IsA>( &self, method_name: &str, parameters: Option<&glib::Variant>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&P>, cancellable: Option<&Q>, ) -> Result<(glib::Variant, UnixFDList), glib::Error> { unsafe { let mut out_fd_list = ptr::null_mut(); let mut error = 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)) } } } 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, )) } } 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, )) } } fn connection(&self) -> DBusConnection { unsafe { from_glib_none(ffi::g_dbus_proxy_get_connection( self.as_ref().to_glib_none().0, )) } } fn default_timeout(&self) -> i32 { unsafe { ffi::g_dbus_proxy_get_default_timeout(self.as_ref().to_glib_none().0) } } fn flags(&self) -> DBusProxyFlags { unsafe { from_glib(ffi::g_dbus_proxy_get_flags(self.as_ref().to_glib_none().0)) } } fn interface_info(&self) -> Option { unsafe { from_glib_none(ffi::g_dbus_proxy_get_interface_info( self.as_ref().to_glib_none().0, )) } } fn interface_name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_proxy_get_interface_name( self.as_ref().to_glib_none().0, )) } } fn name(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_proxy_get_name(self.as_ref().to_glib_none().0)) } } fn name_owner(&self) -> Option { unsafe { from_glib_full(ffi::g_dbus_proxy_get_name_owner( self.as_ref().to_glib_none().0, )) } } fn object_path(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_dbus_proxy_get_object_path( self.as_ref().to_glib_none().0, )) } } 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, ); } } 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); } } 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, ); } } fn g_connection(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-connection\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-connection` getter") } } fn g_default_timeout(&self) -> i32 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-default-timeout\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-default-timeout` getter") } } fn set_g_default_timeout(&self, g_default_timeout: i32) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-default-timeout\0".as_ptr() as *const _, g_default_timeout.to_value().to_glib_none().0, ); } } fn g_flags(&self) -> DBusProxyFlags { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-flags\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-flags` getter") } } fn g_interface_info(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-interface-info\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-interface-info` getter") } } fn set_g_interface_info(&self, g_interface_info: Option<&DBusInterfaceInfo>) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-interface-info\0".as_ptr() as *const _, g_interface_info.to_value().to_glib_none().0, ); } } fn g_interface_name(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-interface-name\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-interface-name` getter") } } fn g_name(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-name\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-name` getter") } } fn g_name_owner(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-name-owner\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-name-owner` getter") } } fn g_object_path(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"g-object-path\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `g-object-path` getter") } } 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::<_, unsafe extern "C" fn()>( g_signal_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_g_default_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_g_interface_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_g_name_owner_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.14.8/src/auto/dbus_server.rs000064400000000000000000000151240072674642500151570ustar 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::Cancellable; use crate::DBusAuthObserver; use crate::DBusConnection; use crate::DBusServerFlags; use crate::Initable; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; 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<&P>, ) -> Result { unsafe { let mut error = 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")] 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")] 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"address\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `address` getter") } } #[doc(alias = "authentication-observer")] pub fn authentication_observer(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"authentication-observer\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `authentication-observer` getter") } } #[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(transmute::<_, 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(transmute::<_, 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(transmute::<_, unsafe extern "C" fn()>( notify_client_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for DBusServer { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DBusServer") } } gio-0.14.8/src/auto/dbus_signal_info.rs000064400000000000000000000007250072674642500161420ustar 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 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.14.8/src/auto/desktop_app_info.rs000064400000000000000000000243550072674642500161660ustar 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::AppInfo; use crate::AppLaunchContext; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] use std::mem; use std::ptr; 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: P) -> 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, )) } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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 = 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 usize, ); 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<&P>, ) { 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<&P>, 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>( 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: *mut Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = user_data as *const _ as usize 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( 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 usize as *mut _, &mut error, ); 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, )) } } } impl fmt::Display for DesktopAppInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("DesktopAppInfo") } } gio-0.14.8/src/auto/drive.rs000064400000000000000000000472310072674642500137510ustar 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::AsyncResult; use crate::Cancellable; use crate::DriveStartFlags; use crate::DriveStartStopType; use crate::Icon; use crate::MountOperation; use crate::MountUnmountFlags; use crate::Volume; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GDrive")] pub struct Drive(Interface); match fn { type_ => || ffi::g_drive_get_type(), } } pub const NONE_DRIVE: Option<&Drive> = None; pub trait DriveExt: 'static { #[doc(alias = "g_drive_can_eject")] fn can_eject(&self) -> bool; #[doc(alias = "g_drive_can_poll_for_media")] fn can_poll_for_media(&self) -> bool; #[doc(alias = "g_drive_can_start")] fn can_start(&self) -> bool; #[doc(alias = "g_drive_can_start_degraded")] fn can_start_degraded(&self) -> bool; #[doc(alias = "g_drive_can_stop")] fn can_stop(&self) -> bool; #[doc(alias = "g_drive_eject_with_operation")] fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_drive_enumerate_identifiers")] fn enumerate_identifiers(&self) -> Vec; #[doc(alias = "g_drive_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon; #[doc(alias = "g_drive_get_identifier")] #[doc(alias = "get_identifier")] fn identifier(&self, kind: &str) -> Option; #[doc(alias = "g_drive_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_drive_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option; #[doc(alias = "g_drive_get_start_stop_type")] #[doc(alias = "get_start_stop_type")] fn start_stop_type(&self) -> DriveStartStopType; #[doc(alias = "g_drive_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon; #[doc(alias = "g_drive_get_volumes")] #[doc(alias = "get_volumes")] fn volumes(&self) -> Vec; #[doc(alias = "g_drive_has_media")] fn has_media(&self) -> bool; #[doc(alias = "g_drive_has_volumes")] fn has_volumes(&self) -> bool; #[doc(alias = "g_drive_is_media_check_automatic")] fn is_media_check_automatic(&self) -> bool; #[doc(alias = "g_drive_is_media_removable")] fn is_media_removable(&self) -> bool; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_drive_is_removable")] fn is_removable(&self) -> bool; #[doc(alias = "g_drive_poll_for_media")] fn poll_for_media, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); fn poll_for_media_future( &self, ) -> Pin> + 'static>>; #[doc(alias = "g_drive_start")] fn start< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn start_future + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_drive_stop")] fn stop< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn stop_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "disconnected")] fn connect_disconnected(&self, f: F) -> SignalHandlerId; #[doc(alias = "eject-button")] fn connect_eject_button(&self, f: F) -> SignalHandlerId; #[doc(alias = "stop-button")] fn connect_stop_button(&self, f: F) -> SignalHandlerId; } impl> DriveExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_eject(self.as_ref().to_glib_none().0)) } } fn can_poll_for_media(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_poll_for_media( self.as_ref().to_glib_none().0, )) } } fn can_start(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_start(self.as_ref().to_glib_none().0)) } } fn can_start_degraded(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_start_degraded( self.as_ref().to_glib_none().0, )) } } fn can_stop(&self) -> bool { unsafe { from_glib(ffi::g_drive_can_stop(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_drive_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_drive_get_icon(self.as_ref().to_glib_none().0)) } } 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, )) } } fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_drive_get_name(self.as_ref().to_glib_none().0)) } } fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_drive_get_sort_key(self.as_ref().to_glib_none().0)) } } fn start_stop_type(&self) -> DriveStartStopType { unsafe { from_glib(ffi::g_drive_get_start_stop_type( self.as_ref().to_glib_none().0, )) } } fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_drive_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_drive_get_volumes( self.as_ref().to_glib_none().0, )) } } fn has_media(&self) -> bool { unsafe { from_glib(ffi::g_drive_has_media(self.as_ref().to_glib_none().0)) } } fn has_volumes(&self) -> bool { unsafe { from_glib(ffi::g_drive_has_volumes(self.as_ref().to_glib_none().0)) } } fn is_media_check_automatic(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_media_check_automatic( self.as_ref().to_glib_none().0, )) } } fn is_media_removable(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_media_removable( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] fn is_removable(&self) -> bool { unsafe { from_glib(ffi::g_drive_is_removable(self.as_ref().to_glib_none().0)) } } fn poll_for_media, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn poll_for_media_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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); }); }, )) } fn start< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn start_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: DriveStartFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn stop< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn stop_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( disconnected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( eject_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( stop_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Drive { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Drive") } } gio-0.14.8/src/auto/emblem.rs000064400000000000000000000027530072674642500141010ustar 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::EmblemOrigin; use crate::Icon; use glib::object::IsA; use glib::translate::*; use std::fmt; 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: &P) -> 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: &P, 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)) } } } impl fmt::Display for Emblem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Emblem") } } gio-0.14.8/src/auto/emblemed_icon.rs000064400000000000000000000054310072674642500154160ustar 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::Emblem; use crate::Icon; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use std::fmt; glib::wrapper! { #[doc(alias = "GEmblemedIcon")] pub struct EmblemedIcon(Object) @implements Icon; match fn { type_ => || ffi::g_emblemed_icon_get_type(), } } impl EmblemedIcon { #[doc(alias = "g_emblemed_icon_new")] pub fn new>(icon: &P, 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, )) } } } pub const NONE_EMBLEMED_ICON: Option<&EmblemedIcon> = None; pub trait EmblemedIconExt: 'static { #[doc(alias = "g_emblemed_icon_add_emblem")] fn add_emblem(&self, emblem: &Emblem); #[doc(alias = "g_emblemed_icon_clear_emblems")] fn clear_emblems(&self); #[doc(alias = "g_emblemed_icon_get_emblems")] #[doc(alias = "get_emblems")] fn emblems(&self) -> Vec; #[doc(alias = "g_emblemed_icon_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon; fn gicon(&self) -> Option; } impl> EmblemedIconExt for O { 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, ); } } fn clear_emblems(&self) { unsafe { ffi::g_emblemed_icon_clear_emblems(self.as_ref().to_glib_none().0); } } fn emblems(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_none(ffi::g_emblemed_icon_get_emblems( self.as_ref().to_glib_none().0, )) } } 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"gicon\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `gicon` getter") } } } impl fmt::Display for EmblemedIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("EmblemedIcon") } } gio-0.14.8/src/auto/enums.rs000064400000000000000000003425730072674642500137760ustar 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 glib::error::ErrorDomain; use glib::translate::*; use glib::value::FromValue; use glib::value::ToValue; use glib::Quark; use glib::StaticType; use glib::Type; use std::fmt; #[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), } impl fmt::Display for BusType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "BusType::{}", match *self { Self::Starter => "Starter", Self::None => "None", Self::System => "System", Self::Session => "Session", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for BusType { type GlibType = ffi::GBusType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_bus_type_get_type()) } } } impl glib::value::ValueType for BusType { type Type = Self; } unsafe impl<'a> FromValue<'a> for BusType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for ConverterResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ConverterResult::{}", match *self { Self::Error => "Error", Self::Converted => "Converted", Self::Finished => "Finished", Self::Flushed => "Flushed", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for ConverterResult { type GlibType = ffi::GConverterResult; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_converter_result_get_type()) } } } impl glib::value::ValueType for ConverterResult { type Type = Self; } unsafe impl<'a> FromValue<'a> for ConverterResult { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for CredentialsType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "CredentialsType::{}", match *self { Self::Invalid => "Invalid", Self::LinuxUcred => "LinuxUcred", Self::FreebsdCmsgcred => "FreebsdCmsgcred", Self::OpenbsdSockpeercred => "OpenbsdSockpeercred", Self::SolarisUcred => "SolarisUcred", Self::NetbsdUnpcbid => "NetbsdUnpcbid", Self::AppleXucred => "AppleXucred", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for CredentialsType { type GlibType = ffi::GCredentialsType; 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, Self::__Unknown(value) => value, } } } #[doc(hidden)] impl FromGlib for CredentialsType { 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, value => Self::__Unknown(value), } } } impl StaticType for CredentialsType { fn static_type() -> Type { unsafe { from_glib(ffi::g_credentials_type_get_type()) } } } impl glib::value::ValueType for CredentialsType { type Type = Self; } unsafe impl<'a> FromValue<'a> for CredentialsType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DBusMessageByteOrder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DBusMessageByteOrder::{}", match *self { Self::BigEndian => "BigEndian", Self::LittleEndian => "LittleEndian", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DBusMessageByteOrder { type GlibType = ffi::GDBusMessageByteOrder; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_message_byte_order_get_type()) } } } impl glib::value::ValueType for DBusMessageByteOrder { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusMessageByteOrder { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DBusMessageHeaderField { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DBusMessageHeaderField::{}", match *self { Self::Invalid => "Invalid", Self::Path => "Path", Self::Interface => "Interface", Self::Member => "Member", Self::ErrorName => "ErrorName", Self::ReplySerial => "ReplySerial", Self::Destination => "Destination", Self::Sender => "Sender", Self::Signature => "Signature", Self::NumUnixFds => "NumUnixFds", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DBusMessageHeaderField { type GlibType = ffi::GDBusMessageHeaderField; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_message_header_field_get_type()) } } } impl glib::value::ValueType for DBusMessageHeaderField { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusMessageHeaderField { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DBusMessageType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DBusMessageType::{}", match *self { Self::Invalid => "Invalid", Self::MethodCall => "MethodCall", Self::MethodReturn => "MethodReturn", Self::Error => "Error", Self::Signal => "Signal", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DBusMessageType { type GlibType = ffi::GDBusMessageType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_message_type_get_type()) } } } impl glib::value::ValueType for DBusMessageType { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusMessageType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DataStreamByteOrder { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DataStreamByteOrder::{}", match *self { Self::BigEndian => "BigEndian", Self::LittleEndian => "LittleEndian", Self::HostEndian => "HostEndian", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DataStreamByteOrder { type GlibType = ffi::GDataStreamByteOrder; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_data_stream_byte_order_get_type()) } } } impl glib::value::ValueType for DataStreamByteOrder { type Type = Self; } unsafe impl<'a> FromValue<'a> for DataStreamByteOrder { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DataStreamNewlineType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DataStreamNewlineType::{}", match *self { Self::Lf => "Lf", Self::Cr => "Cr", Self::CrLf => "CrLf", Self::Any => "Any", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DataStreamNewlineType { type GlibType = ffi::GDataStreamNewlineType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_data_stream_newline_type_get_type()) } } } impl glib::value::ValueType for DataStreamNewlineType { type Type = Self; } unsafe impl<'a> FromValue<'a> for DataStreamNewlineType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for DriveStartStopType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "DriveStartStopType::{}", match *self { Self::Unknown => "Unknown", Self::Shutdown => "Shutdown", Self::Network => "Network", Self::Multidisk => "Multidisk", Self::Password => "Password", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for DriveStartStopType { type GlibType = ffi::GDriveStartStopType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_drive_start_stop_type_get_type()) } } } impl glib::value::ValueType for DriveStartStopType { type Type = Self; } unsafe impl<'a> FromValue<'a> for DriveStartStopType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for EmblemOrigin { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "EmblemOrigin::{}", match *self { Self::Unknown => "Unknown", Self::Device => "Device", Self::Livemetadata => "Livemetadata", Self::Tag => "Tag", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for EmblemOrigin { type GlibType = ffi::GEmblemOrigin; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_emblem_origin_get_type()) } } } impl glib::value::ValueType for EmblemOrigin { type Type = Self; } unsafe impl<'a> FromValue<'a> for EmblemOrigin { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for FileAttributeStatus { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileAttributeStatus::{}", match *self { Self::Unset => "Unset", Self::Set => "Set", Self::ErrorSetting => "ErrorSetting", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for FileAttributeStatus { type GlibType = ffi::GFileAttributeStatus; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_attribute_status_get_type()) } } } impl glib::value::ValueType for FileAttributeStatus { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileAttributeStatus { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for FileAttributeType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileAttributeType::{}", match *self { Self::Invalid => "Invalid", Self::String => "String", Self::ByteString => "ByteString", Self::Boolean => "Boolean", Self::Uint32 => "Uint32", Self::Int32 => "Int32", Self::Uint64 => "Uint64", Self::Int64 => "Int64", Self::Object => "Object", Self::Stringv => "Stringv", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for FileAttributeType { type GlibType = ffi::GFileAttributeType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_attribute_type_get_type()) } } } impl glib::value::ValueType for FileAttributeType { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileAttributeType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for FileMonitorEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileMonitorEvent::{}", match *self { Self::Changed => "Changed", Self::ChangesDoneHint => "ChangesDoneHint", Self::Deleted => "Deleted", Self::Created => "Created", Self::AttributeChanged => "AttributeChanged", Self::PreUnmount => "PreUnmount", Self::Unmounted => "Unmounted", Self::Moved => "Moved", Self::Renamed => "Renamed", Self::MovedIn => "MovedIn", Self::MovedOut => "MovedOut", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for FileMonitorEvent { type GlibType = ffi::GFileMonitorEvent; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_monitor_event_get_type()) } } } impl glib::value::ValueType for FileMonitorEvent { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileMonitorEvent { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for FileType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "FileType::{}", match *self { Self::Unknown => "Unknown", Self::Regular => "Regular", Self::Directory => "Directory", Self::SymbolicLink => "SymbolicLink", Self::Special => "Special", Self::Shortcut => "Shortcut", Self::Mountable => "Mountable", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for FileType { type GlibType = ffi::GFileType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_type_get_type()) } } } impl glib::value::ValueType for FileType { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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, #[doc(hidden)] __Unknown(i32), } impl fmt::Display for IOErrorEnum { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "IOErrorEnum::{}", match *self { Self::Failed => "Failed", Self::NotFound => "NotFound", Self::Exists => "Exists", Self::IsDirectory => "IsDirectory", Self::NotDirectory => "NotDirectory", Self::NotEmpty => "NotEmpty", Self::NotRegularFile => "NotRegularFile", Self::NotSymbolicLink => "NotSymbolicLink", Self::NotMountableFile => "NotMountableFile", Self::FilenameTooLong => "FilenameTooLong", Self::InvalidFilename => "InvalidFilename", Self::TooManyLinks => "TooManyLinks", Self::NoSpace => "NoSpace", Self::InvalidArgument => "InvalidArgument", Self::PermissionDenied => "PermissionDenied", Self::NotSupported => "NotSupported", Self::NotMounted => "NotMounted", Self::AlreadyMounted => "AlreadyMounted", Self::Closed => "Closed", Self::Cancelled => "Cancelled", Self::Pending => "Pending", Self::ReadOnly => "ReadOnly", Self::CantCreateBackup => "CantCreateBackup", Self::WrongEtag => "WrongEtag", Self::TimedOut => "TimedOut", Self::WouldRecurse => "WouldRecurse", Self::Busy => "Busy", Self::WouldBlock => "WouldBlock", Self::HostNotFound => "HostNotFound", Self::WouldMerge => "WouldMerge", Self::FailedHandled => "FailedHandled", Self::TooManyOpenFiles => "TooManyOpenFiles", Self::NotInitialized => "NotInitialized", Self::AddressInUse => "AddressInUse", Self::PartialInput => "PartialInput", Self::InvalidData => "InvalidData", Self::DbusError => "DbusError", Self::HostUnreachable => "HostUnreachable", Self::NetworkUnreachable => "NetworkUnreachable", Self::ConnectionRefused => "ConnectionRefused", Self::ProxyFailed => "ProxyFailed", Self::ProxyAuthFailed => "ProxyAuthFailed", Self::ProxyNeedAuth => "ProxyNeedAuth", Self::ProxyNotAllowed => "ProxyNotAllowed", Self::BrokenPipe => "BrokenPipe", Self::NotConnected => "NotConnected", Self::MessageTooLarge => "MessageTooLarge", _ => "Unknown", } ) } } #[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, 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, value => Self::__Unknown(value), } } } impl ErrorDomain for IOErrorEnum { fn domain() -> Quark { unsafe { from_glib(ffi::g_io_error_quark()) } } fn code(self) -> i32 { self.into_glib() } fn from(code: i32) -> Option { match code { ffi::G_IO_ERROR_FAILED => Some(Self::Failed), ffi::G_IO_ERROR_NOT_FOUND => Some(Self::NotFound), ffi::G_IO_ERROR_EXISTS => Some(Self::Exists), ffi::G_IO_ERROR_IS_DIRECTORY => Some(Self::IsDirectory), ffi::G_IO_ERROR_NOT_DIRECTORY => Some(Self::NotDirectory), ffi::G_IO_ERROR_NOT_EMPTY => Some(Self::NotEmpty), ffi::G_IO_ERROR_NOT_REGULAR_FILE => Some(Self::NotRegularFile), ffi::G_IO_ERROR_NOT_SYMBOLIC_LINK => Some(Self::NotSymbolicLink), ffi::G_IO_ERROR_NOT_MOUNTABLE_FILE => Some(Self::NotMountableFile), ffi::G_IO_ERROR_FILENAME_TOO_LONG => Some(Self::FilenameTooLong), ffi::G_IO_ERROR_INVALID_FILENAME => Some(Self::InvalidFilename), ffi::G_IO_ERROR_TOO_MANY_LINKS => Some(Self::TooManyLinks), ffi::G_IO_ERROR_NO_SPACE => Some(Self::NoSpace), ffi::G_IO_ERROR_INVALID_ARGUMENT => Some(Self::InvalidArgument), ffi::G_IO_ERROR_PERMISSION_DENIED => Some(Self::PermissionDenied), ffi::G_IO_ERROR_NOT_SUPPORTED => Some(Self::NotSupported), ffi::G_IO_ERROR_NOT_MOUNTED => Some(Self::NotMounted), ffi::G_IO_ERROR_ALREADY_MOUNTED => Some(Self::AlreadyMounted), ffi::G_IO_ERROR_CLOSED => Some(Self::Closed), ffi::G_IO_ERROR_CANCELLED => Some(Self::Cancelled), ffi::G_IO_ERROR_PENDING => Some(Self::Pending), ffi::G_IO_ERROR_READ_ONLY => Some(Self::ReadOnly), ffi::G_IO_ERROR_CANT_CREATE_BACKUP => Some(Self::CantCreateBackup), ffi::G_IO_ERROR_WRONG_ETAG => Some(Self::WrongEtag), ffi::G_IO_ERROR_TIMED_OUT => Some(Self::TimedOut), ffi::G_IO_ERROR_WOULD_RECURSE => Some(Self::WouldRecurse), ffi::G_IO_ERROR_BUSY => Some(Self::Busy), ffi::G_IO_ERROR_WOULD_BLOCK => Some(Self::WouldBlock), ffi::G_IO_ERROR_HOST_NOT_FOUND => Some(Self::HostNotFound), ffi::G_IO_ERROR_WOULD_MERGE => Some(Self::WouldMerge), ffi::G_IO_ERROR_FAILED_HANDLED => Some(Self::FailedHandled), ffi::G_IO_ERROR_TOO_MANY_OPEN_FILES => Some(Self::TooManyOpenFiles), ffi::G_IO_ERROR_NOT_INITIALIZED => Some(Self::NotInitialized), ffi::G_IO_ERROR_ADDRESS_IN_USE => Some(Self::AddressInUse), ffi::G_IO_ERROR_PARTIAL_INPUT => Some(Self::PartialInput), ffi::G_IO_ERROR_INVALID_DATA => Some(Self::InvalidData), ffi::G_IO_ERROR_DBUS_ERROR => Some(Self::DbusError), ffi::G_IO_ERROR_HOST_UNREACHABLE => Some(Self::HostUnreachable), ffi::G_IO_ERROR_NETWORK_UNREACHABLE => Some(Self::NetworkUnreachable), ffi::G_IO_ERROR_CONNECTION_REFUSED => Some(Self::ConnectionRefused), ffi::G_IO_ERROR_PROXY_FAILED => Some(Self::ProxyFailed), ffi::G_IO_ERROR_PROXY_AUTH_FAILED => Some(Self::ProxyAuthFailed), ffi::G_IO_ERROR_PROXY_NEED_AUTH => Some(Self::ProxyNeedAuth), ffi::G_IO_ERROR_PROXY_NOT_ALLOWED => Some(Self::ProxyNotAllowed), ffi::G_IO_ERROR_BROKEN_PIPE => Some(Self::BrokenPipe), ffi::G_IO_ERROR_NOT_CONNECTED => Some(Self::NotConnected), ffi::G_IO_ERROR_MESSAGE_TOO_LARGE => Some(Self::MessageTooLarge), _ => Some(Self::Failed), } } } impl StaticType for IOErrorEnum { fn static_type() -> Type { unsafe { from_glib(ffi::g_io_error_enum_get_type()) } } } impl glib::value::ValueType for IOErrorEnum { type Type = Self; } unsafe impl<'a> FromValue<'a> for IOErrorEnum { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] impl fmt::Display for MemoryMonitorWarningLevel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "MemoryMonitorWarningLevel::{}", match *self { Self::Low => "Low", Self::Medium => "Medium", Self::Critical => "Critical", _ => "Unknown", } ) } } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] #[doc(hidden)] impl IntoGlib for MemoryMonitorWarningLevel { type GlibType = ffi::GMemoryMonitorWarningLevel; 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] #[doc(hidden)] impl FromGlib for MemoryMonitorWarningLevel { 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] impl StaticType for MemoryMonitorWarningLevel { fn static_type() -> Type { unsafe { from_glib(ffi::g_memory_monitor_warning_level_get_type()) } } } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] impl glib::value::ValueType for MemoryMonitorWarningLevel { type Type = Self; } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] unsafe impl<'a> FromValue<'a> for MemoryMonitorWarningLevel { type Checker = glib::value::GenericValueTypeChecker; unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] impl ToValue for MemoryMonitorWarningLevel { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for MountOperationResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "MountOperationResult::{}", match *self { Self::Handled => "Handled", Self::Aborted => "Aborted", Self::Unhandled => "Unhandled", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for MountOperationResult { type GlibType = ffi::GMountOperationResult; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_mount_operation_result_get_type()) } } } impl glib::value::ValueType for MountOperationResult { type Type = Self; } unsafe impl<'a> FromValue<'a> for MountOperationResult { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for NetworkConnectivity { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "NetworkConnectivity::{}", match *self { Self::Local => "Local", Self::Limited => "Limited", Self::Portal => "Portal", Self::Full => "Full", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for NetworkConnectivity { type GlibType = ffi::GNetworkConnectivity; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_network_connectivity_get_type()) } } } impl glib::value::ValueType for NetworkConnectivity { type Type = Self; } unsafe impl<'a> FromValue<'a> for NetworkConnectivity { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for NotificationPriority { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "NotificationPriority::{}", match *self { Self::Normal => "Normal", Self::Low => "Low", Self::High => "High", Self::Urgent => "Urgent", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for NotificationPriority { type GlibType = ffi::GNotificationPriority; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_notification_priority_get_type()) } } } impl glib::value::ValueType for NotificationPriority { type Type = Self; } unsafe impl<'a> FromValue<'a> for NotificationPriority { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for PasswordSave { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "PasswordSave::{}", match *self { Self::Never => "Never", Self::ForSession => "ForSession", Self::Permanently => "Permanently", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for PasswordSave { type GlibType = ffi::GPasswordSave; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_password_save_get_type()) } } } impl glib::value::ValueType for PasswordSave { type Type = Self; } unsafe impl<'a> FromValue<'a> for PasswordSave { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for ResolverRecordType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ResolverRecordType::{}", match *self { Self::Srv => "Srv", Self::Mx => "Mx", Self::Txt => "Txt", Self::Soa => "Soa", Self::Ns => "Ns", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for ResolverRecordType { type GlibType = ffi::GResolverRecordType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_resolver_record_type_get_type()) } } } impl glib::value::ValueType for ResolverRecordType { type Type = Self; } unsafe impl<'a> FromValue<'a> for ResolverRecordType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for ResourceError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ResourceError::{}", match *self { Self::NotFound => "NotFound", Self::Internal => "Internal", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for ResourceError { type GlibType = ffi::GResourceError; 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 { 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 ErrorDomain for ResourceError { fn domain() -> Quark { unsafe { from_glib(ffi::g_resource_error_quark()) } } fn code(self) -> i32 { self.into_glib() } fn from(code: i32) -> Option { match code { ffi::G_RESOURCE_ERROR_NOT_FOUND => Some(Self::NotFound), ffi::G_RESOURCE_ERROR_INTERNAL => Some(Self::Internal), value => Some(Self::__Unknown(value)), } } } impl StaticType for ResourceError { fn static_type() -> Type { unsafe { from_glib(ffi::g_resource_error_get_type()) } } } impl glib::value::ValueType for ResourceError { type Type = Self; } unsafe impl<'a> FromValue<'a> for ResourceError { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for SocketClientEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketClientEvent::{}", match *self { Self::Resolving => "Resolving", Self::Resolved => "Resolved", Self::Connecting => "Connecting", Self::Connected => "Connected", Self::ProxyNegotiating => "ProxyNegotiating", Self::ProxyNegotiated => "ProxyNegotiated", Self::TlsHandshaking => "TlsHandshaking", Self::TlsHandshaked => "TlsHandshaked", Self::Complete => "Complete", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for SocketClientEvent { type GlibType = ffi::GSocketClientEvent; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_client_event_get_type()) } } } impl glib::value::ValueType for SocketClientEvent { type Type = Self; } unsafe impl<'a> FromValue<'a> for SocketClientEvent { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for SocketFamily { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketFamily::{}", match *self { Self::Invalid => "Invalid", Self::Unix => "Unix", Self::Ipv4 => "Ipv4", Self::Ipv6 => "Ipv6", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for SocketFamily { type GlibType = ffi::GSocketFamily; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_family_get_type()) } } } impl glib::value::ValueType for SocketFamily { type Type = Self; } unsafe impl<'a> FromValue<'a> for SocketFamily { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for SocketListenerEvent { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketListenerEvent::{}", match *self { Self::Binding => "Binding", Self::Bound => "Bound", Self::Listening => "Listening", Self::Listened => "Listened", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for SocketListenerEvent { type GlibType = ffi::GSocketListenerEvent; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_listener_event_get_type()) } } } impl glib::value::ValueType for SocketListenerEvent { type Type = Self; } unsafe impl<'a> FromValue<'a> for SocketListenerEvent { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for SocketProtocol { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketProtocol::{}", match *self { Self::Unknown => "Unknown", Self::Default => "Default", Self::Tcp => "Tcp", Self::Udp => "Udp", Self::Sctp => "Sctp", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for SocketProtocol { type GlibType = ffi::GSocketProtocol; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_protocol_get_type()) } } } impl glib::value::ValueType for SocketProtocol { type Type = Self; } unsafe impl<'a> FromValue<'a> for SocketProtocol { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for SocketType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "SocketType::{}", match *self { Self::Invalid => "Invalid", Self::Stream => "Stream", Self::Datagram => "Datagram", Self::Seqpacket => "Seqpacket", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for SocketType { type GlibType = ffi::GSocketType; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_socket_type_get_type()) } } } impl glib::value::ValueType for SocketType { type Type = Self; } unsafe impl<'a> FromValue<'a> for SocketType { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for TlsAuthenticationMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsAuthenticationMode::{}", match *self { Self::None => "None", Self::Requested => "Requested", Self::Required => "Required", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for TlsAuthenticationMode { type GlibType = ffi::GTlsAuthenticationMode; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_authentication_mode_get_type()) } } } impl glib::value::ValueType for TlsAuthenticationMode { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsAuthenticationMode { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for TlsCertificateRequestFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsCertificateRequestFlags::{}", match *self { Self::None => "None", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for TlsCertificateRequestFlags { type GlibType = ffi::GTlsCertificateRequestFlags; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_certificate_request_flags_get_type()) } } } impl glib::value::ValueType for TlsCertificateRequestFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsCertificateRequestFlags { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", 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, #[doc(hidden)] __Unknown(i32), } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] impl fmt::Display for TlsChannelBindingType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsChannelBindingType::{}", match *self { Self::Unique => "Unique", Self::ServerEndPoint => "ServerEndPoint", _ => "Unknown", } ) } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] #[doc(hidden)] impl IntoGlib for TlsChannelBindingType { type GlibType = ffi::GTlsChannelBindingType; 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, Self::__Unknown(value) => value, } } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] #[doc(hidden)] impl FromGlib for TlsChannelBindingType { 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, value => Self::__Unknown(value), } } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] impl StaticType for TlsChannelBindingType { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_channel_binding_type_get_type()) } } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] impl glib::value::ValueType for TlsChannelBindingType { type Type = Self; } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] unsafe impl<'a> FromValue<'a> for TlsChannelBindingType { type Checker = glib::value::GenericValueTypeChecker; unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] impl ToValue for TlsChannelBindingType { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for TlsDatabaseLookupFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsDatabaseLookupFlags::{}", match *self { Self::None => "None", Self::Keypair => "Keypair", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for TlsDatabaseLookupFlags { type GlibType = ffi::GTlsDatabaseLookupFlags; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_database_lookup_flags_get_type()) } } } impl glib::value::ValueType for TlsDatabaseLookupFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsDatabaseLookupFlags { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for TlsInteractionResult { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsInteractionResult::{}", match *self { Self::Unhandled => "Unhandled", Self::Handled => "Handled", Self::Failed => "Failed", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for TlsInteractionResult { type GlibType = ffi::GTlsInteractionResult; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_interaction_result_get_type()) } } } impl glib::value::ValueType for TlsInteractionResult { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsInteractionResult { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for TlsRehandshakeMode { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "TlsRehandshakeMode::{}", match *self { Self::Never => "Never", Self::Safely => "Safely", Self::Unsafely => "Unsafely", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for TlsRehandshakeMode { type GlibType = ffi::GTlsRehandshakeMode; 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, } } } #[doc(hidden)] impl FromGlib for TlsRehandshakeMode { 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), } } } impl StaticType for TlsRehandshakeMode { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_rehandshake_mode_get_type()) } } } impl glib::value::ValueType for TlsRehandshakeMode { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsRehandshakeMode { type Checker = glib::value::GenericValueTypeChecker; 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 TlsRehandshakeMode { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(unix, feature = "dox"))] impl fmt::Display for UnixSocketAddressType { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "UnixSocketAddressType::{}", match *self { Self::Invalid => "Invalid", Self::Anonymous => "Anonymous", Self::Path => "Path", Self::Abstract => "Abstract", Self::AbstractPadded => "AbstractPadded", _ => "Unknown", } ) } } #[cfg(any(unix, feature = "dox"))] #[doc(hidden)] impl IntoGlib for UnixSocketAddressType { type GlibType = ffi::GUnixSocketAddressType; 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(any(unix, feature = "dox"))] #[doc(hidden)] impl FromGlib for UnixSocketAddressType { 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(any(unix, feature = "dox"))] impl StaticType for UnixSocketAddressType { fn static_type() -> Type { unsafe { from_glib(ffi::g_unix_socket_address_type_get_type()) } } } #[cfg(any(unix, feature = "dox"))] impl glib::value::ValueType for UnixSocketAddressType { type Type = Self; } #[cfg(any(unix, feature = "dox"))] unsafe impl<'a> FromValue<'a> for UnixSocketAddressType { type Checker = glib::value::GenericValueTypeChecker; unsafe fn from_value(value: &'a glib::Value) -> Self { from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0)) } } #[cfg(any(unix, feature = "dox"))] impl ToValue for UnixSocketAddressType { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[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), } impl fmt::Display for ZlibCompressorFormat { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, "ZlibCompressorFormat::{}", match *self { Self::Zlib => "Zlib", Self::Gzip => "Gzip", Self::Raw => "Raw", _ => "Unknown", } ) } } #[doc(hidden)] impl IntoGlib for ZlibCompressorFormat { type GlibType = ffi::GZlibCompressorFormat; 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 { 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 { fn static_type() -> Type { unsafe { from_glib(ffi::g_zlib_compressor_format_get_type()) } } } impl glib::value::ValueType for ZlibCompressorFormat { type Type = Self; } unsafe impl<'a> FromValue<'a> for ZlibCompressorFormat { type Checker = glib::value::GenericValueTypeChecker; 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 { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } gio-0.14.8/src/auto/file.rs000064400000000000000000003510120072674642500135520ustar 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::AppInfo; use crate::AsyncResult; use crate::Cancellable; use crate::DriveStartFlags; use crate::FileCopyFlags; use crate::FileCreateFlags; use crate::FileEnumerator; use crate::FileIOStream; use crate::FileInfo; use crate::FileInputStream; use crate::FileMeasureFlags; use crate::FileMonitor; use crate::FileMonitorFlags; use crate::FileOutputStream; use crate::FileQueryInfoFlags; use crate::FileType; use crate::Mount; use crate::MountMountFlags; use crate::MountOperation; use crate::MountUnmountFlags; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GFile")] pub struct File(Interface); match fn { type_ => || ffi::g_file_get_type(), } } impl File { //#[cfg(any(feature = "v2_56", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] //#[doc(alias = "g_file_new_build_filename")] //pub fn new_build_filename>(first_element: P, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> File { // unsafe { TODO: call ffi:g_file_new_build_filename() } //} #[doc(alias = "g_file_new_for_commandline_arg")] #[doc(alias = "new_for_commandline_arg")] pub fn for_commandline_arg>(arg: P) -> 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, Q: AsRef>( arg: P, cwd: Q, ) -> 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: P) -> 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: P, ) -> Result<(File, FileIOStream), glib::Error> { unsafe { let mut iostream = ptr::null_mut(); let mut error = ptr::null_mut(); let ret = ffi::g_file_new_tmp(tmpl.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 {} pub const NONE_FILE: Option<&File> = None; pub trait FileExt: 'static { #[doc(alias = "g_file_append_to")] fn append_to>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_append_to_async")] fn append_to_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn append_to_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_copy")] fn copy, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), glib::Error>; //#[doc(alias = "g_file_copy_async")] //fn copy_async, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, S: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S); // //fn copy_async_future + Clone + 'static, R: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Pin> + 'static>>; #[doc(alias = "g_file_copy_attributes")] fn copy_attributes, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_create")] fn create>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_create_async")] fn create_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn create_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_create_readwrite")] fn create_readwrite>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_create_readwrite_async")] fn create_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn create_readwrite_async_future( &self, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_delete")] fn delete>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_file_delete_async")] fn delete_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn delete_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_dup")] fn dup(&self) -> File; #[doc(alias = "g_file_eject_mountable_with_operation")] fn eject_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn eject_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_file_enumerate_children")] fn enumerate_children>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_equal")] fn equal>(&self, file2: &P) -> bool; #[doc(alias = "g_file_find_enclosing_mount")] fn find_enclosing_mount>( &self, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_get_basename")] #[doc(alias = "get_basename")] fn basename(&self) -> Option; #[doc(alias = "g_file_get_child")] #[doc(alias = "get_child")] fn child>(&self, name: P) -> File; #[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; #[doc(alias = "g_file_get_parent")] #[doc(alias = "get_parent")] fn parent(&self) -> Option; #[doc(alias = "g_file_get_parse_name")] #[doc(alias = "get_parse_name")] fn parse_name(&self) -> glib::GString; #[doc(alias = "g_file_get_path")] #[doc(alias = "get_path")] fn path(&self) -> Option; #[doc(alias = "g_file_get_relative_path")] #[doc(alias = "get_relative_path")] fn relative_path>(&self, descendant: &P) -> Option; #[doc(alias = "g_file_get_uri")] #[doc(alias = "get_uri")] fn uri(&self) -> glib::GString; #[doc(alias = "g_file_get_uri_scheme")] #[doc(alias = "get_uri_scheme")] fn uri_scheme(&self) -> Option; #[doc(alias = "g_file_has_parent")] fn has_parent>(&self, parent: Option<&P>) -> bool; #[doc(alias = "g_file_has_prefix")] fn has_prefix>(&self, prefix: &P) -> bool; #[doc(alias = "g_file_has_uri_scheme")] fn has_uri_scheme(&self, uri_scheme: &str) -> bool; #[doc(alias = "g_file_is_native")] fn is_native(&self) -> bool; #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_file_load_bytes")] fn load_bytes>( &self, cancellable: Option<&P>, ) -> Result<(glib::Bytes, Option), glib::Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_file_load_bytes_async")] fn load_bytes_async< P: IsA, Q: FnOnce(Result<(glib::Bytes, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn load_bytes_async_future( &self, ) -> Pin< Box_< dyn std::future::Future< Output = Result<(glib::Bytes, Option), glib::Error>, > + 'static, >, >; #[doc(alias = "g_file_load_contents")] fn load_contents>( &self, cancellable: Option<&P>, ) -> Result<(Vec, Option), glib::Error>; #[doc(alias = "g_file_load_contents_async")] fn load_contents_async< P: IsA, Q: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); fn load_contents_async_future( &self, ) -> Pin< Box_< dyn std::future::Future, Option), glib::Error>> + 'static, >, >; //#[doc(alias = "g_file_load_partial_contents_async")] //fn load_partial_contents_async, Q: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static, R: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R); // //fn load_partial_contents_async_future, Option), glib::Error>) + Send + 'static>(&self, read_more_callback: Q) -> Pin, Option), glib::Error>> + 'static>>; #[doc(alias = "g_file_make_directory")] fn make_directory>( &self, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_make_directory_async")] fn make_directory_async< P: IsA, Q: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn make_directory_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_make_directory_with_parents")] fn make_directory_with_parents>( &self, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_make_symbolic_link")] fn make_symbolic_link, Q: IsA>( &self, symlink_value: P, cancellable: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_measure_disk_usage")] fn measure_disk_usage>( &self, flags: FileMeasureFlags, cancellable: Option<&P>, progress_callback: Option>, ) -> Result<(u64, u64, u64), glib::Error>; //#[doc(alias = "g_file_measure_disk_usage_async")] //fn measure_disk_usage_async, Q: FnOnce(Result<(u64, u64, u64), glib::Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), glib::Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R); // //fn measure_disk_usage_async_future) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Pin> + 'static>>; #[doc(alias = "g_file_monitor")] fn monitor>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_monitor_directory")] fn monitor_directory>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_monitor_file")] fn monitor_file>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_mount_enclosing_volume")] fn mount_enclosing_volume< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn mount_enclosing_volume_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_file_mount_mountable")] fn mount_mountable< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn mount_mountable_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_file_move")] #[doc(alias = "move")] fn move_, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, progress_callback: Option<&mut dyn (FnMut(i64, i64))>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_open_readwrite")] fn open_readwrite>( &self, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_open_readwrite_async")] fn open_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn open_readwrite_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_file_peek_path")] fn peek_path(&self) -> Option; #[doc(alias = "g_file_poll_mountable")] fn poll_mountable, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); fn poll_mountable_future( &self, ) -> Pin> + 'static>>; #[doc(alias = "g_file_query_default_handler")] fn query_default_handler>( &self, cancellable: Option<&P>, ) -> Result; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "g_file_query_default_handler_async")] fn query_default_handler_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn query_default_handler_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_query_exists")] fn query_exists>(&self, cancellable: Option<&P>) -> bool; #[doc(alias = "g_file_query_file_type")] fn query_file_type>( &self, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> FileType; #[doc(alias = "g_file_query_filesystem_info")] fn query_filesystem_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_query_filesystem_info_async")] fn query_filesystem_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn query_filesystem_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_query_info")] fn query_info>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_query_info_async")] fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn query_info_async_future( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; //#[doc(alias = "g_file_query_settable_attributes")] //fn query_settable_attributes>(&self, cancellable: Option<&P>) -> Result; //#[doc(alias = "g_file_query_writable_namespaces")] //fn query_writable_namespaces>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_file_read")] fn read>( &self, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_read_async")] fn read_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn read_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_replace")] fn replace>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_replace_async")] fn replace_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn replace_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_replace_contents")] fn replace_contents>( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result, glib::Error>; //#[doc(alias = "g_file_replace_contents_bytes_async")] //fn replace_contents_bytes_async, Q: FnOnce(Result<(), glib::Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q); #[doc(alias = "g_file_replace_readwrite")] fn replace_readwrite>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_replace_readwrite_async")] fn replace_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn replace_readwrite_async_future( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_resolve_relative_path")] fn resolve_relative_path>(&self, relative_path: P) -> File; //#[doc(alias = "g_file_set_attribute")] //fn set_attribute>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_byte_string")] fn set_attribute_byte_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_int32")] fn set_attribute_int32>( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_int64")] fn set_attribute_int64>( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_string")] fn set_attribute_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_uint32")] fn set_attribute_uint32>( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attribute_uint64")] fn set_attribute_uint64>( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_attributes_async")] fn set_attributes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn set_attributes_async_future( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_set_attributes_from_info")] fn set_attributes_from_info>( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_file_set_display_name")] fn set_display_name>( &self, display_name: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_set_display_name_async")] fn set_display_name_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, display_name: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn set_display_name_async_future( &self, display_name: &str, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_start_mountable")] fn start_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, start_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn start_mountable_future + Clone + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_file_stop_mountable")] fn stop_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn stop_mountable_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_file_supports_thread_contexts")] fn supports_thread_contexts(&self) -> bool; #[doc(alias = "g_file_trash")] fn trash>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_file_trash_async")] fn trash_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn trash_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_unmount_mountable_with_operation")] fn unmount_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn unmount_mountable_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; } impl> FileExt for O { fn append_to>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn append_to_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn append_to_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn copy, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, 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, Q: IsA>( current_num_bytes: i64, total_num_bytes: i64, user_data: glib::ffi::gpointer, ) { let callback: *mut Option<&mut dyn (FnMut(i64, i64))> = user_data as *const _ as usize 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 = ptr::null_mut(); let _ = 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 usize as *mut _, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } //fn copy_async, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, S: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, cancellable: Option<&Q>, progress_callback: R, callback: S) { // unsafe { TODO: call ffi:g_file_copy_async() } //} // //fn copy_async_future + Clone + 'static, R: FnOnce(Result<(), glib::Error>) + Send + 'static>(&self, destination: &P, flags: FileCopyFlags, io_priority: glib::Priority, progress_callback: R) -> Pin> + 'static>> { //let destination = destination.clone(); //let progress_callback = progress_callback.map(ToOwned::to_owned); //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { // obj.copy_async( // &destination, // flags, // io_priority, // Some(cancellable), // progress_callback.as_ref().map(::std::borrow::Borrow::borrow), // move |res| { // send.resolve(res); // }, // ); //})) //} fn copy_attributes, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn create>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn create_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn create_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn create_readwrite>( &self, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn create_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn create_readwrite_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn delete>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_file_delete( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn delete_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn delete_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn dup(&self) -> File { unsafe { from_glib_full(ffi::g_file_dup(self.as_ref().to_glib_none().0)) } } fn eject_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn eject_mountable_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn enumerate_children>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn equal>(&self, file2: &P) -> bool { unsafe { from_glib(ffi::g_file_equal( self.as_ref().to_glib_none().0, file2.as_ref().to_glib_none().0, )) } } fn find_enclosing_mount>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn basename(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_basename(self.as_ref().to_glib_none().0)) } } fn child>(&self, name: P) -> File { unsafe { from_glib_full(ffi::g_file_get_child( self.as_ref().to_glib_none().0, name.as_ref().to_glib_none().0, )) } } fn child_for_display_name(&self, display_name: &str) -> Result { unsafe { let mut error = 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)) } } } fn parent(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_parent(self.as_ref().to_glib_none().0)) } } fn parse_name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_file_get_parse_name(self.as_ref().to_glib_none().0)) } } fn path(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_path(self.as_ref().to_glib_none().0)) } } fn relative_path>(&self, descendant: &P) -> 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, )) } } fn uri(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_file_get_uri(self.as_ref().to_glib_none().0)) } } fn uri_scheme(&self) -> Option { unsafe { from_glib_full(ffi::g_file_get_uri_scheme(self.as_ref().to_glib_none().0)) } } fn has_parent>(&self, parent: Option<&P>) -> 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, )) } } fn has_prefix>(&self, prefix: &P) -> bool { unsafe { from_glib(ffi::g_file_has_prefix( self.as_ref().to_glib_none().0, prefix.as_ref().to_glib_none().0, )) } } 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, )) } } fn is_native(&self) -> bool { unsafe { from_glib(ffi::g_file_is_native(self.as_ref().to_glib_none().0)) } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn load_bytes>( &self, cancellable: Option<&P>, ) -> Result<(glib::Bytes, Option), glib::Error> { unsafe { let mut etag_out = ptr::null_mut(); let mut error = 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)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn load_bytes_async< P: IsA, Q: FnOnce(Result<(glib::Bytes, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn load_bytes_async_trampoline< Q: FnOnce(Result<(glib::Bytes, Option), glib::Error>) + Send + '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 etag_out = 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 _); 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 _, ); } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn load_bytes_async_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); }); }, )) } fn load_contents>( &self, cancellable: Option<&P>, ) -> Result<(Vec, Option), glib::Error> { unsafe { 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(); let _ = 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, ); if error.is_null() { Ok(( FromGlibContainer::from_glib_full_num(contents, length.assume_init() as usize), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) } } } fn load_contents_async< P: IsA, Q: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn load_contents_async_trampoline< Q: FnOnce(Result<(Vec, Option), glib::Error>) + Send + '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 contents = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let mut etag_out = 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 usize), from_glib_full(etag_out), )) } else { Err(from_glib_full(error)) }; let callback: Box_ = Box_::from_raw(user_data as *mut _); 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_async_future( &self, ) -> Pin< Box_< dyn std::future::Future, 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); }); }, )) } //fn load_partial_contents_async, Q: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static, R: FnOnce(Result<(Vec, Option), glib::Error>) + Send + 'static>(&self, cancellable: Option<&P>, read_more_callback: Q, callback: R) { // unsafe { TODO: call ffi:g_file_load_partial_contents_async() } //} // //fn load_partial_contents_async_future, Option), glib::Error>) + Send + 'static>(&self, read_more_callback: Q) -> Pin, Option), glib::Error>> + 'static>> { //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { // obj.load_partial_contents_async( // Some(cancellable), // read_more_callback, // move |res| { // send.resolve(res); // }, // ); //})) //} fn make_directory>( &self, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_file_make_directory( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn make_directory_async< P: IsA, Q: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn make_directory_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn make_directory_with_parents>( &self, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn make_symbolic_link, Q: IsA>( &self, symlink_value: P, cancellable: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn measure_disk_usage>( &self, flags: FileMeasureFlags, cancellable: Option<&P>, progress_callback: Option>, ) -> Result<(u64, u64, u64), glib::Error> { let progress_callback_data: Box_>> = Box_::new(progress_callback); 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(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)) } } } //fn measure_disk_usage_async, Q: FnOnce(Result<(u64, u64, u64), glib::Error>) + Send + 'static, R: FnOnce(Result<(u64, u64, u64), glib::Error>) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, cancellable: Option<&P>, progress_callback: Q, callback: R) { // unsafe { TODO: call ffi:g_file_measure_disk_usage_async() } //} // //fn measure_disk_usage_async_future) + Send + 'static>(&self, flags: FileMeasureFlags, io_priority: glib::Priority, progress_callback: Q) -> Pin> + 'static>> { //let progress_callback = progress_callback.map(ToOwned::to_owned); //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { // obj.measure_disk_usage_async( // flags, // io_priority, // Some(cancellable), // progress_callback.as_ref().map(::std::borrow::Borrow::borrow), // move |res| { // send.resolve(res); // }, // ); //})) //} fn monitor>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn monitor_directory>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn monitor_file>( &self, flags: FileMonitorFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn mount_enclosing_volume< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn mount_enclosing_volume_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn mount_mountable< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn mount_mountable_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn move_, Q: IsA>( &self, destination: &P, flags: FileCopyFlags, cancellable: Option<&Q>, 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, Q: IsA>( current_num_bytes: i64, total_num_bytes: i64, user_data: glib::ffi::gpointer, ) { let callback: *mut Option<&mut dyn (FnMut(i64, i64))> = user_data as *const _ as usize 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 = ptr::null_mut(); let _ = 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 usize as *mut _, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn open_readwrite>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn open_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn open_readwrite_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn peek_path(&self) -> Option { unsafe { from_glib_none(ffi::g_file_peek_path(self.as_ref().to_glib_none().0)) } } fn poll_mountable, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn poll_mountable_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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); }); }, )) } fn query_default_handler>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn query_default_handler_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_default_handler_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn query_default_handler_async_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); }); }, )) } fn query_exists>(&self, cancellable: Option<&P>) -> 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, )) } } fn query_file_type>( &self, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> 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, )) } } fn query_filesystem_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn query_filesystem_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_filesystem_info_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn query_info>( &self, attributes: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } //fn query_settable_attributes>(&self, cancellable: Option<&P>) -> Result { // unsafe { TODO: call ffi:g_file_query_settable_attributes() } //} //fn query_writable_namespaces>(&self, cancellable: Option<&P>) -> Result { // unsafe { TODO: call ffi:g_file_query_writable_namespaces() } //} fn read>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn read_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn replace>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn replace_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn replace_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn replace_contents>( &self, contents: &[u8], etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result, glib::Error> { let length = contents.len() as usize; unsafe { let mut new_etag = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(from_glib_full(new_etag)) } else { Err(from_glib_full(error)) } } } //fn replace_contents_bytes_async, Q: FnOnce(Result<(), glib::Error>) + 'static>(&self, contents: &glib::Bytes, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, callback: Q) { // unsafe { TODO: call ffi:g_file_replace_contents_bytes_async() } //} fn replace_readwrite>( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn replace_readwrite_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn replace_readwrite_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn resolve_relative_path>(&self, relative_path: P) -> 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, )) } } //fn set_attribute>(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Option, flags: FileQueryInfoFlags, cancellable: Option<&P>) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:g_file_set_attribute() } //} fn set_attribute_byte_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_int32>( &self, attribute: &str, value: i32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_int64>( &self, attribute: &str, value: i64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_string>( &self, attribute: &str, value: &str, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_uint32>( &self, attribute: &str, value: u32, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attribute_uint64>( &self, attribute: &str, value: u64, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_attributes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, info: &FileInfo, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn set_attributes_async_trampoline< Q: FnOnce(Result) + Send + '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 info = 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 _); 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_async_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); }, ); }, )) } fn set_attributes_from_info>( &self, info: &FileInfo, flags: FileQueryInfoFlags, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_display_name>( &self, display_name: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn set_display_name_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, display_name: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn set_display_name_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn start_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: DriveStartFlags, start_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn start_mountable_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: DriveStartFlags, start_operation: Option<&P>, ) -> 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); }, ); }, )) } fn stop_mountable< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn stop_mountable_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn supports_thread_contexts(&self) -> bool { unsafe { from_glib(ffi::g_file_supports_thread_contexts( self.as_ref().to_glib_none().0, )) } } fn trash>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_file_trash( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn trash_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn trash_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn unmount_mountable_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn unmount_mountable_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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 fmt::Display for File { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("File") } } gio-0.14.8/src/auto/file_attribute_matcher.rs000064400000000000000000000050550072674642500173430ustar 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 glib::translate::*; use std::fmt; 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")] 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 fmt::Display for FileAttributeMatcher { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.to_str()) } } gio-0.14.8/src/auto/file_enumerator.rs000064400000000000000000000206330072674642500160150ustar 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::AsyncResult; use crate::Cancellable; use crate::File; use crate::FileInfo; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GFileEnumerator")] pub struct FileEnumerator(Object); match fn { type_ => || ffi::g_file_enumerator_get_type(), } } pub const NONE_FILE_ENUMERATOR: Option<&FileEnumerator> = None; pub trait FileEnumeratorExt: 'static { #[doc(alias = "g_file_enumerator_close")] fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_file_enumerator_close_async")] fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn close_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_file_enumerator_get_child")] #[doc(alias = "get_child")] fn child(&self, info: &FileInfo) -> File; #[doc(alias = "g_file_enumerator_get_container")] #[doc(alias = "get_container")] fn container(&self) -> File; #[doc(alias = "g_file_enumerator_has_pending")] fn has_pending(&self) -> bool; #[doc(alias = "g_file_enumerator_is_closed")] fn is_closed(&self) -> bool; #[doc(alias = "g_file_enumerator_next_file")] fn next_file>( &self, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_file_enumerator_next_files_async")] fn next_files_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, num_files: i32, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn next_files_async_future( &self, num_files: i32, io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>>; #[doc(alias = "g_file_enumerator_set_pending")] fn set_pending(&self, pending: bool); } impl> FileEnumeratorExt for O { fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_file_enumerator_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } 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, )) } } fn container(&self) -> File { unsafe { from_glib_none(ffi::g_file_enumerator_get_container( self.as_ref().to_glib_none().0, )) } } fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_file_enumerator_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_file_enumerator_is_closed( self.as_ref().to_glib_none().0, )) } } fn next_file>( &self, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn next_files_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, num_files: i32, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn next_files_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn set_pending(&self, pending: bool) { unsafe { ffi::g_file_enumerator_set_pending(self.as_ref().to_glib_none().0, pending.into_glib()); } } } impl fmt::Display for FileEnumerator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileEnumerator") } } gio-0.14.8/src/auto/file_icon.rs000064400000000000000000000017710072674642500145660ustar 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::File; use crate::Icon; use crate::LoadableIcon; use glib::object::IsA; use glib::translate::*; use std::fmt; 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: &P) -> 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)) } } } impl fmt::Display for FileIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileIcon") } } gio-0.14.8/src/auto/file_info.rs000064400000000000000000000440670072674642500145760ustar 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::FileAttributeMatcher; use crate::FileAttributeStatus; use crate::FileAttributeType; use crate::FileType; use crate::Icon; use glib::object::IsA; use glib::translate::*; use std::fmt; 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")] pub fn dup(&self) -> FileInfo { unsafe { from_glib_full(ffi::g_file_info_dup(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 Fundamental: Pointer) -> Option<(FileAttributeType, FileAttributeStatus)> { // unsafe { TODO: call ffi:g_file_info_get_attribute_data() } //} #[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_stringv")] #[doc(alias = "get_attribute_stringv")] pub fn attribute_stringv(&self, attribute: &str) -> Vec { 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_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)) } } #[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(any(feature = "v2_62", feature = "dox"))] #[cfg_attr(feature = "dox", 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); } } //#[doc(alias = "g_file_info_set_attribute")] //pub fn set_attribute(&self, attribute: &str, type_: FileAttributeType, value_p: /*Unimplemented*/Fundamental: 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, ); } } #[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: &P) { 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_stringv")] pub fn set_attribute_stringv(&self, attribute: &str, attr_value: &[&str]) { unsafe { ffi::g_file_info_set_attribute_stringv( 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); } } #[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: &P) { 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(any(feature = "v2_62", feature = "dox"))] #[cfg_attr(feature = "dox", 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: P) { 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: &P) { 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: &str) { unsafe { ffi::g_file_info_set_symlink_target( self.to_glib_none().0, symlink_target.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() } } impl fmt::Display for FileInfo { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileInfo") } } gio-0.14.8/src/auto/file_input_stream.rs000064400000000000000000000105610072674642500163450ustar 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::AsyncResult; use crate::Cancellable; use crate::FileInfo; use crate::InputStream; use crate::Seekable; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GFileInputStream")] pub struct FileInputStream(Object) @extends InputStream, @implements Seekable; match fn { type_ => || ffi::g_file_input_stream_get_type(), } } pub const NONE_FILE_INPUT_STREAM: Option<&FileInputStream> = None; pub trait FileInputStreamExt: 'static { #[doc(alias = "g_file_input_stream_query_info")] fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_input_stream_query_info_async")] fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>>; } impl> FileInputStreamExt for O { fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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 fmt::Display for FileInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileInputStream") } } gio-0.14.8/src/auto/file_io_stream.rs000064400000000000000000000111200072674642500156050ustar 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::AsyncResult; use crate::Cancellable; use crate::FileInfo; use crate::IOStream; use crate::Seekable; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GFileIOStream")] pub struct FileIOStream(Object) @extends IOStream, @implements Seekable; match fn { type_ => || ffi::g_file_io_stream_get_type(), } } pub const NONE_FILE_IO_STREAM: Option<&FileIOStream> = None; pub trait FileIOStreamExt: 'static { #[doc(alias = "g_file_io_stream_get_etag")] #[doc(alias = "get_etag")] fn etag(&self) -> Option; #[doc(alias = "g_file_io_stream_query_info")] fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_io_stream_query_info_async")] fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>>; } impl> FileIOStreamExt for O { fn etag(&self) -> Option { unsafe { from_glib_full(ffi::g_file_io_stream_get_etag( self.as_ref().to_glib_none().0, )) } } fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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 fmt::Display for FileIOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileIOStream") } } gio-0.14.8/src/auto/file_monitor.rs000064400000000000000000000143110072674642500153170ustar 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::File; use crate::FileMonitorEvent; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GFileMonitor")] pub struct FileMonitor(Object); match fn { type_ => || ffi::g_file_monitor_get_type(), } } pub const NONE_FILE_MONITOR: Option<&FileMonitor> = None; pub trait FileMonitorExt: 'static { #[doc(alias = "g_file_monitor_cancel")] fn cancel(&self) -> bool; #[doc(alias = "g_file_monitor_emit_event")] fn emit_event, Q: IsA>( &self, child: &P, other_file: &Q, event_type: FileMonitorEvent, ); #[doc(alias = "g_file_monitor_is_cancelled")] fn is_cancelled(&self) -> bool; #[doc(alias = "g_file_monitor_set_rate_limit")] fn set_rate_limit(&self, limit_msecs: i32); #[doc(alias = "rate-limit")] fn rate_limit(&self) -> i32; #[doc(alias = "changed")] fn connect_changed, FileMonitorEvent) + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "cancelled")] fn connect_cancelled_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "rate-limit")] fn connect_rate_limit_notify(&self, f: F) -> SignalHandlerId; } impl> FileMonitorExt for O { fn cancel(&self) -> bool { unsafe { from_glib(ffi::g_file_monitor_cancel(self.as_ref().to_glib_none().0)) } } fn emit_event, Q: IsA>( &self, child: &P, other_file: &Q, 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(), ); } } fn is_cancelled(&self) -> bool { unsafe { from_glib(ffi::g_file_monitor_is_cancelled( self.as_ref().to_glib_none().0, )) } } 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); } } fn rate_limit(&self) -> i32 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"rate-limit\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `rate-limit` getter") } } 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_cancelled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_rate_limit_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for FileMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileMonitor") } } gio-0.14.8/src/auto/file_output_stream.rs000064400000000000000000000113230072674642500165430ustar 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::AsyncResult; use crate::Cancellable; use crate::FileInfo; use crate::OutputStream; use crate::Seekable; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GFileOutputStream")] pub struct FileOutputStream(Object) @extends OutputStream, @implements Seekable; match fn { type_ => || ffi::g_file_output_stream_get_type(), } } pub const NONE_FILE_OUTPUT_STREAM: Option<&FileOutputStream> = None; pub trait FileOutputStreamExt: 'static { #[doc(alias = "g_file_output_stream_get_etag")] #[doc(alias = "get_etag")] fn etag(&self) -> Option; #[doc(alias = "g_file_output_stream_query_info")] fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_file_output_stream_query_info_async")] fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn query_info_async_future( &self, attributes: &str, io_priority: glib::Priority, ) -> Pin> + 'static>>; } impl> FileOutputStreamExt for O { fn etag(&self) -> Option { unsafe { from_glib_full(ffi::g_file_output_stream_get_etag( self.as_ref().to_glib_none().0, )) } } fn query_info>( &self, attributes: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn query_info_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &str, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn query_info_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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 fmt::Display for FileOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FileOutputStream") } } gio-0.14.8/src/auto/filename_completer.rs000064400000000000000000000055040072674642500164670ustar 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 glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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(transmute::<_, unsafe extern "C" fn()>( got_completion_data_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl Default for FilenameCompleter { fn default() -> Self { Self::new() } } impl fmt::Display for FilenameCompleter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FilenameCompleter") } } gio-0.14.8/src/auto/filter_input_stream.rs000064400000000000000000000060710072674642500167140ustar 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::InputStream; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GFilterInputStream")] pub struct FilterInputStream(Object) @extends InputStream; match fn { type_ => || ffi::g_filter_input_stream_get_type(), } } pub const NONE_FILTER_INPUT_STREAM: Option<&FilterInputStream> = None; pub trait FilterInputStreamExt: 'static { #[doc(alias = "g_filter_input_stream_get_base_stream")] #[doc(alias = "get_base_stream")] fn base_stream(&self) -> InputStream; #[doc(alias = "g_filter_input_stream_get_close_base_stream")] #[doc(alias = "get_close_base_stream")] fn closes_base_stream(&self) -> bool; #[doc(alias = "g_filter_input_stream_set_close_base_stream")] fn set_close_base_stream(&self, close_base: bool); #[doc(alias = "close-base-stream")] fn connect_close_base_stream_notify(&self, f: F) -> SignalHandlerId; } impl> FilterInputStreamExt for O { fn base_stream(&self) -> InputStream { unsafe { from_glib_none(ffi::g_filter_input_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } 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, )) } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_close_base_stream_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for FilterInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FilterInputStream") } } gio-0.14.8/src/auto/filter_output_stream.rs000064400000000000000000000061220072674642500171120ustar 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::OutputStream; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GFilterOutputStream")] pub struct FilterOutputStream(Object) @extends OutputStream; match fn { type_ => || ffi::g_filter_output_stream_get_type(), } } pub const NONE_FILTER_OUTPUT_STREAM: Option<&FilterOutputStream> = None; pub trait FilterOutputStreamExt: 'static { #[doc(alias = "g_filter_output_stream_get_base_stream")] #[doc(alias = "get_base_stream")] fn base_stream(&self) -> OutputStream; #[doc(alias = "g_filter_output_stream_get_close_base_stream")] #[doc(alias = "get_close_base_stream")] fn closes_base_stream(&self) -> bool; #[doc(alias = "g_filter_output_stream_set_close_base_stream")] fn set_close_base_stream(&self, close_base: bool); #[doc(alias = "close-base-stream")] fn connect_close_base_stream_notify(&self, f: F) -> SignalHandlerId; } impl> FilterOutputStreamExt for O { fn base_stream(&self) -> OutputStream { unsafe { from_glib_none(ffi::g_filter_output_stream_get_base_stream( self.as_ref().to_glib_none().0, )) } } 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, )) } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_close_base_stream_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for FilterOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("FilterOutputStream") } } gio-0.14.8/src/auto/flags.rs000064400000000000000000001767750072674642500137540ustar 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 bitflags::bitflags; use glib::translate::*; use glib::value::FromValue; use glib::value::ToValue; use glib::StaticType; use glib::Type; use std::fmt; bitflags! { #[doc(alias = "GAppInfoCreateFlags")] pub struct AppInfoCreateFlags: u32 { #[doc(alias = "G_APP_INFO_CREATE_NONE")] const NONE = ffi::G_APP_INFO_CREATE_NONE as u32; #[doc(alias = "G_APP_INFO_CREATE_NEEDS_TERMINAL")] const NEEDS_TERMINAL = ffi::G_APP_INFO_CREATE_NEEDS_TERMINAL as u32; #[doc(alias = "G_APP_INFO_CREATE_SUPPORTS_URIS")] const SUPPORTS_URIS = ffi::G_APP_INFO_CREATE_SUPPORTS_URIS as u32; #[doc(alias = "G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION")] const SUPPORTS_STARTUP_NOTIFICATION = ffi::G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION as u32; } } impl fmt::Display for AppInfoCreateFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for AppInfoCreateFlags { type GlibType = ffi::GAppInfoCreateFlags; fn into_glib(self) -> ffi::GAppInfoCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AppInfoCreateFlags { unsafe fn from_glib(value: ffi::GAppInfoCreateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for AppInfoCreateFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_app_info_create_flags_get_type()) } } } impl glib::value::ValueType for AppInfoCreateFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for AppInfoCreateFlags { 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)) } } impl ToValue for AppInfoCreateFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GApplicationFlags")] pub struct ApplicationFlags: u32 { #[doc(alias = "G_APPLICATION_FLAGS_NONE")] const FLAGS_NONE = ffi::G_APPLICATION_FLAGS_NONE as u32; #[doc(alias = "G_APPLICATION_IS_SERVICE")] const IS_SERVICE = ffi::G_APPLICATION_IS_SERVICE as u32; #[doc(alias = "G_APPLICATION_IS_LAUNCHER")] const IS_LAUNCHER = ffi::G_APPLICATION_IS_LAUNCHER as u32; #[doc(alias = "G_APPLICATION_HANDLES_OPEN")] const HANDLES_OPEN = ffi::G_APPLICATION_HANDLES_OPEN as u32; #[doc(alias = "G_APPLICATION_HANDLES_COMMAND_LINE")] const HANDLES_COMMAND_LINE = ffi::G_APPLICATION_HANDLES_COMMAND_LINE as u32; #[doc(alias = "G_APPLICATION_SEND_ENVIRONMENT")] const SEND_ENVIRONMENT = ffi::G_APPLICATION_SEND_ENVIRONMENT as u32; #[doc(alias = "G_APPLICATION_NON_UNIQUE")] const NON_UNIQUE = ffi::G_APPLICATION_NON_UNIQUE as u32; #[doc(alias = "G_APPLICATION_CAN_OVERRIDE_APP_ID")] const CAN_OVERRIDE_APP_ID = ffi::G_APPLICATION_CAN_OVERRIDE_APP_ID as u32; #[doc(alias = "G_APPLICATION_ALLOW_REPLACEMENT")] const ALLOW_REPLACEMENT = ffi::G_APPLICATION_ALLOW_REPLACEMENT as u32; #[doc(alias = "G_APPLICATION_REPLACE")] const REPLACE = ffi::G_APPLICATION_REPLACE as u32; } } impl fmt::Display for ApplicationFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for ApplicationFlags { type GlibType = ffi::GApplicationFlags; fn into_glib(self) -> ffi::GApplicationFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ApplicationFlags { unsafe fn from_glib(value: ffi::GApplicationFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ApplicationFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_application_flags_get_type()) } } } impl glib::value::ValueType for ApplicationFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for ApplicationFlags { 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)) } } impl ToValue for ApplicationFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GAskPasswordFlags")] pub struct AskPasswordFlags: u32 { #[doc(alias = "G_ASK_PASSWORD_NEED_PASSWORD")] const NEED_PASSWORD = ffi::G_ASK_PASSWORD_NEED_PASSWORD as u32; #[doc(alias = "G_ASK_PASSWORD_NEED_USERNAME")] const NEED_USERNAME = ffi::G_ASK_PASSWORD_NEED_USERNAME as u32; #[doc(alias = "G_ASK_PASSWORD_NEED_DOMAIN")] const NEED_DOMAIN = ffi::G_ASK_PASSWORD_NEED_DOMAIN as u32; #[doc(alias = "G_ASK_PASSWORD_SAVING_SUPPORTED")] const SAVING_SUPPORTED = ffi::G_ASK_PASSWORD_SAVING_SUPPORTED as u32; #[doc(alias = "G_ASK_PASSWORD_ANONYMOUS_SUPPORTED")] const ANONYMOUS_SUPPORTED = ffi::G_ASK_PASSWORD_ANONYMOUS_SUPPORTED as u32; #[doc(alias = "G_ASK_PASSWORD_TCRYPT")] const TCRYPT = ffi::G_ASK_PASSWORD_TCRYPT as u32; } } impl fmt::Display for AskPasswordFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for AskPasswordFlags { type GlibType = ffi::GAskPasswordFlags; fn into_glib(self) -> ffi::GAskPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for AskPasswordFlags { unsafe fn from_glib(value: ffi::GAskPasswordFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for AskPasswordFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_ask_password_flags_get_type()) } } } impl glib::value::ValueType for AskPasswordFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for AskPasswordFlags { 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)) } } impl ToValue for AskPasswordFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[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 u32; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT")] const ALLOW_REPLACEMENT = ffi::G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT as u32; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_REPLACE")] const REPLACE = ffi::G_BUS_NAME_OWNER_FLAGS_REPLACE as u32; #[doc(alias = "G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE")] const DO_NOT_QUEUE = ffi::G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE as u32; } } impl fmt::Display for BusNameOwnerFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for BusNameOwnerFlags { type GlibType = ffi::GBusNameOwnerFlags; fn into_glib(self) -> ffi::GBusNameOwnerFlags { self.bits() } } #[doc(hidden)] impl FromGlib for BusNameOwnerFlags { unsafe fn from_glib(value: ffi::GBusNameOwnerFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for BusNameOwnerFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_bus_name_owner_flags_get_type()) } } } impl glib::value::ValueType for BusNameOwnerFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for BusNameOwnerFlags { 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)) } } impl ToValue for BusNameOwnerFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[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 u32; #[doc(alias = "G_BUS_NAME_WATCHER_FLAGS_AUTO_START")] const AUTO_START = ffi::G_BUS_NAME_WATCHER_FLAGS_AUTO_START as u32; } } impl fmt::Display for BusNameWatcherFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for BusNameWatcherFlags { type GlibType = ffi::GBusNameWatcherFlags; fn into_glib(self) -> ffi::GBusNameWatcherFlags { self.bits() } } #[doc(hidden)] impl FromGlib for BusNameWatcherFlags { unsafe fn from_glib(value: ffi::GBusNameWatcherFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for BusNameWatcherFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_bus_name_watcher_flags_get_type()) } } } impl glib::value::ValueType for BusNameWatcherFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for BusNameWatcherFlags { 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)) } } impl ToValue for BusNameWatcherFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GConverterFlags")] pub struct ConverterFlags: u32 { #[doc(alias = "G_CONVERTER_NO_FLAGS")] const NONE = ffi::G_CONVERTER_NO_FLAGS as u32; #[doc(alias = "G_CONVERTER_INPUT_AT_END")] const INPUT_AT_END = ffi::G_CONVERTER_INPUT_AT_END as u32; #[doc(alias = "G_CONVERTER_FLUSH")] const FLUSH = ffi::G_CONVERTER_FLUSH as u32; } } impl fmt::Display for ConverterFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for ConverterFlags { type GlibType = ffi::GConverterFlags; fn into_glib(self) -> ffi::GConverterFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ConverterFlags { unsafe fn from_glib(value: ffi::GConverterFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ConverterFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_converter_flags_get_type()) } } } impl glib::value::ValueType for ConverterFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for ConverterFlags { 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)) } } impl ToValue for ConverterFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusCallFlags")] pub struct DBusCallFlags: u32 { #[doc(alias = "G_DBUS_CALL_FLAGS_NONE")] const NONE = ffi::G_DBUS_CALL_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_CALL_FLAGS_NO_AUTO_START")] const NO_AUTO_START = ffi::G_DBUS_CALL_FLAGS_NO_AUTO_START as u32; #[doc(alias = "G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION")] const ALLOW_INTERACTIVE_AUTHORIZATION = ffi::G_DBUS_CALL_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION as u32; } } impl fmt::Display for DBusCallFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusCallFlags { type GlibType = ffi::GDBusCallFlags; fn into_glib(self) -> ffi::GDBusCallFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusCallFlags { unsafe fn from_glib(value: ffi::GDBusCallFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusCallFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_call_flags_get_type()) } } } impl glib::value::ValueType for DBusCallFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusCallFlags { 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)) } } impl ToValue for DBusCallFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusCapabilityFlags")] pub struct DBusCapabilityFlags: u32 { #[doc(alias = "G_DBUS_CAPABILITY_FLAGS_NONE")] const NONE = ffi::G_DBUS_CAPABILITY_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING")] const UNIX_FD_PASSING = ffi::G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING as u32; } } impl fmt::Display for DBusCapabilityFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusCapabilityFlags { type GlibType = ffi::GDBusCapabilityFlags; fn into_glib(self) -> ffi::GDBusCapabilityFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusCapabilityFlags { unsafe fn from_glib(value: ffi::GDBusCapabilityFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusCapabilityFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_capability_flags_get_type()) } } } impl glib::value::ValueType for DBusCapabilityFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusCapabilityFlags { 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)) } } impl ToValue for DBusCapabilityFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusConnectionFlags")] pub struct DBusConnectionFlags: u32 { #[doc(alias = "G_DBUS_CONNECTION_FLAGS_NONE")] const NONE = ffi::G_DBUS_CONNECTION_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT")] const AUTHENTICATION_CLIENT = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT as u32; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER")] const AUTHENTICATION_SERVER = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_SERVER as u32; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS")] const AUTHENTICATION_ALLOW_ANONYMOUS = ffi::G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS as u32; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION")] const MESSAGE_BUS_CONNECTION = ffi::G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION as u32; #[doc(alias = "G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING")] const DELAY_MESSAGE_PROCESSING = ffi::G_DBUS_CONNECTION_FLAGS_DELAY_MESSAGE_PROCESSING as u32; } } impl fmt::Display for DBusConnectionFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusConnectionFlags { type GlibType = ffi::GDBusConnectionFlags; fn into_glib(self) -> ffi::GDBusConnectionFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusConnectionFlags { unsafe fn from_glib(value: ffi::GDBusConnectionFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusConnectionFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_connection_flags_get_type()) } } } impl glib::value::ValueType for DBusConnectionFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusConnectionFlags { 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)) } } impl ToValue for DBusConnectionFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[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 u32; #[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 u32; } } impl fmt::Display for DBusInterfaceSkeletonFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusInterfaceSkeletonFlags { type GlibType = ffi::GDBusInterfaceSkeletonFlags; fn into_glib(self) -> ffi::GDBusInterfaceSkeletonFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusInterfaceSkeletonFlags { unsafe fn from_glib(value: ffi::GDBusInterfaceSkeletonFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusInterfaceSkeletonFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_interface_skeleton_flags_get_type()) } } } impl glib::value::ValueType for DBusInterfaceSkeletonFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusInterfaceSkeletonFlags { 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)) } } impl ToValue for DBusInterfaceSkeletonFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusMessageFlags")] pub struct DBusMessageFlags: u32 { #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NONE")] const NONE = ffi::G_DBUS_MESSAGE_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED")] const NO_REPLY_EXPECTED = ffi::G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED as u32; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_NO_AUTO_START")] const NO_AUTO_START = ffi::G_DBUS_MESSAGE_FLAGS_NO_AUTO_START as u32; #[doc(alias = "G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION")] const ALLOW_INTERACTIVE_AUTHORIZATION = ffi::G_DBUS_MESSAGE_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION as u32; } } impl fmt::Display for DBusMessageFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusMessageFlags { type GlibType = ffi::GDBusMessageFlags; fn into_glib(self) -> ffi::GDBusMessageFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusMessageFlags { unsafe fn from_glib(value: ffi::GDBusMessageFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusMessageFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_message_flags_get_type()) } } } impl glib::value::ValueType for DBusMessageFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusMessageFlags { 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)) } } impl ToValue for DBusMessageFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusProxyFlags")] pub struct DBusProxyFlags: u32 { #[doc(alias = "G_DBUS_PROXY_FLAGS_NONE")] const NONE = ffi::G_DBUS_PROXY_FLAGS_NONE as u32; #[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 u32; #[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 u32; #[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 u32; #[doc(alias = "G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES")] const GET_INVALIDATED_PROPERTIES = ffi::G_DBUS_PROXY_FLAGS_GET_INVALIDATED_PROPERTIES as u32; #[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 u32; } } impl fmt::Display for DBusProxyFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusProxyFlags { type GlibType = ffi::GDBusProxyFlags; fn into_glib(self) -> ffi::GDBusProxyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusProxyFlags { unsafe fn from_glib(value: ffi::GDBusProxyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusProxyFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_proxy_flags_get_type()) } } } impl glib::value::ValueType for DBusProxyFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusProxyFlags { 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)) } } impl ToValue for DBusProxyFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[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 u32; #[doc(alias = "G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL")] const PRESERVE_SERIAL = ffi::G_DBUS_SEND_MESSAGE_FLAGS_PRESERVE_SERIAL as u32; } } impl fmt::Display for DBusSendMessageFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusSendMessageFlags { type GlibType = ffi::GDBusSendMessageFlags; fn into_glib(self) -> ffi::GDBusSendMessageFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusSendMessageFlags { unsafe fn from_glib(value: ffi::GDBusSendMessageFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusSendMessageFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_send_message_flags_get_type()) } } } impl glib::value::ValueType for DBusSendMessageFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusSendMessageFlags { 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)) } } impl ToValue for DBusSendMessageFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusServerFlags")] pub struct DBusServerFlags: u32 { #[doc(alias = "G_DBUS_SERVER_FLAGS_NONE")] const NONE = ffi::G_DBUS_SERVER_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_SERVER_FLAGS_RUN_IN_THREAD")] const RUN_IN_THREAD = ffi::G_DBUS_SERVER_FLAGS_RUN_IN_THREAD as u32; #[doc(alias = "G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS")] const AUTHENTICATION_ALLOW_ANONYMOUS = ffi::G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS as u32; } } impl fmt::Display for DBusServerFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusServerFlags { type GlibType = ffi::GDBusServerFlags; fn into_glib(self) -> ffi::GDBusServerFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusServerFlags { unsafe fn from_glib(value: ffi::GDBusServerFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusServerFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_server_flags_get_type()) } } } impl glib::value::ValueType for DBusServerFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusServerFlags { 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)) } } impl ToValue for DBusServerFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDBusSignalFlags")] pub struct DBusSignalFlags: u32 { #[doc(alias = "G_DBUS_SIGNAL_FLAGS_NONE")] const NONE = ffi::G_DBUS_SIGNAL_FLAGS_NONE as u32; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE")] const NO_MATCH_RULE = ffi::G_DBUS_SIGNAL_FLAGS_NO_MATCH_RULE as u32; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE")] const MATCH_ARG0_NAMESPACE = ffi::G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_NAMESPACE as u32; #[doc(alias = "G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH")] const MATCH_ARG0_PATH = ffi::G_DBUS_SIGNAL_FLAGS_MATCH_ARG0_PATH as u32; } } impl fmt::Display for DBusSignalFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DBusSignalFlags { type GlibType = ffi::GDBusSignalFlags; fn into_glib(self) -> ffi::GDBusSignalFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DBusSignalFlags { unsafe fn from_glib(value: ffi::GDBusSignalFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DBusSignalFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_dbus_signal_flags_get_type()) } } } impl glib::value::ValueType for DBusSignalFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DBusSignalFlags { 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)) } } impl ToValue for DBusSignalFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GDriveStartFlags")] pub struct DriveStartFlags: u32 { #[doc(alias = "G_DRIVE_START_NONE")] const NONE = ffi::G_DRIVE_START_NONE as u32; } } impl fmt::Display for DriveStartFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for DriveStartFlags { type GlibType = ffi::GDriveStartFlags; fn into_glib(self) -> ffi::GDriveStartFlags { self.bits() } } #[doc(hidden)] impl FromGlib for DriveStartFlags { unsafe fn from_glib(value: ffi::GDriveStartFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for DriveStartFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_drive_start_flags_get_type()) } } } impl glib::value::ValueType for DriveStartFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for DriveStartFlags { 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)) } } impl ToValue for DriveStartFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GFileCopyFlags")] pub struct FileCopyFlags: u32 { #[doc(alias = "G_FILE_COPY_NONE")] const NONE = ffi::G_FILE_COPY_NONE as u32; #[doc(alias = "G_FILE_COPY_OVERWRITE")] const OVERWRITE = ffi::G_FILE_COPY_OVERWRITE as u32; #[doc(alias = "G_FILE_COPY_BACKUP")] const BACKUP = ffi::G_FILE_COPY_BACKUP as u32; #[doc(alias = "G_FILE_COPY_NOFOLLOW_SYMLINKS")] const NOFOLLOW_SYMLINKS = ffi::G_FILE_COPY_NOFOLLOW_SYMLINKS as u32; #[doc(alias = "G_FILE_COPY_ALL_METADATA")] const ALL_METADATA = ffi::G_FILE_COPY_ALL_METADATA as u32; #[doc(alias = "G_FILE_COPY_NO_FALLBACK_FOR_MOVE")] const NO_FALLBACK_FOR_MOVE = ffi::G_FILE_COPY_NO_FALLBACK_FOR_MOVE as u32; #[doc(alias = "G_FILE_COPY_TARGET_DEFAULT_PERMS")] const TARGET_DEFAULT_PERMS = ffi::G_FILE_COPY_TARGET_DEFAULT_PERMS as u32; } } impl fmt::Display for FileCopyFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for FileCopyFlags { type GlibType = ffi::GFileCopyFlags; fn into_glib(self) -> ffi::GFileCopyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCopyFlags { unsafe fn from_glib(value: ffi::GFileCopyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileCopyFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_copy_flags_get_type()) } } } impl glib::value::ValueType for FileCopyFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileCopyFlags { 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)) } } impl ToValue for FileCopyFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GFileCreateFlags")] pub struct FileCreateFlags: u32 { #[doc(alias = "G_FILE_CREATE_NONE")] const NONE = ffi::G_FILE_CREATE_NONE as u32; #[doc(alias = "G_FILE_CREATE_PRIVATE")] const PRIVATE = ffi::G_FILE_CREATE_PRIVATE as u32; #[doc(alias = "G_FILE_CREATE_REPLACE_DESTINATION")] const REPLACE_DESTINATION = ffi::G_FILE_CREATE_REPLACE_DESTINATION as u32; } } impl fmt::Display for FileCreateFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for FileCreateFlags { type GlibType = ffi::GFileCreateFlags; fn into_glib(self) -> ffi::GFileCreateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileCreateFlags { unsafe fn from_glib(value: ffi::GFileCreateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileCreateFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_create_flags_get_type()) } } } impl glib::value::ValueType for FileCreateFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileCreateFlags { 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)) } } impl ToValue for FileCreateFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GFileMeasureFlags")] pub struct FileMeasureFlags: u32 { #[doc(alias = "G_FILE_MEASURE_NONE")] const NONE = ffi::G_FILE_MEASURE_NONE as u32; #[doc(alias = "G_FILE_MEASURE_REPORT_ANY_ERROR")] const REPORT_ANY_ERROR = ffi::G_FILE_MEASURE_REPORT_ANY_ERROR as u32; #[doc(alias = "G_FILE_MEASURE_APPARENT_SIZE")] const APPARENT_SIZE = ffi::G_FILE_MEASURE_APPARENT_SIZE as u32; #[doc(alias = "G_FILE_MEASURE_NO_XDEV")] const NO_XDEV = ffi::G_FILE_MEASURE_NO_XDEV as u32; } } impl fmt::Display for FileMeasureFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for FileMeasureFlags { type GlibType = ffi::GFileMeasureFlags; fn into_glib(self) -> ffi::GFileMeasureFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMeasureFlags { unsafe fn from_glib(value: ffi::GFileMeasureFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileMeasureFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_measure_flags_get_type()) } } } impl glib::value::ValueType for FileMeasureFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileMeasureFlags { 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)) } } impl ToValue for FileMeasureFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GFileMonitorFlags")] pub struct FileMonitorFlags: u32 { #[doc(alias = "G_FILE_MONITOR_NONE")] const NONE = ffi::G_FILE_MONITOR_NONE as u32; #[doc(alias = "G_FILE_MONITOR_WATCH_MOUNTS")] const WATCH_MOUNTS = ffi::G_FILE_MONITOR_WATCH_MOUNTS as u32; #[doc(alias = "G_FILE_MONITOR_SEND_MOVED")] const SEND_MOVED = ffi::G_FILE_MONITOR_SEND_MOVED as u32; #[doc(alias = "G_FILE_MONITOR_WATCH_HARD_LINKS")] const WATCH_HARD_LINKS = ffi::G_FILE_MONITOR_WATCH_HARD_LINKS as u32; #[doc(alias = "G_FILE_MONITOR_WATCH_MOVES")] const WATCH_MOVES = ffi::G_FILE_MONITOR_WATCH_MOVES as u32; } } impl fmt::Display for FileMonitorFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for FileMonitorFlags { type GlibType = ffi::GFileMonitorFlags; fn into_glib(self) -> ffi::GFileMonitorFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileMonitorFlags { unsafe fn from_glib(value: ffi::GFileMonitorFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileMonitorFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_monitor_flags_get_type()) } } } impl glib::value::ValueType for FileMonitorFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileMonitorFlags { 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)) } } impl ToValue for FileMonitorFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GFileQueryInfoFlags")] pub struct FileQueryInfoFlags: u32 { #[doc(alias = "G_FILE_QUERY_INFO_NONE")] const NONE = ffi::G_FILE_QUERY_INFO_NONE as u32; #[doc(alias = "G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS")] const NOFOLLOW_SYMLINKS = ffi::G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS as u32; } } impl fmt::Display for FileQueryInfoFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for FileQueryInfoFlags { type GlibType = ffi::GFileQueryInfoFlags; fn into_glib(self) -> ffi::GFileQueryInfoFlags { self.bits() } } #[doc(hidden)] impl FromGlib for FileQueryInfoFlags { unsafe fn from_glib(value: ffi::GFileQueryInfoFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for FileQueryInfoFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_file_query_info_flags_get_type()) } } } impl glib::value::ValueType for FileQueryInfoFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for FileQueryInfoFlags { 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)) } } impl ToValue for FileQueryInfoFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GIOStreamSpliceFlags")] pub struct IOStreamSpliceFlags: u32 { #[doc(alias = "G_IO_STREAM_SPLICE_NONE")] const NONE = ffi::G_IO_STREAM_SPLICE_NONE as u32; #[doc(alias = "G_IO_STREAM_SPLICE_CLOSE_STREAM1")] const CLOSE_STREAM1 = ffi::G_IO_STREAM_SPLICE_CLOSE_STREAM1 as u32; #[doc(alias = "G_IO_STREAM_SPLICE_CLOSE_STREAM2")] const CLOSE_STREAM2 = ffi::G_IO_STREAM_SPLICE_CLOSE_STREAM2 as u32; #[doc(alias = "G_IO_STREAM_SPLICE_WAIT_FOR_BOTH")] const WAIT_FOR_BOTH = ffi::G_IO_STREAM_SPLICE_WAIT_FOR_BOTH as u32; } } impl fmt::Display for IOStreamSpliceFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for IOStreamSpliceFlags { type GlibType = ffi::GIOStreamSpliceFlags; fn into_glib(self) -> ffi::GIOStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for IOStreamSpliceFlags { unsafe fn from_glib(value: ffi::GIOStreamSpliceFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for IOStreamSpliceFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_io_stream_splice_flags_get_type()) } } } impl glib::value::ValueType for IOStreamSpliceFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for IOStreamSpliceFlags { 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)) } } impl ToValue for IOStreamSpliceFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GMountMountFlags")] pub struct MountMountFlags: u32 { #[doc(alias = "G_MOUNT_MOUNT_NONE")] const NONE = ffi::G_MOUNT_MOUNT_NONE as u32; } } impl fmt::Display for MountMountFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for MountMountFlags { type GlibType = ffi::GMountMountFlags; fn into_glib(self) -> ffi::GMountMountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountMountFlags { unsafe fn from_glib(value: ffi::GMountMountFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for MountMountFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_mount_mount_flags_get_type()) } } } impl glib::value::ValueType for MountMountFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for MountMountFlags { 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)) } } impl ToValue for MountMountFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GMountUnmountFlags")] pub struct MountUnmountFlags: u32 { #[doc(alias = "G_MOUNT_UNMOUNT_NONE")] const NONE = ffi::G_MOUNT_UNMOUNT_NONE as u32; #[doc(alias = "G_MOUNT_UNMOUNT_FORCE")] const FORCE = ffi::G_MOUNT_UNMOUNT_FORCE as u32; } } impl fmt::Display for MountUnmountFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for MountUnmountFlags { type GlibType = ffi::GMountUnmountFlags; fn into_glib(self) -> ffi::GMountUnmountFlags { self.bits() } } #[doc(hidden)] impl FromGlib for MountUnmountFlags { unsafe fn from_glib(value: ffi::GMountUnmountFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for MountUnmountFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_mount_unmount_flags_get_type()) } } } impl glib::value::ValueType for MountUnmountFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for MountUnmountFlags { 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)) } } impl ToValue for MountUnmountFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GOutputStreamSpliceFlags")] pub struct OutputStreamSpliceFlags: u32 { #[doc(alias = "G_OUTPUT_STREAM_SPLICE_NONE")] const NONE = ffi::G_OUTPUT_STREAM_SPLICE_NONE as u32; #[doc(alias = "G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE")] const CLOSE_SOURCE = ffi::G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE as u32; #[doc(alias = "G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET")] const CLOSE_TARGET = ffi::G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET as u32; } } impl fmt::Display for OutputStreamSpliceFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for OutputStreamSpliceFlags { type GlibType = ffi::GOutputStreamSpliceFlags; fn into_glib(self) -> ffi::GOutputStreamSpliceFlags { self.bits() } } #[doc(hidden)] impl FromGlib for OutputStreamSpliceFlags { unsafe fn from_glib(value: ffi::GOutputStreamSpliceFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for OutputStreamSpliceFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_output_stream_splice_flags_get_type()) } } } impl glib::value::ValueType for OutputStreamSpliceFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for OutputStreamSpliceFlags { 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)) } } impl ToValue for OutputStreamSpliceFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } #[cfg(any(feature = "v2_60", feature = "dox"))] bitflags! { #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[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 u32; #[doc(alias = "G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY")] const IPV4_ONLY = ffi::G_RESOLVER_NAME_LOOKUP_FLAGS_IPV4_ONLY as u32; #[doc(alias = "G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY")] const IPV6_ONLY = ffi::G_RESOLVER_NAME_LOOKUP_FLAGS_IPV6_ONLY as u32; } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] impl fmt::Display for ResolverNameLookupFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl IntoGlib for ResolverNameLookupFlags { type GlibType = ffi::GResolverNameLookupFlags; fn into_glib(self) -> ffi::GResolverNameLookupFlags { self.bits() } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(hidden)] impl FromGlib for ResolverNameLookupFlags { unsafe fn from_glib(value: ffi::GResolverNameLookupFlags) -> Self { Self::from_bits_truncate(value) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] impl StaticType for ResolverNameLookupFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_resolver_name_lookup_flags_get_type()) } } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] impl glib::value::ValueType for ResolverNameLookupFlags { type Type = Self; } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] unsafe impl<'a> FromValue<'a> for ResolverNameLookupFlags { 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)) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] impl ToValue for ResolverNameLookupFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GResourceLookupFlags")] pub struct ResourceLookupFlags: u32 { #[doc(alias = "G_RESOURCE_LOOKUP_FLAGS_NONE")] const NONE = ffi::G_RESOURCE_LOOKUP_FLAGS_NONE as u32; } } impl fmt::Display for ResourceLookupFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for ResourceLookupFlags { type GlibType = ffi::GResourceLookupFlags; fn into_glib(self) -> ffi::GResourceLookupFlags { self.bits() } } #[doc(hidden)] impl FromGlib for ResourceLookupFlags { unsafe fn from_glib(value: ffi::GResourceLookupFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for ResourceLookupFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_resource_lookup_flags_get_type()) } } } impl glib::value::ValueType for ResourceLookupFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for ResourceLookupFlags { 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)) } } impl ToValue for ResourceLookupFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GSettingsBindFlags")] pub struct SettingsBindFlags: u32 { #[doc(alias = "G_SETTINGS_BIND_DEFAULT")] const DEFAULT = ffi::G_SETTINGS_BIND_DEFAULT as u32; #[doc(alias = "G_SETTINGS_BIND_GET")] const GET = ffi::G_SETTINGS_BIND_GET as u32; #[doc(alias = "G_SETTINGS_BIND_SET")] const SET = ffi::G_SETTINGS_BIND_SET as u32; #[doc(alias = "G_SETTINGS_BIND_NO_SENSITIVITY")] const NO_SENSITIVITY = ffi::G_SETTINGS_BIND_NO_SENSITIVITY as u32; #[doc(alias = "G_SETTINGS_BIND_GET_NO_CHANGES")] const GET_NO_CHANGES = ffi::G_SETTINGS_BIND_GET_NO_CHANGES as u32; #[doc(alias = "G_SETTINGS_BIND_INVERT_BOOLEAN")] const INVERT_BOOLEAN = ffi::G_SETTINGS_BIND_INVERT_BOOLEAN as u32; } } impl fmt::Display for SettingsBindFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for SettingsBindFlags { type GlibType = ffi::GSettingsBindFlags; fn into_glib(self) -> ffi::GSettingsBindFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SettingsBindFlags { unsafe fn from_glib(value: ffi::GSettingsBindFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for SettingsBindFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_settings_bind_flags_get_type()) } } } impl glib::value::ValueType for SettingsBindFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for SettingsBindFlags { 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)) } } impl ToValue for SettingsBindFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GSubprocessFlags")] pub struct SubprocessFlags: u32 { #[doc(alias = "G_SUBPROCESS_FLAGS_NONE")] const NONE = ffi::G_SUBPROCESS_FLAGS_NONE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDIN_PIPE")] const STDIN_PIPE = ffi::G_SUBPROCESS_FLAGS_STDIN_PIPE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDIN_INHERIT")] const STDIN_INHERIT = ffi::G_SUBPROCESS_FLAGS_STDIN_INHERIT as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDOUT_PIPE")] const STDOUT_PIPE = ffi::G_SUBPROCESS_FLAGS_STDOUT_PIPE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDOUT_SILENCE")] const STDOUT_SILENCE = ffi::G_SUBPROCESS_FLAGS_STDOUT_SILENCE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_PIPE")] const STDERR_PIPE = ffi::G_SUBPROCESS_FLAGS_STDERR_PIPE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_SILENCE")] const STDERR_SILENCE = ffi::G_SUBPROCESS_FLAGS_STDERR_SILENCE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_STDERR_MERGE")] const STDERR_MERGE = ffi::G_SUBPROCESS_FLAGS_STDERR_MERGE as u32; #[doc(alias = "G_SUBPROCESS_FLAGS_INHERIT_FDS")] const INHERIT_FDS = ffi::G_SUBPROCESS_FLAGS_INHERIT_FDS as u32; } } impl fmt::Display for SubprocessFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for SubprocessFlags { type GlibType = ffi::GSubprocessFlags; fn into_glib(self) -> ffi::GSubprocessFlags { self.bits() } } #[doc(hidden)] impl FromGlib for SubprocessFlags { unsafe fn from_glib(value: ffi::GSubprocessFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for SubprocessFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_subprocess_flags_get_type()) } } } impl glib::value::ValueType for SubprocessFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for SubprocessFlags { 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)) } } impl ToValue for SubprocessFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GTlsCertificateFlags")] pub struct TlsCertificateFlags: u32 { #[doc(alias = "G_TLS_CERTIFICATE_UNKNOWN_CA")] const UNKNOWN_CA = ffi::G_TLS_CERTIFICATE_UNKNOWN_CA as u32; #[doc(alias = "G_TLS_CERTIFICATE_BAD_IDENTITY")] const BAD_IDENTITY = ffi::G_TLS_CERTIFICATE_BAD_IDENTITY as u32; #[doc(alias = "G_TLS_CERTIFICATE_NOT_ACTIVATED")] const NOT_ACTIVATED = ffi::G_TLS_CERTIFICATE_NOT_ACTIVATED as u32; #[doc(alias = "G_TLS_CERTIFICATE_EXPIRED")] const EXPIRED = ffi::G_TLS_CERTIFICATE_EXPIRED as u32; #[doc(alias = "G_TLS_CERTIFICATE_REVOKED")] const REVOKED = ffi::G_TLS_CERTIFICATE_REVOKED as u32; #[doc(alias = "G_TLS_CERTIFICATE_INSECURE")] const INSECURE = ffi::G_TLS_CERTIFICATE_INSECURE as u32; #[doc(alias = "G_TLS_CERTIFICATE_GENERIC_ERROR")] const GENERIC_ERROR = ffi::G_TLS_CERTIFICATE_GENERIC_ERROR as u32; #[doc(alias = "G_TLS_CERTIFICATE_VALIDATE_ALL")] const VALIDATE_ALL = ffi::G_TLS_CERTIFICATE_VALIDATE_ALL as u32; } } impl fmt::Display for TlsCertificateFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for TlsCertificateFlags { type GlibType = ffi::GTlsCertificateFlags; fn into_glib(self) -> ffi::GTlsCertificateFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsCertificateFlags { unsafe fn from_glib(value: ffi::GTlsCertificateFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsCertificateFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_certificate_flags_get_type()) } } } impl glib::value::ValueType for TlsCertificateFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsCertificateFlags { 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)) } } impl ToValue for TlsCertificateFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GTlsDatabaseVerifyFlags")] pub struct TlsDatabaseVerifyFlags: u32 { #[doc(alias = "G_TLS_DATABASE_VERIFY_NONE")] const NONE = ffi::G_TLS_DATABASE_VERIFY_NONE as u32; } } impl fmt::Display for TlsDatabaseVerifyFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for TlsDatabaseVerifyFlags { type GlibType = ffi::GTlsDatabaseVerifyFlags; fn into_glib(self) -> ffi::GTlsDatabaseVerifyFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsDatabaseVerifyFlags { unsafe fn from_glib(value: ffi::GTlsDatabaseVerifyFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsDatabaseVerifyFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_database_verify_flags_get_type()) } } } impl glib::value::ValueType for TlsDatabaseVerifyFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsDatabaseVerifyFlags { 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)) } } impl ToValue for TlsDatabaseVerifyFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } bitflags! { #[doc(alias = "GTlsPasswordFlags")] pub struct TlsPasswordFlags: u32 { #[doc(alias = "G_TLS_PASSWORD_NONE")] const NONE = ffi::G_TLS_PASSWORD_NONE as u32; #[doc(alias = "G_TLS_PASSWORD_RETRY")] const RETRY = ffi::G_TLS_PASSWORD_RETRY as u32; #[doc(alias = "G_TLS_PASSWORD_MANY_TRIES")] const MANY_TRIES = ffi::G_TLS_PASSWORD_MANY_TRIES as u32; #[doc(alias = "G_TLS_PASSWORD_FINAL_TRY")] const FINAL_TRY = ffi::G_TLS_PASSWORD_FINAL_TRY as u32; } } impl fmt::Display for TlsPasswordFlags { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { ::fmt(self, f) } } #[doc(hidden)] impl IntoGlib for TlsPasswordFlags { type GlibType = ffi::GTlsPasswordFlags; fn into_glib(self) -> ffi::GTlsPasswordFlags { self.bits() } } #[doc(hidden)] impl FromGlib for TlsPasswordFlags { unsafe fn from_glib(value: ffi::GTlsPasswordFlags) -> Self { Self::from_bits_truncate(value) } } impl StaticType for TlsPasswordFlags { fn static_type() -> Type { unsafe { from_glib(ffi::g_tls_password_flags_get_type()) } } } impl glib::value::ValueType for TlsPasswordFlags { type Type = Self; } unsafe impl<'a> FromValue<'a> for TlsPasswordFlags { 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)) } } impl ToValue for TlsPasswordFlags { 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 } fn value_type(&self) -> glib::Type { Self::static_type() } } gio-0.14.8/src/auto/functions.rs000064400000000000000000000500040072674642500146400ustar 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::AsyncResult; use crate::BusType; use crate::Cancellable; use crate::DBusConnection; use crate::File; use crate::IOErrorEnum; use crate::IOStream; use crate::Icon; use crate::InputStream; use crate::Resource; use crate::ResourceLookupFlags; use crate::SettingsBackend; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::mem; use std::pin::Pin; use std::ptr; #[doc(alias = "g_bus_get")] pub fn bus_get< P: IsA, Q: FnOnce(Result) + Send + 'static, >( bus_type: BusType, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn bus_get_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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<&P>, ) -> Result { unsafe { let mut error = 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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<&str>, data: &[u8]) -> (glib::GString, bool) { let data_size = data.len() as usize; unsafe { let mut result_uncertain = mem::MaybeUninit::uninit(); let ret = from_glib_full(ffi::g_content_type_guess( filename.to_glib_none().0, data.to_glib_none().0, data_size, result_uncertain.as_mut_ptr(), )); let result_uncertain = result_uncertain.assume_init(); (ret, from_glib(result_uncertain)) } } #[doc(alias = "g_content_type_guess_for_tree")] pub fn content_type_guess_for_tree>(root: &P) -> 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, )) } } #[cfg(any(feature = "v2_52", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_52")))] #[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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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<&P>, ) -> Result { unsafe { let mut error = 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: IsA, Q: FnOnce(Result<(IOStream, Option), glib::Error>) + Send + 'static, >( address: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn dbus_address_get_stream_trampoline< Q: FnOnce(Result<(IOStream, Option), glib::Error>) + Send + '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 out_guid = 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 _); 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<&P>, ) -> Result<(IOStream, Option), glib::Error> { unsafe { let mut out_guid = ptr::null_mut(); let mut error = 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)) } } } #[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)) } } #[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 = ptr::null_mut(); let _ = ffi::g_dbus_is_supported_address(string.to_glib_none().0, &mut error); 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: P) -> /*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: P, 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: P) { 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: P, scope: /*Ignored*/&mut IOModuleScope) { // unsafe { TODO: call ffi:g_io_modules_scan_all_in_directory_with_scope() } //} #[doc(alias = "g_io_scheduler_cancel_all_jobs")] pub fn io_scheduler_cancel_all_jobs() { unsafe { ffi::g_io_scheduler_cancel_all_jobs(); } } //#[doc(alias = "g_io_scheduler_push_job")] //pub fn io_scheduler_push_job>(job_func: /*Unimplemented*/Fn(/*Ignored*/IOSchedulerJob, Option<&Cancellable>) -> bool, user_data: /*Unimplemented*/Option, io_priority: i32, cancellable: Option<&P>) { // unsafe { TODO: call ffi:g_io_scheduler_push_job() } //} #[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_networking_init")] pub fn networking_init() { unsafe { ffi::g_networking_init(); } } #[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 = 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 = mem::MaybeUninit::uninit(); let mut flags = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = ffi::g_resources_get_info( path.to_glib_none().0, lookup_flags.into_glib(), size.as_mut_ptr(), flags.as_mut_ptr(), &mut error, ); let size = size.assume_init(); let flags = flags.assume_init(); if error.is_null() { Ok((size, flags)) } 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 = 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 = 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_unix_is_mount_path_system_internal")] pub fn unix_is_mount_path_system_internal>(mount_path: P) -> bool { unsafe { from_glib(ffi::g_unix_is_mount_path_system_internal( mount_path.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_unix_is_system_device_path")] pub fn unix_is_system_device_path>(device_path: P) -> bool { unsafe { from_glib(ffi::g_unix_is_system_device_path( device_path.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[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.14.8/src/auto/icon.rs000064400000000000000000000044760072674642500135740ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GIcon")] pub struct Icon(Interface); match fn { type_ => || ffi::g_icon_get_type(), } } impl Icon { #[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_hash")] pub fn hash(&self) -> u32 { unsafe { ffi::g_icon_hash( ToGlibPtr::<*mut ffi::GIcon>::to_glib_none(self).0 as glib::ffi::gconstpointer, ) } } #[doc(alias = "g_icon_new_for_string")] #[doc(alias = "new_for_string")] pub fn for_string(str: &str) -> Result { unsafe { let mut error = 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)) } } } } pub const NONE_ICON: Option<&Icon> = None; pub trait IconExt: 'static { #[doc(alias = "g_icon_equal")] fn equal>(&self, icon2: Option<&P>) -> bool; #[doc(alias = "g_icon_serialize")] fn serialize(&self) -> Option; #[doc(alias = "g_icon_to_string")] fn to_string(&self) -> Option; } impl> IconExt for O { fn equal>(&self, icon2: Option<&P>) -> 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, )) } } fn serialize(&self) -> Option { unsafe { from_glib_full(ffi::g_icon_serialize(self.as_ref().to_glib_none().0)) } } fn to_string(&self) -> Option { unsafe { from_glib_full(ffi::g_icon_to_string(self.as_ref().to_glib_none().0)) } } } impl fmt::Display for Icon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Icon") } } gio-0.14.8/src/auto/inet_address.rs000064400000000000000000000430020072674642500152740ustar 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::SocketFamily; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GInetAddress")] pub struct InetAddress(Object); match fn { type_ => || ffi::g_inet_address_get_type(), } } impl InetAddress { #[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 fmt::Display for InetAddress { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&InetAddressExt::to_str(self)) } } unsafe impl Send for InetAddress {} unsafe impl Sync for InetAddress {} pub const NONE_INET_ADDRESS: Option<&InetAddress> = None; pub trait InetAddressExt: 'static { #[doc(alias = "g_inet_address_equal")] fn equal>(&self, other_address: &P) -> bool; #[doc(alias = "g_inet_address_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily; #[doc(alias = "g_inet_address_get_is_any")] #[doc(alias = "get_is_any")] fn is_any(&self) -> bool; #[doc(alias = "g_inet_address_get_is_link_local")] #[doc(alias = "get_is_link_local")] fn is_link_local(&self) -> bool; #[doc(alias = "g_inet_address_get_is_loopback")] #[doc(alias = "get_is_loopback")] fn is_loopback(&self) -> bool; #[doc(alias = "g_inet_address_get_is_mc_global")] #[doc(alias = "get_is_mc_global")] fn is_mc_global(&self) -> bool; #[doc(alias = "g_inet_address_get_is_mc_link_local")] #[doc(alias = "get_is_mc_link_local")] fn is_mc_link_local(&self) -> bool; #[doc(alias = "g_inet_address_get_is_mc_node_local")] #[doc(alias = "get_is_mc_node_local")] fn is_mc_node_local(&self) -> bool; #[doc(alias = "g_inet_address_get_is_mc_org_local")] #[doc(alias = "get_is_mc_org_local")] fn is_mc_org_local(&self) -> bool; #[doc(alias = "g_inet_address_get_is_mc_site_local")] #[doc(alias = "get_is_mc_site_local")] fn is_mc_site_local(&self) -> bool; #[doc(alias = "g_inet_address_get_is_multicast")] #[doc(alias = "get_is_multicast")] fn is_multicast(&self) -> bool; #[doc(alias = "g_inet_address_get_is_site_local")] #[doc(alias = "get_is_site_local")] fn is_site_local(&self) -> bool; #[doc(alias = "g_inet_address_get_native_size")] #[doc(alias = "get_native_size")] fn native_size(&self) -> usize; #[doc(alias = "g_inet_address_to_string")] #[doc(alias = "to_string")] fn to_str(&self) -> glib::GString; //fn bytes(&self) -> /*Unimplemented*/Fundamental: Pointer; #[doc(alias = "is-any")] fn connect_is_any_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "is-link-local")] fn connect_is_link_local_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-loopback")] fn connect_is_loopback_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-mc-global")] fn connect_is_mc_global_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-mc-link-local")] fn connect_is_mc_link_local_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-mc-node-local")] fn connect_is_mc_node_local_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-mc-org-local")] fn connect_is_mc_org_local_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-mc-site-local")] fn connect_is_mc_site_local_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-multicast")] fn connect_is_multicast_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "is-site-local")] fn connect_is_site_local_notify( &self, f: F, ) -> SignalHandlerId; } impl> InetAddressExt for O { fn equal>(&self, other_address: &P) -> bool { unsafe { from_glib(ffi::g_inet_address_equal( self.as_ref().to_glib_none().0, other_address.as_ref().to_glib_none().0, )) } } fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_inet_address_get_family( self.as_ref().to_glib_none().0, )) } } fn is_any(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_any( self.as_ref().to_glib_none().0, )) } } fn is_link_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_link_local( self.as_ref().to_glib_none().0, )) } } fn is_loopback(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_loopback( self.as_ref().to_glib_none().0, )) } } fn is_mc_global(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_mc_global( self.as_ref().to_glib_none().0, )) } } 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, )) } } 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, )) } } 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, )) } } 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, )) } } fn is_multicast(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_multicast( self.as_ref().to_glib_none().0, )) } } fn is_site_local(&self) -> bool { unsafe { from_glib(ffi::g_inet_address_get_is_site_local( self.as_ref().to_glib_none().0, )) } } fn native_size(&self) -> usize { unsafe { ffi::g_inet_address_get_native_size(self.as_ref().to_glib_none().0) } } 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*/Fundamental: Pointer { // unsafe { // let mut value = glib::Value::from_type(::static_type()); // glib::gobject_ffi::g_object_get_property(self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"bytes\0".as_ptr() as *const _, value.to_glib_none_mut().0); // value.get().expect("Return Value for property `bytes` getter") // } //} 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(transmute::<_, unsafe extern "C" fn()>( notify_is_any_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_link_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_loopback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_mc_global_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_mc_link_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_mc_node_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_mc_org_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_mc_site_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_multicast_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_is_site_local_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.14.8/src/auto/inet_address_mask.rs000064400000000000000000000176640072674642500163260ustar 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::InetAddress; use crate::Initable; use crate::SocketFamily; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GInetAddressMask")] pub struct InetAddressMask(Object) @implements Initable; match fn { type_ => || ffi::g_inet_address_mask_get_type(), } } impl InetAddressMask { #[doc(alias = "g_inet_address_mask_new")] pub fn new>(addr: &P, length: u32) -> Result { unsafe { let mut error = 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 = 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 fmt::Display for InetAddressMask { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&InetAddressMaskExt::to_str(self)) } } unsafe impl Send for InetAddressMask {} unsafe impl Sync for InetAddressMask {} pub const NONE_INET_ADDRESS_MASK: Option<&InetAddressMask> = None; pub trait InetAddressMaskExt: 'static { #[doc(alias = "g_inet_address_mask_equal")] fn equal>(&self, mask2: &P) -> bool; #[doc(alias = "g_inet_address_mask_get_address")] #[doc(alias = "get_address")] fn address(&self) -> InetAddress; #[doc(alias = "g_inet_address_mask_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily; #[doc(alias = "g_inet_address_mask_get_length")] #[doc(alias = "get_length")] fn length(&self) -> u32; #[doc(alias = "g_inet_address_mask_matches")] fn matches>(&self, address: &P) -> bool; #[doc(alias = "g_inet_address_mask_to_string")] #[doc(alias = "to_string")] fn to_str(&self) -> glib::GString; fn set_address>(&self, address: Option<&P>); fn set_length(&self, length: u32); #[doc(alias = "address")] fn connect_address_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "length")] fn connect_length_notify(&self, f: F) -> SignalHandlerId; } impl> InetAddressMaskExt for O { fn equal>(&self, mask2: &P) -> bool { unsafe { from_glib(ffi::g_inet_address_mask_equal( self.as_ref().to_glib_none().0, mask2.as_ref().to_glib_none().0, )) } } fn address(&self) -> InetAddress { unsafe { from_glib_none(ffi::g_inet_address_mask_get_address( self.as_ref().to_glib_none().0, )) } } fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_inet_address_mask_get_family( self.as_ref().to_glib_none().0, )) } } fn length(&self) -> u32 { unsafe { ffi::g_inet_address_mask_get_length(self.as_ref().to_glib_none().0) } } fn matches>(&self, address: &P) -> bool { unsafe { from_glib(ffi::g_inet_address_mask_matches( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, )) } } 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>) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"address\0".as_ptr() as *const _, address.to_value().to_glib_none().0, ); } } fn set_length(&self, length: u32) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"length\0".as_ptr() as *const _, length.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_length_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } gio-0.14.8/src/auto/inet_socket_address.rs000064400000000000000000000055130072674642500166510ustar 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::InetAddress; use crate::SocketAddress; use crate::SocketConnectable; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; 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 { #[doc(alias = "g_inet_socket_address_new")] pub fn new>(address: &P, 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 {} pub const NONE_INET_SOCKET_ADDRESS: Option<&InetSocketAddress> = None; pub trait InetSocketAddressExt: 'static { #[doc(alias = "g_inet_socket_address_get_address")] #[doc(alias = "get_address")] fn address(&self) -> InetAddress; #[doc(alias = "g_inet_socket_address_get_flowinfo")] #[doc(alias = "get_flowinfo")] fn flowinfo(&self) -> u32; #[doc(alias = "g_inet_socket_address_get_port")] #[doc(alias = "get_port")] fn port(&self) -> u16; #[doc(alias = "g_inet_socket_address_get_scope_id")] #[doc(alias = "get_scope_id")] fn scope_id(&self) -> u32; } impl> InetSocketAddressExt for O { fn address(&self) -> InetAddress { unsafe { from_glib_none(ffi::g_inet_socket_address_get_address( self.as_ref().to_glib_none().0, )) } } fn flowinfo(&self) -> u32 { unsafe { ffi::g_inet_socket_address_get_flowinfo(self.as_ref().to_glib_none().0) } } fn port(&self) -> u16 { unsafe { ffi::g_inet_socket_address_get_port(self.as_ref().to_glib_none().0) } } fn scope_id(&self) -> u32 { unsafe { ffi::g_inet_socket_address_get_scope_id(self.as_ref().to_glib_none().0) } } } impl fmt::Display for InetSocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("InetSocketAddress") } } gio-0.14.8/src/auto/initable.rs000064400000000000000000000023760072674642500144300ustar 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::Cancellable; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GInitable")] pub struct Initable(Interface); match fn { type_ => || ffi::g_initable_get_type(), } } pub const NONE_INITABLE: Option<&Initable> = None; pub trait InitableExt: 'static { #[doc(alias = "g_initable_init")] unsafe fn init>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; } impl> InitableExt for O { unsafe fn init>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { let mut error = ptr::null_mut(); let _ = ffi::g_initable_init( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } impl fmt::Display for Initable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Initable") } } gio-0.14.8/src/auto/input_stream.rs000064400000000000000000000261230072674642500153470ustar 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::AsyncResult; use crate::Cancellable; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GInputStream")] pub struct InputStream(Object); match fn { type_ => || ffi::g_input_stream_get_type(), } } pub const NONE_INPUT_STREAM: Option<&InputStream> = None; pub trait InputStreamExt: 'static { #[doc(alias = "g_input_stream_clear_pending")] fn clear_pending(&self); #[doc(alias = "g_input_stream_close")] fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_input_stream_close_async")] fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn close_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_input_stream_has_pending")] fn has_pending(&self) -> bool; #[doc(alias = "g_input_stream_is_closed")] fn is_closed(&self) -> bool; #[doc(alias = "g_input_stream_read_bytes")] fn read_bytes>( &self, count: usize, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_input_stream_read_bytes_async")] fn read_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn read_bytes_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_input_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error>; #[doc(alias = "g_input_stream_skip")] fn skip>( &self, count: usize, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_input_stream_skip_async")] fn skip_async, Q: FnOnce(Result) + Send + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn skip_async_future( &self, count: usize, io_priority: glib::Priority, ) -> Pin> + 'static>>; } impl> InputStreamExt for O { fn clear_pending(&self) { unsafe { ffi::g_input_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_input_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_input_stream_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_input_stream_is_closed( self.as_ref().to_glib_none().0, )) } } fn read_bytes>( &self, count: usize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn read_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_bytes_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_input_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn skip>( &self, count: usize, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn skip_async, Q: FnOnce(Result) + Send + 'static>( &self, count: usize, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn skip_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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 fmt::Display for InputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("InputStream") } } gio-0.14.8/src/auto/io_stream.rs000064400000000000000000000146050072674642500146210ustar 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::AsyncResult; use crate::Cancellable; use crate::InputStream; use crate::OutputStream; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GIOStream")] pub struct IOStream(Object); match fn { type_ => || ffi::g_io_stream_get_type(), } } impl IOStream {} pub const NONE_IO_STREAM: Option<&IOStream> = None; pub trait IOStreamExt: 'static { #[doc(alias = "g_io_stream_clear_pending")] fn clear_pending(&self); #[doc(alias = "g_io_stream_close")] fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_io_stream_close_async")] fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn close_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_io_stream_get_input_stream")] #[doc(alias = "get_input_stream")] fn input_stream(&self) -> InputStream; #[doc(alias = "g_io_stream_get_output_stream")] #[doc(alias = "get_output_stream")] fn output_stream(&self) -> OutputStream; #[doc(alias = "g_io_stream_has_pending")] fn has_pending(&self) -> bool; #[doc(alias = "g_io_stream_is_closed")] fn is_closed(&self) -> bool; #[doc(alias = "g_io_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error>; #[doc(alias = "closed")] fn connect_closed_notify(&self, f: F) -> SignalHandlerId; } impl> IOStreamExt for O { fn clear_pending(&self) { unsafe { ffi::g_io_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_io_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn input_stream(&self) -> InputStream { unsafe { from_glib_none(ffi::g_io_stream_get_input_stream( self.as_ref().to_glib_none().0, )) } } fn output_stream(&self) -> OutputStream { unsafe { from_glib_none(ffi::g_io_stream_get_output_stream( self.as_ref().to_glib_none().0, )) } } fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_io_stream_has_pending(self.as_ref().to_glib_none().0)) } } fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_io_stream_is_closed(self.as_ref().to_glib_none().0)) } } fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_io_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } 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(transmute::<_, unsafe extern "C" fn()>( notify_closed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for IOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("IOStream") } } gio-0.14.8/src/auto/list_model.rs000064400000000000000000000065120072674642500147700ustar 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 glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GListModel")] pub struct ListModel(Interface); match fn { type_ => || ffi::g_list_model_get_type(), } } pub const NONE_LIST_MODEL: Option<&ListModel> = None; pub trait ListModelExt: 'static { #[doc(alias = "g_list_model_get_item_type")] #[doc(alias = "get_item_type")] fn item_type(&self) -> glib::types::Type; #[doc(alias = "g_list_model_get_n_items")] #[doc(alias = "get_n_items")] fn n_items(&self) -> u32; #[doc(alias = "g_list_model_get_object")] #[doc(alias = "get_object")] fn item(&self, position: u32) -> Option; #[doc(alias = "g_list_model_items_changed")] fn items_changed(&self, position: u32, removed: u32, added: u32); #[doc(alias = "items-changed")] fn connect_items_changed(&self, f: F) -> SignalHandlerId; } impl> ListModelExt for O { fn item_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_list_model_get_item_type( self.as_ref().to_glib_none().0, )) } } fn n_items(&self) -> u32 { unsafe { ffi::g_list_model_get_n_items(self.as_ref().to_glib_none().0) } } fn item(&self, position: u32) -> Option { unsafe { from_glib_full(ffi::g_list_model_get_object( self.as_ref().to_glib_none().0, position, )) } } 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, ); } } 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(transmute::<_, unsafe extern "C" fn()>( items_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ListModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ListModel") } } gio-0.14.8/src/auto/list_store.rs000064400000000000000000000113000072674642500150130ustar 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::ListModel; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::fmt; #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] use std::mem; glib::wrapper! { #[doc(alias = "GListStore")] pub struct ListStore(Object) @implements ListModel; match fn { type_ => || ffi::g_list_store_get_type(), } } impl ListStore { #[doc(alias = "g_list_store_new")] pub fn new(item_type: glib::types::Type) -> ListStore { unsafe { from_glib_full(ffi::g_list_store_new(item_type.into_glib())) } } // rustdoc-stripper-ignore-next /// Creates a new builder-pattern struct instance to construct [`ListStore`] objects. /// /// This method returns an instance of [`ListStoreBuilder`] which can be used to create [`ListStore`] objects. pub fn builder() -> ListStoreBuilder { ListStoreBuilder::default() } #[doc(alias = "g_list_store_append")] pub fn append>(&self, item: &P) { unsafe { ffi::g_list_store_append(self.to_glib_none().0, item.as_ref().to_glib_none().0); } } #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] #[doc(alias = "g_list_store_find")] pub fn find>(&self, item: &P) -> Option { unsafe { let mut position = 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(), )); let position = position.assume_init(); if ret { Some(position) } else { None } } } //#[cfg(any(feature = "v2_64", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] //#[doc(alias = "g_list_store_find_with_equal_func")] //pub fn find_with_equal_func>(&self, item: &P, equal_func: /*Unimplemented*/FnMut(/*Unimplemented*/Option, /*Unimplemented*/Option) -> bool) -> Option { // unsafe { TODO: call ffi:g_list_store_find_with_equal_func() } //} #[doc(alias = "g_list_store_insert")] pub fn insert>(&self, position: u32, item: &P) { 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); } } #[doc(alias = "g_list_store_splice")] pub fn splice(&self, position: u32, n_removals: u32, additions: &[glib::Object]) { let n_additions = additions.len() as u32; unsafe { ffi::g_list_store_splice( self.to_glib_none().0, position, n_removals, additions.to_glib_none().0, n_additions, ); } } } #[derive(Clone, Default)] // 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 pub struct ListStoreBuilder { item_type: Option, } impl ListStoreBuilder { // rustdoc-stripper-ignore-next /// Create a new [`ListStoreBuilder`]. pub fn new() -> Self { Self::default() } // rustdoc-stripper-ignore-next /// Build the [`ListStore`]. pub fn build(self) -> ListStore { let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; if let Some(ref item_type) = self.item_type { properties.push(("item-type", item_type)); } glib::Object::new::(&properties) .expect("Failed to create an instance of ListStore") } pub fn item_type(mut self, item_type: glib::types::Type) -> Self { self.item_type = Some(item_type); self } } impl fmt::Display for ListStore { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ListStore") } } gio-0.14.8/src/auto/loadable_icon.rs000064400000000000000000000104210072674642500154020ustar 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::AsyncResult; use crate::Cancellable; use crate::Icon; use crate::InputStream; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GLoadableIcon")] pub struct LoadableIcon(Interface) @requires Icon; match fn { type_ => || ffi::g_loadable_icon_get_type(), } } pub const NONE_LOADABLE_ICON: Option<&LoadableIcon> = None; pub trait LoadableIconExt: 'static { #[doc(alias = "g_loadable_icon_load")] fn load>( &self, size: i32, cancellable: Option<&P>, ) -> Result<(InputStream, glib::GString), glib::Error>; #[doc(alias = "g_loadable_icon_load_async")] fn load_async< P: IsA, Q: FnOnce(Result<(InputStream, glib::GString), glib::Error>) + Send + 'static, >( &self, size: i32, cancellable: Option<&P>, callback: Q, ); fn load_async_future( &self, size: i32, ) -> Pin< Box_< dyn std::future::Future> + 'static, >, >; } impl> LoadableIconExt for O { fn load>( &self, size: i32, cancellable: Option<&P>, ) -> Result<(InputStream, glib::GString), glib::Error> { unsafe { let mut type_ = ptr::null_mut(); let mut error = 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)) } } } fn load_async< P: IsA, Q: FnOnce(Result<(InputStream, glib::GString), glib::Error>) + Send + 'static, >( &self, size: i32, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn load_async_trampoline< Q: FnOnce(Result<(InputStream, glib::GString), glib::Error>) + Send + '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 type_ = 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 _); 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_async_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 fmt::Display for LoadableIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("LoadableIcon") } } gio-0.14.8/src/auto/memory_input_stream.rs000064400000000000000000000036230072674642500167370ustar 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::InputStream; use crate::PollableInputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; 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 { #[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() } } pub const NONE_MEMORY_INPUT_STREAM: Option<&MemoryInputStream> = None; pub trait MemoryInputStreamExt: 'static { #[doc(alias = "g_memory_input_stream_add_bytes")] fn add_bytes(&self, bytes: &glib::Bytes); } impl> MemoryInputStreamExt for O { 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 fmt::Display for MemoryInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MemoryInputStream") } } gio-0.14.8/src/auto/memory_monitor.rs000064400000000000000000000050550072674642500157150ustar 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::Initable; use crate::MemoryMonitorWarningLevel; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GMemoryMonitor")] pub struct MemoryMonitor(Interface) @requires Initable; match fn { type_ => || ffi::g_memory_monitor_get_type(), } } impl MemoryMonitor { #[doc(alias = "g_memory_monitor_dup_default")] pub fn dup_default() -> MemoryMonitor { unsafe { from_glib_full(ffi::g_memory_monitor_dup_default()) } } } pub const NONE_MEMORY_MONITOR: Option<&MemoryMonitor> = None; pub trait MemoryMonitorExt: 'static { #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] #[doc(alias = "low-memory-warning")] fn connect_low_memory_warning( &self, f: F, ) -> SignalHandlerId; } impl> MemoryMonitorExt for O { #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] 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(transmute::<_, unsafe extern "C" fn()>( low_memory_warning_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for MemoryMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MemoryMonitor") } } gio-0.14.8/src/auto/memory_output_stream.rs000064400000000000000000000056170072674642500171450ustar 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::OutputStream; use crate::PollableOutputStream; use crate::Seekable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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 { #[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() } } } pub const NONE_MEMORY_OUTPUT_STREAM: Option<&MemoryOutputStream> = None; pub trait MemoryOutputStreamExt: 'static { #[doc(alias = "g_memory_output_stream_get_data_size")] #[doc(alias = "get_data_size")] fn data_size(&self) -> usize; #[doc(alias = "g_memory_output_stream_steal_as_bytes")] fn steal_as_bytes(&self) -> glib::Bytes; #[doc(alias = "data-size")] fn connect_data_size_notify(&self, f: F) -> SignalHandlerId; } impl> MemoryOutputStreamExt for O { fn data_size(&self) -> usize { unsafe { ffi::g_memory_output_stream_get_data_size(self.as_ref().to_glib_none().0) } } 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, )) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_data_size_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for MemoryOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MemoryOutputStream") } } gio-0.14.8/src/auto/menu.rs000064400000000000000000000121040072674642500135730ustar 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::MenuItem; use crate::MenuModel; use glib::object::IsA; use glib::translate::*; use std::fmt; 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: &P) { 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: &P) { 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: &P, ) { 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: &P, ) { 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: &P) { 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: &P) { 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() } } impl fmt::Display for Menu { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Menu") } } gio-0.14.8/src/auto/menu_attribute_iter.rs000064400000000000000000000026600072674642500167070ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GMenuAttributeIter")] pub struct MenuAttributeIter(Object); match fn { type_ => || ffi::g_menu_attribute_iter_get_type(), } } pub const NONE_MENU_ATTRIBUTE_ITER: Option<&MenuAttributeIter> = None; pub trait MenuAttributeIterExt: 'static { #[doc(alias = "g_menu_attribute_iter_get_next")] #[doc(alias = "get_next")] fn next(&self) -> Option<(glib::GString, glib::Variant)>; } impl> MenuAttributeIterExt for O { fn next(&self) -> Option<(glib::GString, glib::Variant)> { unsafe { let mut out_name = ptr::null(); let mut value = 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 fmt::Display for MenuAttributeIter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MenuAttributeIter") } } gio-0.14.8/src/auto/menu_item.rs000064400000000000000000000136730072674642500146250ustar 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::Icon; use crate::MenuModel; use glib::object::IsA; use glib::translate::*; use std::fmt; 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: &P, 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: &P) -> 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: &P) -> 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*/Fundamental: 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*/Fundamental: 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*/Fundamental: 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: &P) { 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<&P>) { 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<&P>) { 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<&P>) { unsafe { ffi::g_menu_item_set_submenu( self.to_glib_none().0, submenu.map(|p| p.as_ref()).to_glib_none().0, ); } } } impl fmt::Display for MenuItem { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MenuItem") } } gio-0.14.8/src/auto/menu_link_iter.rs000064400000000000000000000025700072674642500156410ustar 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::MenuModel; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GMenuLinkIter")] pub struct MenuLinkIter(Object); match fn { type_ => || ffi::g_menu_link_iter_get_type(), } } pub const NONE_MENU_LINK_ITER: Option<&MenuLinkIter> = None; pub trait MenuLinkIterExt: 'static { #[doc(alias = "g_menu_link_iter_get_next")] #[doc(alias = "get_next")] fn next(&self) -> Option<(glib::GString, MenuModel)>; } impl> MenuLinkIterExt for O { fn next(&self) -> Option<(glib::GString, MenuModel)> { unsafe { let mut out_link = ptr::null(); let mut value = 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 fmt::Display for MenuLinkIter { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MenuLinkIter") } } gio-0.14.8/src/auto/menu_model.rs000064400000000000000000000125130072674642500147570ustar 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::MenuAttributeIter; use crate::MenuLinkIter; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GMenuModel")] pub struct MenuModel(Object); match fn { type_ => || ffi::g_menu_model_get_type(), } } pub const NONE_MENU_MODEL: Option<&MenuModel> = None; pub trait MenuModelExt: '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*/Fundamental: VarArgs) -> bool; #[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; #[doc(alias = "g_menu_model_get_item_link")] #[doc(alias = "get_item_link")] fn item_link(&self, item_index: i32, link: &str) -> Option; #[doc(alias = "g_menu_model_get_n_items")] #[doc(alias = "get_n_items")] fn n_items(&self) -> i32; #[doc(alias = "g_menu_model_is_mutable")] fn is_mutable(&self) -> bool; #[doc(alias = "g_menu_model_items_changed")] fn items_changed(&self, position: i32, removed: i32, added: i32); #[doc(alias = "g_menu_model_iterate_item_attributes")] fn iterate_item_attributes(&self, item_index: i32) -> MenuAttributeIter; #[doc(alias = "g_menu_model_iterate_item_links")] fn iterate_item_links(&self, item_index: i32) -> MenuLinkIter; #[doc(alias = "items-changed")] fn connect_items_changed(&self, f: F) -> SignalHandlerId; } impl> MenuModelExt for O { //fn is_item_attribute(&self, item_index: i32, attribute: &str, format_string: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi:g_menu_model_get_item_attribute() } //} 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, )) } } 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, )) } } fn n_items(&self) -> i32 { unsafe { ffi::g_menu_model_get_n_items(self.as_ref().to_glib_none().0) } } fn is_mutable(&self) -> bool { unsafe { from_glib(ffi::g_menu_model_is_mutable(self.as_ref().to_glib_none().0)) } } 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, ); } } 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, )) } } 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, )) } } 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(transmute::<_, unsafe extern "C" fn()>( items_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for MenuModel { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MenuModel") } } gio-0.14.8/src/auto/mod.rs000064400000000000000000000677020072674642500134240ustar 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, NONE_ACTION}; mod action_group; pub use self::action_group::{ActionGroup, NONE_ACTION_GROUP}; mod action_map; pub use self::action_map::{ActionMap, NONE_ACTION_MAP}; mod app_info; pub use self::app_info::{AppInfo, NONE_APP_INFO}; mod app_info_monitor; pub use self::app_info_monitor::AppInfoMonitor; mod app_launch_context; pub use self::app_launch_context::{AppLaunchContext, NONE_APP_LAUNCH_CONTEXT}; mod application; pub use self::application::ApplicationBuilder; pub use self::application::{Application, NONE_APPLICATION}; mod application_command_line; pub use self::application_command_line::{ApplicationCommandLine, NONE_APPLICATION_COMMAND_LINE}; mod async_result; pub use self::async_result::{AsyncResult, NONE_ASYNC_RESULT}; mod buffered_input_stream; pub use self::buffered_input_stream::BufferedInputStreamBuilder; pub use self::buffered_input_stream::{BufferedInputStream, NONE_BUFFERED_INPUT_STREAM}; mod buffered_output_stream; pub use self::buffered_output_stream::BufferedOutputStreamBuilder; pub use self::buffered_output_stream::{BufferedOutputStream, NONE_BUFFERED_OUTPUT_STREAM}; mod bytes_icon; pub use self::bytes_icon::BytesIcon; mod cancellable; pub use self::cancellable::{Cancellable, NONE_CANCELLABLE}; mod charset_converter; pub use self::charset_converter::CharsetConverter; pub use self::charset_converter::CharsetConverterBuilder; mod converter; pub use self::converter::{Converter, NONE_CONVERTER}; mod converter_input_stream; pub use self::converter_input_stream::ConverterInputStreamBuilder; pub use self::converter_input_stream::{ConverterInputStream, NONE_CONVERTER_INPUT_STREAM}; mod converter_output_stream; pub use self::converter_output_stream::ConverterOutputStreamBuilder; pub use self::converter_output_stream::{ConverterOutputStream, NONE_CONVERTER_OUTPUT_STREAM}; 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, NONE_DBUS_INTERFACE}; mod dbus_interface_skeleton; pub use self::dbus_interface_skeleton::{DBusInterfaceSkeleton, NONE_DBUS_INTERFACE_SKELETON}; 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, NONE_DBUS_OBJECT}; mod dbus_proxy; pub use self::dbus_proxy::{DBusProxy, NONE_DBUS_PROXY}; mod dbus_server; pub use self::dbus_server::DBusServer; mod data_input_stream; pub use self::data_input_stream::DataInputStreamBuilder; pub use self::data_input_stream::{DataInputStream, NONE_DATA_INPUT_STREAM}; mod data_output_stream; pub use self::data_output_stream::DataOutputStreamBuilder; pub use self::data_output_stream::{DataOutputStream, NONE_DATA_OUTPUT_STREAM}; #[cfg(any(all(not(windows), not(target_os = "macos")), feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(all(not(windows), not(target_os = "macos")))))] mod desktop_app_info; #[cfg(any(all(not(windows), not(target_os = "macos")), feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(all(not(windows), not(target_os = "macos")))))] pub use self::desktop_app_info::DesktopAppInfo; mod drive; pub use self::drive::{Drive, NONE_DRIVE}; mod emblem; pub use self::emblem::Emblem; mod emblemed_icon; pub use self::emblemed_icon::{EmblemedIcon, NONE_EMBLEMED_ICON}; mod file; pub use self::file::{File, NONE_FILE}; mod file_enumerator; pub use self::file_enumerator::{FileEnumerator, NONE_FILE_ENUMERATOR}; mod file_io_stream; pub use self::file_io_stream::{FileIOStream, NONE_FILE_IO_STREAM}; 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, NONE_FILE_INPUT_STREAM}; mod file_monitor; pub use self::file_monitor::{FileMonitor, NONE_FILE_MONITOR}; mod file_output_stream; pub use self::file_output_stream::{FileOutputStream, NONE_FILE_OUTPUT_STREAM}; mod filename_completer; pub use self::filename_completer::FilenameCompleter; mod filter_input_stream; pub use self::filter_input_stream::{FilterInputStream, NONE_FILTER_INPUT_STREAM}; mod filter_output_stream; pub use self::filter_output_stream::{FilterOutputStream, NONE_FILTER_OUTPUT_STREAM}; mod io_stream; pub use self::io_stream::{IOStream, NONE_IO_STREAM}; mod icon; pub use self::icon::{Icon, NONE_ICON}; mod inet_address; pub use self::inet_address::{InetAddress, NONE_INET_ADDRESS}; mod inet_address_mask; pub use self::inet_address_mask::{InetAddressMask, NONE_INET_ADDRESS_MASK}; mod inet_socket_address; pub use self::inet_socket_address::{InetSocketAddress, NONE_INET_SOCKET_ADDRESS}; mod initable; pub use self::initable::{Initable, NONE_INITABLE}; mod input_stream; pub use self::input_stream::{InputStream, NONE_INPUT_STREAM}; mod list_model; pub use self::list_model::{ListModel, NONE_LIST_MODEL}; mod list_store; pub use self::list_store::ListStore; pub use self::list_store::ListStoreBuilder; mod loadable_icon; pub use self::loadable_icon::{LoadableIcon, NONE_LOADABLE_ICON}; mod memory_input_stream; pub use self::memory_input_stream::{MemoryInputStream, NONE_MEMORY_INPUT_STREAM}; #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] mod memory_monitor; #[cfg(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_64")))] pub use self::memory_monitor::{MemoryMonitor, NONE_MEMORY_MONITOR}; mod memory_output_stream; pub use self::memory_output_stream::{MemoryOutputStream, NONE_MEMORY_OUTPUT_STREAM}; mod menu; pub use self::menu::Menu; mod menu_attribute_iter; pub use self::menu_attribute_iter::{MenuAttributeIter, NONE_MENU_ATTRIBUTE_ITER}; mod menu_item; pub use self::menu_item::MenuItem; mod menu_link_iter; pub use self::menu_link_iter::{MenuLinkIter, NONE_MENU_LINK_ITER}; mod menu_model; pub use self::menu_model::{MenuModel, NONE_MENU_MODEL}; mod mount; pub use self::mount::{Mount, NONE_MOUNT}; mod mount_operation; pub use self::mount_operation::{MountOperation, NONE_MOUNT_OPERATION}; mod network_address; pub use self::network_address::{NetworkAddress, NONE_NETWORK_ADDRESS}; mod network_monitor; pub use self::network_monitor::{NetworkMonitor, NONE_NETWORK_MONITOR}; mod network_service; pub use self::network_service::{NetworkService, NONE_NETWORK_SERVICE}; mod notification; pub use self::notification::Notification; mod output_stream; pub use self::output_stream::{OutputStream, NONE_OUTPUT_STREAM}; mod permission; pub use self::permission::{Permission, NONE_PERMISSION}; mod pollable_input_stream; pub use self::pollable_input_stream::{PollableInputStream, NONE_POLLABLE_INPUT_STREAM}; mod pollable_output_stream; pub use self::pollable_output_stream::{PollableOutputStream, NONE_POLLABLE_OUTPUT_STREAM}; mod property_action; pub use self::property_action::PropertyAction; mod proxy; pub use self::proxy::{Proxy, NONE_PROXY}; mod proxy_address; pub use self::proxy_address::{ProxyAddress, NONE_PROXY_ADDRESS}; mod proxy_resolver; pub use self::proxy_resolver::{ProxyResolver, NONE_PROXY_RESOLVER}; mod remote_action_group; pub use self::remote_action_group::{RemoteActionGroup, NONE_REMOTE_ACTION_GROUP}; mod resolver; pub use self::resolver::{Resolver, NONE_RESOLVER}; mod seekable; pub use self::seekable::{Seekable, NONE_SEEKABLE}; mod settings; pub use self::settings::{Settings, NONE_SETTINGS}; mod settings_backend; pub use self::settings_backend::{SettingsBackend, NONE_SETTINGS_BACKEND}; mod simple_action; pub use self::simple_action::SimpleAction; mod simple_action_group; pub use self::simple_action_group::{SimpleActionGroup, NONE_SIMPLE_ACTION_GROUP}; mod simple_io_stream; pub use self::simple_io_stream::SimpleIOStream; mod simple_permission; pub use self::simple_permission::SimplePermission; mod socket; pub use self::socket::{Socket, NONE_SOCKET}; mod socket_address; pub use self::socket_address::{SocketAddress, NONE_SOCKET_ADDRESS}; mod socket_address_enumerator; pub use self::socket_address_enumerator::{ SocketAddressEnumerator, NONE_SOCKET_ADDRESS_ENUMERATOR, }; mod socket_client; pub use self::socket_client::{SocketClient, NONE_SOCKET_CLIENT}; mod socket_connectable; pub use self::socket_connectable::{SocketConnectable, NONE_SOCKET_CONNECTABLE}; mod socket_connection; pub use self::socket_connection::{SocketConnection, NONE_SOCKET_CONNECTION}; mod socket_listener; pub use self::socket_listener::{SocketListener, NONE_SOCKET_LISTENER}; mod socket_service; pub use self::socket_service::{SocketService, NONE_SOCKET_SERVICE}; mod subprocess; pub use self::subprocess::Subprocess; mod subprocess_launcher; pub use self::subprocess_launcher::SubprocessLauncher; mod task; pub use self::task::Task; mod tcp_connection; pub use self::tcp_connection::{TcpConnection, NONE_TCP_CONNECTION}; mod themed_icon; pub use self::themed_icon::ThemedIcon; mod threaded_socket_service; pub use self::threaded_socket_service::{ThreadedSocketService, NONE_THREADED_SOCKET_SERVICE}; mod tls_backend; pub use self::tls_backend::{TlsBackend, NONE_TLS_BACKEND}; mod tls_certificate; pub use self::tls_certificate::{TlsCertificate, NONE_TLS_CERTIFICATE}; mod tls_client_connection; pub use self::tls_client_connection::{TlsClientConnection, NONE_TLS_CLIENT_CONNECTION}; mod tls_connection; pub use self::tls_connection::{TlsConnection, NONE_TLS_CONNECTION}; mod tls_database; pub use self::tls_database::{TlsDatabase, NONE_TLS_DATABASE}; mod tls_file_database; pub use self::tls_file_database::{TlsFileDatabase, NONE_TLS_FILE_DATABASE}; mod tls_interaction; pub use self::tls_interaction::{TlsInteraction, NONE_TLS_INTERACTION}; mod tls_password; pub use self::tls_password::{TlsPassword, NONE_TLS_PASSWORD}; mod tls_server_connection; pub use self::tls_server_connection::{TlsServerConnection, NONE_TLS_SERVER_CONNECTION}; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] mod unix_fd_list; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use self::unix_fd_list::{UnixFDList, NONE_UNIX_FD_LIST}; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] mod unix_input_stream; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use self::unix_input_stream::{UnixInputStream, NONE_UNIX_INPUT_STREAM}; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] mod unix_output_stream; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use self::unix_output_stream::{UnixOutputStream, NONE_UNIX_OUTPUT_STREAM}; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] mod unix_socket_address; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use self::unix_socket_address::{UnixSocketAddress, NONE_UNIX_SOCKET_ADDRESS}; mod vfs; pub use self::vfs::{Vfs, NONE_VFS}; mod volume; pub use self::volume::{Volume, NONE_VOLUME}; mod volume_monitor; pub use self::volume_monitor::{VolumeMonitor, NONE_VOLUME_MONITOR}; 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_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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_54", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] mod unix_mount_entry; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_54", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] pub use self::unix_mount_entry::UnixMountEntry; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_54", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] mod unix_mount_point; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[cfg(any(feature = "v2_54", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_54")))] 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", 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; 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(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] pub use self::enums::TlsChannelBindingType; pub use self::enums::TlsDatabaseLookupFlags; pub use self::enums::TlsInteractionResult; pub use self::enums::TlsRehandshakeMode; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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::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::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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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 mod functions; mod constants; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] pub use self::constants::FILE_ATTRIBUTE_DOS_IS_MOUNTPOINT; pub use self::constants::FILE_ATTRIBUTE_DOS_IS_SYSTEM; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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; #[cfg(any(feature = "v2_52", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_52")))] 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; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_IS_VALID; pub use self::constants::FILE_ATTRIBUTE_THUMBNAIL_PATH; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS; pub use self::constants::FILE_ATTRIBUTE_TIME_ACCESS_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED; pub use self::constants::FILE_ATTRIBUTE_TIME_CHANGED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED; pub use self::constants::FILE_ATTRIBUTE_TIME_CREATED_USEC; pub use self::constants::FILE_ATTRIBUTE_TIME_MODIFIED; 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", 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; 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; 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; #[doc(hidden)] pub 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_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::dbus_interface::DBusInterfaceExt; pub use super::dbus_interface_skeleton::DBusInterfaceSkeletonExt; pub use super::dbus_object::DBusObjectExt; pub use super::dbus_proxy::DBusProxyExt; 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(any(feature = "v2_64", feature = "dox"))] #[cfg_attr(feature = "dox", 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; 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::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_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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use super::unix_fd_list::UnixFDListExt; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use super::unix_input_stream::UnixInputStreamExt; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] pub use super::unix_output_stream::UnixOutputStreamExt; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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; } gio-0.14.8/src/auto/mount.rs000064400000000000000000000452040072674642500140000ustar 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::AsyncResult; use crate::Cancellable; use crate::Drive; use crate::File; use crate::Icon; use crate::MountMountFlags; use crate::MountOperation; use crate::MountUnmountFlags; use crate::Volume; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GMount")] pub struct Mount(Interface); match fn { type_ => || ffi::g_mount_get_type(), } } pub const NONE_MOUNT: Option<&Mount> = None; pub trait MountExt: 'static { #[doc(alias = "g_mount_can_eject")] fn can_eject(&self) -> bool; #[doc(alias = "g_mount_can_unmount")] fn can_unmount(&self) -> bool; #[doc(alias = "g_mount_eject_with_operation")] fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_mount_get_default_location")] #[doc(alias = "get_default_location")] fn default_location(&self) -> File; #[doc(alias = "g_mount_get_drive")] #[doc(alias = "get_drive")] fn drive(&self) -> Option; #[doc(alias = "g_mount_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon; #[doc(alias = "g_mount_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_mount_get_root")] #[doc(alias = "get_root")] fn root(&self) -> File; #[doc(alias = "g_mount_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option; #[doc(alias = "g_mount_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon; #[doc(alias = "g_mount_get_uuid")] #[doc(alias = "get_uuid")] fn uuid(&self) -> Option; #[doc(alias = "g_mount_get_volume")] #[doc(alias = "get_volume")] fn volume(&self) -> Option; #[doc(alias = "g_mount_guess_content_type")] fn guess_content_type< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, force_rescan: bool, cancellable: Option<&P>, callback: Q, ); fn guess_content_type_future( &self, force_rescan: bool, ) -> Pin< Box_, glib::Error>> + 'static>, >; #[doc(alias = "g_mount_guess_content_type_sync")] fn guess_content_type_sync>( &self, force_rescan: bool, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_mount_is_shadowed")] fn is_shadowed(&self) -> bool; #[doc(alias = "g_mount_remount")] fn remount< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn remount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_mount_shadow")] fn shadow(&self); #[doc(alias = "g_mount_unmount_with_operation")] fn unmount_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn unmount_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_mount_unshadow")] fn unshadow(&self); #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "pre-unmount")] fn connect_pre_unmount(&self, f: F) -> SignalHandlerId; #[doc(alias = "unmounted")] fn connect_unmounted(&self, f: F) -> SignalHandlerId; } impl> MountExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_mount_can_eject(self.as_ref().to_glib_none().0)) } } fn can_unmount(&self) -> bool { unsafe { from_glib(ffi::g_mount_can_unmount(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn default_location(&self) -> File { unsafe { from_glib_full(ffi::g_mount_get_default_location( self.as_ref().to_glib_none().0, )) } } fn drive(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_drive(self.as_ref().to_glib_none().0)) } } fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_mount_get_icon(self.as_ref().to_glib_none().0)) } } fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_mount_get_name(self.as_ref().to_glib_none().0)) } } fn root(&self) -> File { unsafe { from_glib_full(ffi::g_mount_get_root(self.as_ref().to_glib_none().0)) } } fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_get_sort_key(self.as_ref().to_glib_none().0)) } } fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_mount_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn uuid(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_uuid(self.as_ref().to_glib_none().0)) } } fn volume(&self) -> Option { unsafe { from_glib_full(ffi::g_mount_get_volume(self.as_ref().to_glib_none().0)) } } fn guess_content_type< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, force_rescan: bool, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn guess_content_type_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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); }); }, )) } fn guess_content_type_sync>( &self, force_rescan: bool, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn is_shadowed(&self) -> bool { unsafe { from_glib(ffi::g_mount_is_shadowed(self.as_ref().to_glib_none().0)) } } fn remount< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn remount_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn shadow(&self) { unsafe { ffi::g_mount_shadow(self.as_ref().to_glib_none().0); } } fn unmount_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn unmount_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn unshadow(&self) { unsafe { ffi::g_mount_unshadow(self.as_ref().to_glib_none().0); } } 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( pre_unmount_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( unmounted_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Mount { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Mount") } } gio-0.14.8/src/auto/mount_operation.rs000064400000000000000000000575210072674642500160650ustar 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::AskPasswordFlags; use crate::MountOperationResult; use crate::PasswordSave; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GMountOperation")] pub struct MountOperation(Object); match fn { type_ => || ffi::g_mount_operation_get_type(), } } impl MountOperation { #[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() } } pub const NONE_MOUNT_OPERATION: Option<&MountOperation> = None; pub trait MountOperationExt: 'static { #[doc(alias = "g_mount_operation_get_anonymous")] #[doc(alias = "get_anonymous")] fn is_anonymous(&self) -> bool; #[doc(alias = "g_mount_operation_get_choice")] #[doc(alias = "get_choice")] fn choice(&self) -> i32; #[doc(alias = "g_mount_operation_get_domain")] #[doc(alias = "get_domain")] fn domain(&self) -> Option; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_is_tcrypt_hidden_volume")] #[doc(alias = "get_is_tcrypt_hidden_volume")] fn is_tcrypt_hidden_volume(&self) -> bool; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_is_tcrypt_system_volume")] #[doc(alias = "get_is_tcrypt_system_volume")] fn is_tcrypt_system_volume(&self) -> bool; #[doc(alias = "g_mount_operation_get_password")] #[doc(alias = "get_password")] fn password(&self) -> Option; #[doc(alias = "g_mount_operation_get_password_save")] #[doc(alias = "get_password_save")] fn password_save(&self) -> PasswordSave; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_get_pim")] #[doc(alias = "get_pim")] fn pim(&self) -> u32; #[doc(alias = "g_mount_operation_get_username")] #[doc(alias = "get_username")] fn username(&self) -> Option; #[doc(alias = "g_mount_operation_reply")] fn reply(&self, result: MountOperationResult); #[doc(alias = "g_mount_operation_set_anonymous")] fn set_anonymous(&self, anonymous: bool); #[doc(alias = "g_mount_operation_set_choice")] fn set_choice(&self, choice: i32); #[doc(alias = "g_mount_operation_set_domain")] fn set_domain(&self, domain: Option<&str>); #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_is_tcrypt_hidden_volume")] fn set_is_tcrypt_hidden_volume(&self, hidden_volume: bool); #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_is_tcrypt_system_volume")] fn set_is_tcrypt_system_volume(&self, system_volume: bool); #[doc(alias = "g_mount_operation_set_password")] fn set_password(&self, password: Option<&str>); #[doc(alias = "g_mount_operation_set_password_save")] fn set_password_save(&self, save: PasswordSave); #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "g_mount_operation_set_pim")] fn set_pim(&self, pim: u32); #[doc(alias = "g_mount_operation_set_username")] fn set_username(&self, username: Option<&str>); #[doc(alias = "aborted")] fn connect_aborted(&self, f: F) -> SignalHandlerId; #[doc(alias = "ask-password")] fn connect_ask_password( &self, f: F, ) -> SignalHandlerId; //#[doc(alias = "ask-question")] //fn connect_ask_question(&self, f: F) -> SignalHandlerId; #[doc(alias = "reply")] fn connect_reply(&self, f: F) -> SignalHandlerId; //#[doc(alias = "show-processes")] //fn connect_show_processes(&self, f: F) -> SignalHandlerId; #[doc(alias = "show-unmount-progress")] fn connect_show_unmount_progress( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "anonymous")] fn connect_anonymous_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "choice")] fn connect_choice_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "domain")] fn connect_domain_notify(&self, f: F) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "is-tcrypt-hidden-volume")] fn connect_is_tcrypt_hidden_volume_notify( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "is-tcrypt-system-volume")] fn connect_is_tcrypt_system_volume_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "password")] fn connect_password_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "password-save")] fn connect_password_save_notify(&self, f: F) -> SignalHandlerId; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] #[doc(alias = "pim")] fn connect_pim_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "username")] fn connect_username_notify(&self, f: F) -> SignalHandlerId; } impl> MountOperationExt for O { fn is_anonymous(&self) -> bool { unsafe { from_glib(ffi::g_mount_operation_get_anonymous( self.as_ref().to_glib_none().0, )) } } fn choice(&self) -> i32 { unsafe { ffi::g_mount_operation_get_choice(self.as_ref().to_glib_none().0) } } fn domain(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_domain( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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, )) } } fn password(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_password( self.as_ref().to_glib_none().0, )) } } fn password_save(&self) -> PasswordSave { unsafe { from_glib(ffi::g_mount_operation_get_password_save( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] fn pim(&self) -> u32 { unsafe { ffi::g_mount_operation_get_pim(self.as_ref().to_glib_none().0) } } fn username(&self) -> Option { unsafe { from_glib_none(ffi::g_mount_operation_get_username( self.as_ref().to_glib_none().0, )) } } fn reply(&self, result: MountOperationResult) { unsafe { ffi::g_mount_operation_reply(self.as_ref().to_glib_none().0, result.into_glib()); } } fn set_anonymous(&self, anonymous: bool) { unsafe { ffi::g_mount_operation_set_anonymous( self.as_ref().to_glib_none().0, anonymous.into_glib(), ); } } fn set_choice(&self, choice: i32) { unsafe { ffi::g_mount_operation_set_choice(self.as_ref().to_glib_none().0, choice); } } 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(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(), ); } } 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, ); } } 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(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] fn set_pim(&self, pim: u32) { unsafe { ffi::g_mount_operation_set_pim(self.as_ref().to_glib_none().0, pim); } } 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, ); } } 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(transmute::<_, unsafe extern "C" fn()>( aborted_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( ask_password_trampoline:: as *const (), )), Box_::into_raw(f), ) } } //fn connect_ask_question(&self, f: F) -> SignalHandlerId { // Empty ctype choices: *.CArray TypeId { ns_id: 0, id: 28 } //} 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(transmute::<_, unsafe extern "C" fn()>( reply_trampoline:: as *const (), )), Box_::into_raw(f), ) } } //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 } //} 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(transmute::<_, unsafe extern "C" fn()>( show_unmount_progress_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_anonymous_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_choice_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_domain_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(transmute::<_, unsafe extern "C" fn()>( notify_is_tcrypt_hidden_volume_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(transmute::<_, unsafe extern "C" fn()>( notify_is_tcrypt_system_volume_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_password_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_password_save_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_58")))] 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(transmute::<_, unsafe extern "C" fn()>( notify_pim_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_username_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for MountOperation { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("MountOperation") } } gio-0.14.8/src/auto/network_address.rs000064400000000000000000000062540072674642500160360ustar 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::SocketConnectable; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GNetworkAddress")] pub struct NetworkAddress(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_network_address_get_type(), } } impl NetworkAddress { #[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 = 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 = 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 {} pub const NONE_NETWORK_ADDRESS: Option<&NetworkAddress> = None; pub trait NetworkAddressExt: 'static { #[doc(alias = "g_network_address_get_hostname")] #[doc(alias = "get_hostname")] fn hostname(&self) -> glib::GString; #[doc(alias = "g_network_address_get_port")] #[doc(alias = "get_port")] fn port(&self) -> u16; #[doc(alias = "g_network_address_get_scheme")] #[doc(alias = "get_scheme")] fn scheme(&self) -> Option; } impl> NetworkAddressExt for O { fn hostname(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_address_get_hostname( self.as_ref().to_glib_none().0, )) } } fn port(&self) -> u16 { unsafe { ffi::g_network_address_get_port(self.as_ref().to_glib_none().0) } } fn scheme(&self) -> Option { unsafe { from_glib_none(ffi::g_network_address_get_scheme( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for NetworkAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("NetworkAddress") } } gio-0.14.8/src/auto/network_monitor.rs000064400000000000000000000234530072674642500161000ustar 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::AsyncResult; use crate::Cancellable; use crate::Initable; use crate::NetworkConnectivity; use crate::SocketConnectable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GNetworkMonitor")] pub struct NetworkMonitor(Interface) @requires Initable; match fn { type_ => || ffi::g_network_monitor_get_type(), } } impl NetworkMonitor { #[doc(alias = "g_network_monitor_get_default")] #[doc(alias = "get_default")] pub fn default() -> NetworkMonitor { unsafe { from_glib_none(ffi::g_network_monitor_get_default()) } } } pub const NONE_NETWORK_MONITOR: Option<&NetworkMonitor> = None; pub trait NetworkMonitorExt: 'static { #[doc(alias = "g_network_monitor_can_reach")] fn can_reach, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_network_monitor_can_reach_async")] fn can_reach_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ); fn can_reach_async_future + Clone + 'static>( &self, connectable: &P, ) -> Pin> + 'static>>; #[doc(alias = "g_network_monitor_get_connectivity")] #[doc(alias = "get_connectivity")] fn connectivity(&self) -> NetworkConnectivity; #[doc(alias = "g_network_monitor_get_network_available")] #[doc(alias = "get_network_available")] fn is_network_available(&self) -> bool; #[doc(alias = "g_network_monitor_get_network_metered")] #[doc(alias = "get_network_metered")] fn is_network_metered(&self) -> bool; #[doc(alias = "network-changed")] fn connect_network_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "connectivity")] fn connect_connectivity_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "network-available")] fn connect_network_available_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "network-metered")] fn connect_network_metered_notify(&self, f: F) -> SignalHandlerId; } impl> NetworkMonitorExt for O { fn can_reach, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn can_reach_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn can_reach_async_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, connectable: &P, ) -> 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); }); }, )) } fn connectivity(&self) -> NetworkConnectivity { unsafe { from_glib(ffi::g_network_monitor_get_connectivity( self.as_ref().to_glib_none().0, )) } } fn is_network_available(&self) -> bool { unsafe { from_glib(ffi::g_network_monitor_get_network_available( self.as_ref().to_glib_none().0, )) } } fn is_network_metered(&self) -> bool { unsafe { from_glib(ffi::g_network_monitor_get_network_metered( self.as_ref().to_glib_none().0, )) } } 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(transmute::<_, unsafe extern "C" fn()>( network_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_connectivity_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_network_available_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_network_metered_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for NetworkMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("NetworkMonitor") } } gio-0.14.8/src/auto/network_service.rs000064400000000000000000000075440072674642500160540ustar 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::SocketConnectable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GNetworkService")] pub struct NetworkService(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_network_service_get_type(), } } impl NetworkService { #[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, )) } } } pub const NONE_NETWORK_SERVICE: Option<&NetworkService> = None; pub trait NetworkServiceExt: 'static { #[doc(alias = "g_network_service_get_domain")] #[doc(alias = "get_domain")] fn domain(&self) -> glib::GString; #[doc(alias = "g_network_service_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> glib::GString; #[doc(alias = "g_network_service_get_scheme")] #[doc(alias = "get_scheme")] fn scheme(&self) -> glib::GString; #[doc(alias = "g_network_service_get_service")] #[doc(alias = "get_service")] fn service(&self) -> glib::GString; #[doc(alias = "g_network_service_set_scheme")] fn set_scheme(&self, scheme: &str); #[doc(alias = "scheme")] fn connect_scheme_notify(&self, f: F) -> SignalHandlerId; } impl> NetworkServiceExt for O { fn domain(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_domain( self.as_ref().to_glib_none().0, )) } } fn protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_protocol( self.as_ref().to_glib_none().0, )) } } fn scheme(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_scheme( self.as_ref().to_glib_none().0, )) } } fn service(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_network_service_get_service( self.as_ref().to_glib_none().0, )) } } 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, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_scheme_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for NetworkService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("NetworkService") } } gio-0.14.8/src/auto/notification.rs000064400000000000000000000074520072674642500153270ustar 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::Icon; use crate::NotificationPriority; use glib::object::IsA; use glib::translate::*; use std::fmt; 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*/Fundamental: 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); } } #[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*/Fundamental: 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: &P) { 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); } } } impl fmt::Display for Notification { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Notification") } } gio-0.14.8/src/auto/output_stream.rs000064400000000000000000000527000072674642500155500ustar 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::AsyncResult; use crate::Cancellable; use crate::InputStream; use crate::OutputStreamSpliceFlags; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GOutputStream")] pub struct OutputStream(Object); match fn { type_ => || ffi::g_output_stream_get_type(), } } pub const NONE_OUTPUT_STREAM: Option<&OutputStream> = None; pub trait OutputStreamExt: 'static { #[doc(alias = "g_output_stream_clear_pending")] fn clear_pending(&self); #[doc(alias = "g_output_stream_close")] fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_output_stream_close_async")] fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn close_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_output_stream_flush")] fn flush>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_output_stream_flush_async")] fn flush_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn flush_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[doc(alias = "g_output_stream_has_pending")] fn has_pending(&self) -> bool; #[doc(alias = "g_output_stream_is_closed")] fn is_closed(&self) -> bool; #[doc(alias = "g_output_stream_is_closing")] fn is_closing(&self) -> bool; //#[doc(alias = "g_output_stream_printf")] //fn printf>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option; #[doc(alias = "g_output_stream_set_pending")] fn set_pending(&self) -> Result<(), glib::Error>; #[doc(alias = "g_output_stream_splice")] fn splice, Q: IsA>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_output_stream_splice_async")] fn splice_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, ); fn splice_async_future + Clone + 'static>( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; //#[doc(alias = "g_output_stream_vprintf")] //fn vprintf>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option; #[doc(alias = "g_output_stream_write")] fn write>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_output_stream_write_bytes")] fn write_bytes>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_output_stream_write_bytes_async")] fn write_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn write_bytes_async_future( &self, bytes: &glib::Bytes, io_priority: glib::Priority, ) -> Pin> + 'static>>; //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //#[doc(alias = "g_output_stream_writev")] //fn writev>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result; //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //#[doc(alias = "g_output_stream_writev_all")] //fn writev_all>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result; //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //#[doc(alias = "g_output_stream_writev_all_async")] //fn writev_all_async, Q: FnOnce(Result) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q); // //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_all_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin> + 'static>>; //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //#[doc(alias = "g_output_stream_writev_async")] //fn writev_async, Q: FnOnce(Result) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q); // //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin> + 'static>>; } impl> OutputStreamExt for O { fn clear_pending(&self) { unsafe { ffi::g_output_stream_clear_pending(self.as_ref().to_glib_none().0); } } fn close>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_output_stream_close( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn close_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn flush>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_output_stream_flush( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn flush_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn flush_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn has_pending(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_has_pending( self.as_ref().to_glib_none().0, )) } } fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_is_closed( self.as_ref().to_glib_none().0, )) } } fn is_closing(&self) -> bool { unsafe { from_glib(ffi::g_output_stream_is_closing( self.as_ref().to_glib_none().0, )) } } //fn printf>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> Option { // unsafe { TODO: call ffi:g_output_stream_printf() } //} fn set_pending(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_output_stream_set_pending(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn splice, Q: IsA>( &self, source: &P, flags: OutputStreamSpliceFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn splice_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, source: &P, flags: OutputStreamSpliceFlags, io_priority: glib::Priority, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn splice_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, source: &P, 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); }); }, )) } //fn vprintf>(&self, cancellable: Option<&P>, error: &mut glib::Error, format: &str, args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option { // unsafe { TODO: call ffi:g_output_stream_vprintf() } //} fn write>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result { let count = buffer.len() as usize; unsafe { let mut error = 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)) } } } fn write_bytes>( &self, bytes: &glib::Bytes, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn write_bytes_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, bytes: &glib::Bytes, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn write_bytes_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result { // unsafe { TODO: call ffi:g_output_stream_writev() } //} //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_all>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result { // unsafe { TODO: call ffi:g_output_stream_writev_all() } //} //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_all_async, Q: FnOnce(Result) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q) { // unsafe { TODO: call ffi:g_output_stream_writev_all_async() } //} // //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_all_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin> + 'static>> { //let vectors = vectors.clone(); //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { // obj.writev_all_async( // &vectors, // io_priority, // Some(cancellable), // move |res| { // send.resolve(res); // }, // ); //})) //} //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_async, Q: FnOnce(Result) + Send + 'static>(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q) { // unsafe { TODO: call ffi:g_output_stream_writev_async() } //} // //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_async_future(&self, vectors: /*Ignored*/&[&OutputVector], io_priority: glib::Priority) -> Pin> + 'static>> { //let vectors = vectors.clone(); //Box_::pin(crate::GioFuture::new(self, move |obj, cancellable, send| { // obj.writev_async( // &vectors, // io_priority, // Some(cancellable), // move |res| { // send.resolve(res); // }, // ); //})) //} } impl fmt::Display for OutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("OutputStream") } } gio-0.14.8/src/auto/permission.rs000064400000000000000000000246500072674642500150300ustar 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::AsyncResult; use crate::Cancellable; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GPermission")] pub struct Permission(Object); match fn { type_ => || ffi::g_permission_get_type(), } } pub const NONE_PERMISSION: Option<&Permission> = None; pub trait PermissionExt: 'static { #[doc(alias = "g_permission_acquire")] fn acquire>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_permission_acquire_async")] fn acquire_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); fn acquire_async_future( &self, ) -> Pin> + 'static>>; #[doc(alias = "g_permission_get_allowed")] #[doc(alias = "get_allowed")] fn is_allowed(&self) -> bool; #[doc(alias = "g_permission_get_can_acquire")] #[doc(alias = "get_can_acquire")] fn can_acquire(&self) -> bool; #[doc(alias = "g_permission_get_can_release")] #[doc(alias = "get_can_release")] fn can_release(&self) -> bool; #[doc(alias = "g_permission_impl_update")] fn impl_update(&self, allowed: bool, can_acquire: bool, can_release: bool); #[doc(alias = "g_permission_release")] fn release>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_permission_release_async")] fn release_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ); fn release_async_future( &self, ) -> Pin> + 'static>>; #[doc(alias = "allowed")] fn connect_allowed_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "can-acquire")] fn connect_can_acquire_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "can-release")] fn connect_can_release_notify(&self, f: F) -> SignalHandlerId; } impl> PermissionExt for O { fn acquire>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_permission_acquire( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn acquire_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn acquire_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.acquire_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } fn is_allowed(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_allowed( self.as_ref().to_glib_none().0, )) } } fn can_acquire(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_can_acquire( self.as_ref().to_glib_none().0, )) } } fn can_release(&self) -> bool { unsafe { from_glib(ffi::g_permission_get_can_release( self.as_ref().to_glib_none().0, )) } } 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(), ); } } fn release>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_permission_release( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn release_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn release_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.release_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } 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(transmute::<_, unsafe extern "C" fn()>( notify_allowed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_can_acquire_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_can_release_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Permission { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Permission") } } gio-0.14.8/src/auto/pollable_input_stream.rs000064400000000000000000000026070072674642500172220ustar 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::InputStream; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GPollableInputStream")] pub struct PollableInputStream(Interface) @requires InputStream; match fn { type_ => || ffi::g_pollable_input_stream_get_type(), } } pub const NONE_POLLABLE_INPUT_STREAM: Option<&PollableInputStream> = None; pub trait PollableInputStreamExt: 'static { #[doc(alias = "g_pollable_input_stream_can_poll")] fn can_poll(&self) -> bool; #[doc(alias = "g_pollable_input_stream_is_readable")] fn is_readable(&self) -> bool; } impl> PollableInputStreamExt for O { fn can_poll(&self) -> bool { unsafe { from_glib(ffi::g_pollable_input_stream_can_poll( self.as_ref().to_glib_none().0, )) } } fn is_readable(&self) -> bool { unsafe { from_glib(ffi::g_pollable_input_stream_is_readable( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for PollableInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("PollableInputStream") } } gio-0.14.8/src/auto/pollable_output_stream.rs000064400000000000000000000061200072674642500174150ustar 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::Cancellable; use crate::OutputStream; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GPollableOutputStream")] pub struct PollableOutputStream(Interface) @requires OutputStream; match fn { type_ => || ffi::g_pollable_output_stream_get_type(), } } pub const NONE_POLLABLE_OUTPUT_STREAM: Option<&PollableOutputStream> = None; pub trait PollableOutputStreamExt: 'static { #[doc(alias = "g_pollable_output_stream_can_poll")] fn can_poll(&self) -> bool; #[doc(alias = "g_pollable_output_stream_is_writable")] fn is_writable(&self) -> bool; #[doc(alias = "g_pollable_output_stream_write_nonblocking")] fn write_nonblocking>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result; //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //#[doc(alias = "g_pollable_output_stream_writev_nonblocking")] //fn writev_nonblocking>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<(/*Ignored*/PollableReturn, usize), glib::Error>; } impl> PollableOutputStreamExt for O { fn can_poll(&self) -> bool { unsafe { from_glib(ffi::g_pollable_output_stream_can_poll( self.as_ref().to_glib_none().0, )) } } fn is_writable(&self) -> bool { unsafe { from_glib(ffi::g_pollable_output_stream_is_writable( self.as_ref().to_glib_none().0, )) } } fn write_nonblocking>( &self, buffer: &[u8], cancellable: Option<&P>, ) -> Result { let count = buffer.len() as usize; unsafe { let mut error = 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)) } } } //#[cfg(any(feature = "v2_60", feature = "dox"))] //#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] //fn writev_nonblocking>(&self, vectors: /*Ignored*/&[&OutputVector], cancellable: Option<&P>) -> Result<(/*Ignored*/PollableReturn, usize), glib::Error> { // unsafe { TODO: call ffi:g_pollable_output_stream_writev_nonblocking() } //} } impl fmt::Display for PollableOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("PollableOutputStream") } } gio-0.14.8/src/auto/property_action.rs000064400000000000000000000120560072674642500160560ustar 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::Action; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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: &P, 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"invert-boolean\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `invert-boolean` getter") } } #[doc(alias = "enabled")] pub fn connect_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline( this: *mut ffi::GPropertyAction, _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::enabled\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "parameter-type")] pub fn connect_parameter_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_parameter_type_trampoline( this: *mut ffi::GPropertyAction, _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::parameter-type\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_parameter_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state")] pub fn connect_state_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_trampoline( this: *mut ffi::GPropertyAction, _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::state\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state-type")] pub fn connect_state_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline( this: *mut ffi::GPropertyAction, _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::state-type\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_state_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for PropertyAction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("PropertyAction") } } gio-0.14.8/src/auto/proxy.rs000064400000000000000000000122340072674642500140140ustar 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::AsyncResult; use crate::Cancellable; use crate::IOStream; use crate::ProxyAddress; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GProxy")] pub struct Proxy(Interface); match fn { type_ => || ffi::g_proxy_get_type(), } } impl Proxy { #[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, )) } } } pub const NONE_PROXY: Option<&Proxy> = None; pub trait ProxyExt: 'static { #[doc(alias = "g_proxy_connect")] fn connect, Q: IsA, R: IsA>( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, ) -> Result; #[doc(alias = "g_proxy_connect_async")] fn connect_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, callback: S, ); fn connect_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, connection: &P, proxy_address: &Q, ) -> Pin> + 'static>>; #[doc(alias = "g_proxy_supports_hostname")] fn supports_hostname(&self) -> bool; } impl> ProxyExt for O { fn connect, Q: IsA, R: IsA>( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, ) -> Result { unsafe { let mut error = 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)) } } } fn connect_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, connection: &P, proxy_address: &Q, cancellable: Option<&R>, callback: S, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_async_trampoline< S: FnOnce(Result) + Send + '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_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 _); 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_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, connection: &P, proxy_address: &Q, ) -> 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); }); }, )) } fn supports_hostname(&self) -> bool { unsafe { from_glib(ffi::g_proxy_supports_hostname( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for Proxy { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Proxy") } } gio-0.14.8/src/auto/proxy_address.rs000064400000000000000000000077410072674642500155300ustar 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::InetAddress; use crate::InetSocketAddress; use crate::SocketAddress; use crate::SocketConnectable; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; 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 { #[doc(alias = "g_proxy_address_new")] pub fn new>( inetaddr: &P, 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 {} pub const NONE_PROXY_ADDRESS: Option<&ProxyAddress> = None; pub trait ProxyAddressExt: 'static { #[doc(alias = "g_proxy_address_get_destination_hostname")] #[doc(alias = "get_destination_hostname")] fn destination_hostname(&self) -> glib::GString; #[doc(alias = "g_proxy_address_get_destination_port")] #[doc(alias = "get_destination_port")] fn destination_port(&self) -> u16; #[doc(alias = "g_proxy_address_get_destination_protocol")] #[doc(alias = "get_destination_protocol")] fn destination_protocol(&self) -> glib::GString; #[doc(alias = "g_proxy_address_get_password")] #[doc(alias = "get_password")] fn password(&self) -> Option; #[doc(alias = "g_proxy_address_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> glib::GString; #[doc(alias = "g_proxy_address_get_uri")] #[doc(alias = "get_uri")] fn uri(&self) -> Option; #[doc(alias = "g_proxy_address_get_username")] #[doc(alias = "get_username")] fn username(&self) -> Option; } impl> ProxyAddressExt for O { fn destination_hostname(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_destination_hostname( self.as_ref().to_glib_none().0, )) } } fn destination_port(&self) -> u16 { unsafe { ffi::g_proxy_address_get_destination_port(self.as_ref().to_glib_none().0) } } fn destination_protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_destination_protocol( self.as_ref().to_glib_none().0, )) } } fn password(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_password( self.as_ref().to_glib_none().0, )) } } fn protocol(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_proxy_address_get_protocol( self.as_ref().to_glib_none().0, )) } } fn uri(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_uri(self.as_ref().to_glib_none().0)) } } fn username(&self) -> Option { unsafe { from_glib_none(ffi::g_proxy_address_get_username( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for ProxyAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ProxyAddress") } } gio-0.14.8/src/auto/proxy_resolver.rs000064400000000000000000000107570072674642500157450ustar 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::AsyncResult; use crate::Cancellable; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GProxyResolver")] pub struct ProxyResolver(Interface); match fn { type_ => || ffi::g_proxy_resolver_get_type(), } } impl ProxyResolver { #[doc(alias = "g_proxy_resolver_get_default")] #[doc(alias = "get_default")] pub fn default() -> ProxyResolver { unsafe { from_glib_none(ffi::g_proxy_resolver_get_default()) } } } pub const NONE_PROXY_RESOLVER: Option<&ProxyResolver> = None; pub trait ProxyResolverExt: 'static { #[doc(alias = "g_proxy_resolver_is_supported")] fn is_supported(&self) -> bool; #[doc(alias = "g_proxy_resolver_lookup")] fn lookup>( &self, uri: &str, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_proxy_resolver_lookup_async")] fn lookup_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, uri: &str, cancellable: Option<&P>, callback: Q, ); fn lookup_async_future( &self, uri: &str, ) -> Pin< Box_, glib::Error>> + 'static>, >; } impl> ProxyResolverExt for O { fn is_supported(&self) -> bool { unsafe { from_glib(ffi::g_proxy_resolver_is_supported( self.as_ref().to_glib_none().0, )) } } fn lookup>( &self, uri: &str, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, uri: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_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 fmt::Display for ProxyResolver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ProxyResolver") } } gio-0.14.8/src/auto/remote_action_group.rs000064400000000000000000000041770072674642500167060ustar 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::ActionGroup; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GRemoteActionGroup")] pub struct RemoteActionGroup(Interface) @requires ActionGroup; match fn { type_ => || ffi::g_remote_action_group_get_type(), } } pub const NONE_REMOTE_ACTION_GROUP: Option<&RemoteActionGroup> = None; pub trait RemoteActionGroupExt: '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, ); #[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, ); } impl> RemoteActionGroupExt for O { 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, ); } } 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 fmt::Display for RemoteActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("RemoteActionGroup") } } gio-0.14.8/src/auto/resolver.rs000064400000000000000000000527400072674642500145020ustar 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::AsyncResult; use crate::Cancellable; use crate::InetAddress; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] use crate::ResolverNameLookupFlags; use crate::ResolverRecordType; use crate::SrvTarget; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GResolver")] pub struct Resolver(Object); match fn { type_ => || ffi::g_resolver_get_type(), } } impl Resolver { //#[doc(alias = "g_resolver_free_addresses")] //pub fn free_addresses(addresses: /*Unimplemented*/&[&Fundamental: Pointer]) { // unsafe { TODO: call ffi:g_resolver_free_addresses() } //} //#[doc(alias = "g_resolver_free_targets")] //pub fn free_targets(targets: /*Unimplemented*/&[&Fundamental: Pointer]) { // unsafe { TODO: call ffi:g_resolver_free_targets() } //} #[doc(alias = "g_resolver_get_default")] #[doc(alias = "get_default")] pub fn default() -> Resolver { unsafe { from_glib_full(ffi::g_resolver_get_default()) } } } pub const NONE_RESOLVER: Option<&Resolver> = None; pub trait ResolverExt: 'static { #[doc(alias = "g_resolver_lookup_by_address")] fn lookup_by_address, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_resolver_lookup_by_address_async")] fn lookup_by_address_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ); fn lookup_by_address_async_future + Clone + 'static>( &self, address: &P, ) -> Pin> + 'static>>; #[doc(alias = "g_resolver_lookup_by_name")] fn lookup_by_name>( &self, hostname: &str, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_resolver_lookup_by_name_async")] fn lookup_by_name_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, hostname: &str, cancellable: Option<&P>, callback: Q, ); fn lookup_by_name_async_future( &self, hostname: &str, ) -> Pin, glib::Error>> + 'static>>; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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<&P>, ) -> Result, glib::Error>; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "g_resolver_lookup_by_name_with_flags_async")] fn lookup_by_name_with_flags_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&P>, callback: Q, ); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn lookup_by_name_with_flags_async_future( &self, hostname: &str, flags: ResolverNameLookupFlags, ) -> Pin, glib::Error>> + 'static>>; #[doc(alias = "g_resolver_lookup_records")] fn lookup_records>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_resolver_lookup_records_async")] fn lookup_records_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, callback: Q, ); fn lookup_records_async_future( &self, rrname: &str, record_type: ResolverRecordType, ) -> Pin< Box_, glib::Error>> + 'static>, >; #[doc(alias = "g_resolver_lookup_service")] fn lookup_service>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_resolver_lookup_service_async")] fn lookup_service_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, callback: Q, ); fn lookup_service_async_future( &self, service: &str, protocol: &str, domain: &str, ) -> Pin, glib::Error>> + 'static>>; #[doc(alias = "g_resolver_set_default")] fn set_default(&self); #[doc(alias = "reload")] fn connect_reload(&self, f: F) -> SignalHandlerId; } impl> ResolverExt for O { fn lookup_by_address, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn lookup_by_address_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_by_address_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, address: &P, ) -> 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); }); }, )) } fn lookup_by_name>( &self, hostname: &str, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_by_name_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, hostname: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_by_name_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn lookup_by_name_with_flags>( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn lookup_by_name_with_flags_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, hostname: &str, flags: ResolverNameLookupFlags, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_by_name_with_flags_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn lookup_by_name_with_flags_async_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); }, ); }, )) } fn lookup_records>( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_records_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, rrname: &str, record_type: ResolverRecordType, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_records_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } fn lookup_service>( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_service_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, service: &str, protocol: &str, domain: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_service_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn set_default(&self) { unsafe { ffi::g_resolver_set_default(self.as_ref().to_glib_none().0); } } 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(transmute::<_, unsafe extern "C" fn()>( reload_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Resolver { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Resolver") } } gio-0.14.8/src/auto/resource.rs000064400000000000000000000074520072674642500144700ustar 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::InputStream; use crate::ResourceLookupFlags; use glib::translate::*; use std::mem; use std::ptr; 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 = 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 = mem::MaybeUninit::uninit(); let mut flags = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = 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, ); let size = size.assume_init(); let flags = flags.assume_init(); if error.is_null() { Ok((size, flags)) } 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 = 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 = 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: P) -> Result { unsafe { let mut error = 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.14.8/src/auto/seekable.rs000064400000000000000000000055270072674642500144150ustar 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::Cancellable; use glib::object::IsA; use glib::translate::*; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GSeekable")] pub struct Seekable(Interface); match fn { type_ => || ffi::g_seekable_get_type(), } } pub const NONE_SEEKABLE: Option<&Seekable> = None; pub trait SeekableExt: 'static { #[doc(alias = "g_seekable_can_seek")] fn can_seek(&self) -> bool; #[doc(alias = "g_seekable_can_truncate")] fn can_truncate(&self) -> bool; #[doc(alias = "g_seekable_seek")] fn seek>( &self, offset: i64, type_: glib::SeekType, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_seekable_tell")] fn tell(&self) -> i64; #[doc(alias = "g_seekable_truncate")] fn truncate>( &self, offset: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error>; } impl> SeekableExt for O { fn can_seek(&self) -> bool { unsafe { from_glib(ffi::g_seekable_can_seek(self.as_ref().to_glib_none().0)) } } fn can_truncate(&self) -> bool { unsafe { from_glib(ffi::g_seekable_can_truncate(self.as_ref().to_glib_none().0)) } } fn seek>( &self, offset: i64, type_: glib::SeekType, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn tell(&self) -> i64 { unsafe { ffi::g_seekable_tell(self.as_ref().to_glib_none().0) } } fn truncate>( &self, offset: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_seekable_truncate( self.as_ref().to_glib_none().0, offset, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } } impl fmt::Display for Seekable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Seekable") } } gio-0.14.8/src/auto/settings.rs000064400000000000000000000663310072674642500145020ustar 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::Action; use crate::SettingsBackend; use crate::SettingsSchema; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GSettings")] pub struct Settings(Object); match fn { type_ => || ffi::g_settings_get_type(), } } impl Settings { #[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<&P>, 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: &P) -> 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: &P, 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: &P, property: &str) { unsafe { ffi::g_settings_unbind(object.as_ref().to_glib_none().0, property.to_glib_none().0); } } } pub const NONE_SETTINGS: Option<&Settings> = None; pub trait SettingsExt: 'static { #[doc(alias = "g_settings_apply")] fn apply(&self); #[doc(alias = "g_settings_bind_writable")] fn bind_writable>( &self, key: &str, object: &P, property: &str, inverted: bool, ); #[doc(alias = "g_settings_create_action")] fn create_action(&self, key: &str) -> Action; #[doc(alias = "g_settings_delay")] fn delay(&self); //#[doc(alias = "g_settings_get")] //fn get(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs); #[doc(alias = "g_settings_get_boolean")] #[doc(alias = "get_boolean")] fn boolean(&self, key: &str) -> bool; #[doc(alias = "g_settings_get_child")] #[doc(alias = "get_child")] fn child(&self, name: &str) -> Settings; #[doc(alias = "g_settings_get_default_value")] #[doc(alias = "get_default_value")] fn default_value(&self, key: &str) -> Option; #[doc(alias = "g_settings_get_double")] #[doc(alias = "get_double")] fn double(&self, key: &str) -> f64; #[doc(alias = "g_settings_get_enum")] #[doc(alias = "get_enum")] fn enum_(&self, key: &str) -> i32; #[doc(alias = "g_settings_get_flags")] #[doc(alias = "get_flags")] fn flags(&self, key: &str) -> u32; #[doc(alias = "g_settings_get_has_unapplied")] #[doc(alias = "get_has_unapplied")] fn has_unapplied(&self) -> bool; #[doc(alias = "g_settings_get_int")] #[doc(alias = "get_int")] fn int(&self, key: &str) -> i32; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_settings_get_int64")] #[doc(alias = "get_int64")] fn int64(&self, key: &str) -> i64; //#[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; #[doc(alias = "g_settings_get_string")] #[doc(alias = "get_string")] fn string(&self, key: &str) -> glib::GString; #[doc(alias = "g_settings_get_strv")] #[doc(alias = "get_strv")] fn strv(&self, key: &str) -> Vec; #[doc(alias = "g_settings_get_uint")] #[doc(alias = "get_uint")] fn uint(&self, key: &str) -> u32; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_settings_get_uint64")] #[doc(alias = "get_uint64")] fn uint64(&self, key: &str) -> u64; #[doc(alias = "g_settings_get_user_value")] #[doc(alias = "get_user_value")] fn user_value(&self, key: &str) -> Option; #[doc(alias = "g_settings_get_value")] #[doc(alias = "get_value")] fn value(&self, key: &str) -> glib::Variant; #[doc(alias = "g_settings_is_writable")] fn is_writable(&self, name: &str) -> bool; #[doc(alias = "g_settings_list_children")] fn list_children(&self) -> Vec; #[doc(alias = "g_settings_reset")] fn reset(&self, key: &str); #[doc(alias = "g_settings_revert")] fn revert(&self); //#[doc(alias = "g_settings_set")] //fn set(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool; #[doc(alias = "g_settings_set_boolean")] fn set_boolean(&self, key: &str, value: bool) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_double")] fn set_double(&self, key: &str, value: f64) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_enum")] fn set_enum(&self, key: &str, value: i32) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_flags")] fn set_flags(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_int")] fn set_int(&self, key: &str, value: i32) -> Result<(), glib::error::BoolError>; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_settings_set_int64")] fn set_int64(&self, key: &str, value: i64) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_string")] fn set_string(&self, key: &str, value: &str) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_strv")] fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_uint")] fn set_uint(&self, key: &str, value: u32) -> Result<(), glib::error::BoolError>; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_settings_set_uint64")] fn set_uint64(&self, key: &str, value: u64) -> Result<(), glib::error::BoolError>; #[doc(alias = "g_settings_set_value")] fn set_value(&self, key: &str, value: &glib::Variant) -> Result<(), glib::error::BoolError>; fn backend(&self) -> Option; #[doc(alias = "delay-apply")] fn is_delay_apply(&self) -> bool; fn path(&self) -> Option; #[doc(alias = "schema-id")] fn schema_id(&self) -> Option; #[doc(alias = "settings-schema")] fn settings_schema(&self) -> Option; //#[doc(alias = "change-event")] //fn connect_change_event(&self, f: F) -> SignalHandlerId; #[doc(alias = "changed")] fn connect_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; #[doc(alias = "writable-change-event")] fn connect_writable_change_event glib::signal::Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "writable-changed")] fn connect_writable_changed( &self, detail: Option<&str>, f: F, ) -> SignalHandlerId; #[doc(alias = "delay-apply")] fn connect_delay_apply_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "has-unapplied")] fn connect_has_unapplied_notify(&self, f: F) -> SignalHandlerId; } impl> SettingsExt for O { fn apply(&self) { unsafe { ffi::g_settings_apply(self.as_ref().to_glib_none().0); } } fn bind_writable>( &self, key: &str, object: &P, 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(), ); } } 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, )) } } fn delay(&self) { unsafe { ffi::g_settings_delay(self.as_ref().to_glib_none().0); } } //fn get(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:g_settings_get() } //} 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, )) } } 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, )) } } 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, )) } } fn double(&self, key: &str) -> f64 { unsafe { ffi::g_settings_get_double(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn enum_(&self, key: &str) -> i32 { unsafe { ffi::g_settings_get_enum(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn flags(&self, key: &str) -> u32 { unsafe { ffi::g_settings_get_flags(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } fn has_unapplied(&self) -> bool { unsafe { from_glib(ffi::g_settings_get_has_unapplied( self.as_ref().to_glib_none().0, )) } } fn int(&self, key: &str) -> i32 { unsafe { ffi::g_settings_get_int(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] fn int64(&self, key: &str) -> i64 { unsafe { ffi::g_settings_get_int64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } //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() } //} 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, )) } } fn strv(&self, key: &str) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_get_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, )) } } fn uint(&self, key: &str) -> u32 { unsafe { ffi::g_settings_get_uint(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] fn uint64(&self, key: &str) -> u64 { unsafe { ffi::g_settings_get_uint64(self.as_ref().to_glib_none().0, key.to_glib_none().0) } } 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, )) } } 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, )) } } 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, )) } } fn list_children(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_settings_list_children( self.as_ref().to_glib_none().0, )) } } fn reset(&self, key: &str) { unsafe { ffi::g_settings_reset(self.as_ref().to_glib_none().0, key.to_glib_none().0); } } fn revert(&self) { unsafe { ffi::g_settings_revert(self.as_ref().to_glib_none().0); } } //fn set(&self, key: &str, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) -> bool { // unsafe { TODO: call ffi:g_settings_set() } //} 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" ) } } 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" ) } } 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" ) } } 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" ) } } 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" ) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] 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" ) } } 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" ) } } fn set_strv(&self, key: &str, value: &[&str]) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::g_settings_set_strv( self.as_ref().to_glib_none().0, key.to_glib_none().0, value.to_glib_none().0 ), "Can't set readonly key" ) } } 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" ) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] 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" ) } } 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"backend\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `backend` getter") } } fn is_delay_apply(&self) -> bool { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"delay-apply\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `delay-apply` getter") } } fn path(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"path\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `path` getter") } } fn schema_id(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"schema-id\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `schema-id` getter") } } fn settings_schema(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"settings-schema\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `settings-schema` getter") } } //fn connect_change_event(&self, f: F) -> SignalHandlerId { // Unimplemented keys: *.CArray TypeId { ns_id: 2, id: 5 } //} 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_writable_change_event glib::signal::Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn writable_change_event_trampoline< P: IsA, F: Fn(&P, u32) -> glib::signal::Inhibit + '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(transmute::<_, unsafe extern "C" fn()>( writable_change_event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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::{}\0", name)); 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(transmute::<_, unsafe extern "C" fn()>( writable_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_delay_apply_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_has_unapplied_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Settings { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Settings") } } gio-0.14.8/src/auto/settings_backend.rs000064400000000000000000000063730072674642500161510ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GSettingsBackend")] pub struct SettingsBackend(Object); match fn { type_ => || ffi::g_settings_backend_get_type(), } } impl SettingsBackend { //#[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")] pub fn default() -> SettingsBackend { unsafe { from_glib_full(ffi::g_settings_backend_get_default()) } } } pub const NONE_SETTINGS_BACKEND: Option<&SettingsBackend> = None; pub trait SettingsBackendExt: 'static { //#[doc(alias = "g_settings_backend_changed")] //fn changed(&self, key: &str, origin_tag: /*Unimplemented*/Option); //#[doc(alias = "g_settings_backend_changed_tree")] //fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option); //#[doc(alias = "g_settings_backend_keys_changed")] //fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option); //#[doc(alias = "g_settings_backend_path_changed")] //fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option); #[doc(alias = "g_settings_backend_path_writable_changed")] fn path_writable_changed(&self, path: &str); #[doc(alias = "g_settings_backend_writable_changed")] fn writable_changed(&self, key: &str); } impl> SettingsBackendExt for O { //fn changed(&self, key: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_changed() } //} //fn changed_tree(&self, tree: /*Ignored*/&glib::Tree, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_changed_tree() } //} //fn keys_changed(&self, path: &str, items: &[&str], origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_keys_changed() } //} //fn path_changed(&self, path: &str, origin_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_settings_backend_path_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, ); } } 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 fmt::Display for SettingsBackend { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SettingsBackend") } } gio-0.14.8/src/auto/settings_schema.rs000064400000000000000000000041330072674642500160120ustar 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::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.14.8/src/auto/settings_schema_key.rs000064400000000000000000000052230072674642500166630ustar 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 glib::translate::*; use std::fmt; 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 fmt::Display for SettingsSchemaKey { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.name()) } } gio-0.14.8/src/auto/settings_schema_source.rs000064400000000000000000000051550072674642500173770ustar 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::SettingsSchema; use glib::translate::*; use std::ptr; 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: P, parent: Option<&SettingsSchemaSource>, trusted: bool, ) -> Result { unsafe { let mut error = 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 = ptr::null_mut(); let mut relocatable = 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")] pub fn default() -> Option { unsafe { from_glib_none(ffi::g_settings_schema_source_get_default()) } } } gio-0.14.8/src/auto/simple_action.rs000064400000000000000000000136220072674642500154630ustar 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::Action; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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")] 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")] 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(transmute::<_, 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(transmute::<_, unsafe extern "C" fn()>( change_state_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "enabled")] pub fn connect_enabled_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_enabled_trampoline( this: *mut ffi::GSimpleAction, _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::enabled\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_enabled_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[doc(alias = "state-type")] pub fn connect_state_type_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_state_type_trampoline( this: *mut ffi::GSimpleAction, _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::state-type\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_state_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for SimpleAction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SimpleAction") } } gio-0.14.8/src/auto/simple_action_group.rs000064400000000000000000000017520072674642500167000ustar 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::ActionGroup; use crate::ActionMap; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GSimpleActionGroup")] pub struct SimpleActionGroup(Object) @implements ActionGroup, ActionMap; match fn { type_ => || ffi::g_simple_action_group_get_type(), } } impl SimpleActionGroup { #[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() } } pub const NONE_SIMPLE_ACTION_GROUP: Option<&SimpleActionGroup> = None; impl fmt::Display for SimpleActionGroup { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SimpleActionGroup") } } gio-0.14.8/src/auto/simple_io_stream.rs000064400000000000000000000021330072674642500161630ustar 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::IOStream; use crate::InputStream; use crate::OutputStream; use glib::object::Cast; use glib::object::IsA; use glib::translate::*; use std::fmt; 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, Q: IsA>( input_stream: &P, output_stream: &Q, ) -> 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() } } } impl fmt::Display for SimpleIOStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SimpleIOStream") } } gio-0.14.8/src/auto/simple_permission.rs000064400000000000000000000015530072674642500163760ustar 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::Permission; use glib::object::Cast; use glib::translate::*; use std::fmt; 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() } } } impl fmt::Display for SimplePermission { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SimplePermission") } } gio-0.14.8/src/auto/socket.rs000064400000000000000000001000500072674642500141150ustar 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::Cancellable; use crate::Credentials; use crate::InetAddress; use crate::Initable; use crate::SocketAddress; use crate::SocketConnection; use crate::SocketFamily; use crate::SocketProtocol; use crate::SocketType; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::ObjectExt; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GSocket")] pub struct Socket(Object) @implements Initable; match fn { type_ => || ffi::g_socket_get_type(), } } impl Socket { #[doc(alias = "g_socket_new")] pub fn new( family: SocketFamily, type_: SocketType, protocol: SocketProtocol, ) -> Result { unsafe { let mut error = 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)) } } } } unsafe impl glib::SendUnique for Socket { fn is_unique(&self) -> bool { self.ref_count() == 1 } } pub const NONE_SOCKET: Option<&Socket> = None; pub trait SocketExt: 'static { #[doc(alias = "g_socket_accept")] fn accept>(&self, cancellable: Option<&P>) -> Result; #[doc(alias = "g_socket_bind")] fn bind>( &self, address: &P, allow_reuse: bool, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_check_connect_result")] fn check_connect_result(&self) -> Result<(), glib::Error>; #[doc(alias = "g_socket_close")] fn close(&self) -> Result<(), glib::Error>; #[doc(alias = "g_socket_condition_check")] fn condition_check(&self, condition: glib::IOCondition) -> glib::IOCondition; #[doc(alias = "g_socket_condition_timed_wait")] fn condition_timed_wait>( &self, condition: glib::IOCondition, timeout_us: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_condition_wait")] fn condition_wait>( &self, condition: glib::IOCondition, cancellable: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_connect")] fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_connection_factory_create_connection")] fn connection_factory_create_connection(&self) -> SocketConnection; #[doc(alias = "g_socket_get_available_bytes")] #[doc(alias = "get_available_bytes")] fn available_bytes(&self) -> isize; #[doc(alias = "g_socket_get_blocking")] #[doc(alias = "get_blocking")] fn is_blocking(&self) -> bool; #[doc(alias = "g_socket_get_broadcast")] #[doc(alias = "get_broadcast")] fn is_broadcast(&self) -> bool; #[doc(alias = "g_socket_get_credentials")] #[doc(alias = "get_credentials")] fn credentials(&self) -> Result; #[doc(alias = "g_socket_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily; #[doc(alias = "g_socket_get_keepalive")] #[doc(alias = "get_keepalive")] fn is_keepalive(&self) -> bool; #[doc(alias = "g_socket_get_listen_backlog")] #[doc(alias = "get_listen_backlog")] fn listen_backlog(&self) -> i32; #[doc(alias = "g_socket_get_local_address")] #[doc(alias = "get_local_address")] fn local_address(&self) -> Result; #[doc(alias = "g_socket_get_multicast_loopback")] #[doc(alias = "get_multicast_loopback")] fn is_multicast_loopback(&self) -> bool; #[doc(alias = "g_socket_get_multicast_ttl")] #[doc(alias = "get_multicast_ttl")] fn multicast_ttl(&self) -> u32; #[doc(alias = "g_socket_get_option")] #[doc(alias = "get_option")] fn option(&self, level: i32, optname: i32) -> Result; #[doc(alias = "g_socket_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> SocketProtocol; #[doc(alias = "g_socket_get_remote_address")] #[doc(alias = "get_remote_address")] fn remote_address(&self) -> Result; #[doc(alias = "g_socket_get_socket_type")] #[doc(alias = "get_socket_type")] fn socket_type(&self) -> SocketType; #[doc(alias = "g_socket_get_timeout")] #[doc(alias = "get_timeout")] fn timeout(&self) -> u32; #[doc(alias = "g_socket_get_ttl")] #[doc(alias = "get_ttl")] fn ttl(&self) -> u32; #[doc(alias = "g_socket_is_closed")] fn is_closed(&self) -> bool; #[doc(alias = "g_socket_is_connected")] fn is_connected(&self) -> bool; #[doc(alias = "g_socket_join_multicast_group")] fn join_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_socket_join_multicast_group_ssm")] fn join_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_leave_multicast_group")] fn leave_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error>; #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] #[doc(alias = "g_socket_leave_multicast_group_ssm")] fn leave_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_listen")] fn listen(&self) -> Result<(), glib::Error>; #[doc(alias = "g_socket_set_blocking")] fn set_blocking(&self, blocking: bool); #[doc(alias = "g_socket_set_broadcast")] fn set_broadcast(&self, broadcast: bool); #[doc(alias = "g_socket_set_keepalive")] fn set_keepalive(&self, keepalive: bool); #[doc(alias = "g_socket_set_listen_backlog")] fn set_listen_backlog(&self, backlog: i32); #[doc(alias = "g_socket_set_multicast_loopback")] fn set_multicast_loopback(&self, loopback: bool); #[doc(alias = "g_socket_set_multicast_ttl")] fn set_multicast_ttl(&self, ttl: u32); #[doc(alias = "g_socket_set_option")] fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), glib::Error>; #[doc(alias = "g_socket_set_timeout")] fn set_timeout(&self, timeout: u32); #[doc(alias = "g_socket_set_ttl")] fn set_ttl(&self, ttl: u32); #[doc(alias = "g_socket_shutdown")] fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), glib::Error>; #[doc(alias = "g_socket_speaks_ipv4")] fn speaks_ipv4(&self) -> bool; #[doc(alias = "type")] fn type_(&self) -> SocketType; #[doc(alias = "blocking")] fn connect_blocking_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "broadcast")] fn connect_broadcast_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "keepalive")] fn connect_keepalive_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "listen-backlog")] fn connect_listen_backlog_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "local-address")] fn connect_local_address_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "multicast-loopback")] fn connect_multicast_loopback_notify( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "multicast-ttl")] fn connect_multicast_ttl_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "remote-address")] fn connect_remote_address_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "timeout")] fn connect_timeout_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "ttl")] fn connect_ttl_notify(&self, f: F) -> SignalHandlerId; } impl> SocketExt for O { fn accept>(&self, cancellable: Option<&P>) -> Result { unsafe { let mut error = 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)) } } } fn bind>( &self, address: &P, allow_reuse: bool, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_bind( self.as_ref().to_glib_none().0, address.as_ref().to_glib_none().0, allow_reuse.into_glib(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn check_connect_result(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_check_connect_result(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_close(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } 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(), )) } } fn condition_timed_wait>( &self, condition: glib::IOCondition, timeout_us: i64, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn condition_wait>( &self, condition: glib::IOCondition, cancellable: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } 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, )) } } fn available_bytes(&self) -> isize { unsafe { ffi::g_socket_get_available_bytes(self.as_ref().to_glib_none().0) } } fn is_blocking(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_blocking(self.as_ref().to_glib_none().0)) } } fn is_broadcast(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_broadcast(self.as_ref().to_glib_none().0)) } } fn credentials(&self) -> Result { unsafe { let mut error = 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)) } } } fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_get_family(self.as_ref().to_glib_none().0)) } } fn is_keepalive(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_keepalive(self.as_ref().to_glib_none().0)) } } fn listen_backlog(&self) -> i32 { unsafe { ffi::g_socket_get_listen_backlog(self.as_ref().to_glib_none().0) } } fn local_address(&self) -> Result { unsafe { let mut error = 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)) } } } fn is_multicast_loopback(&self) -> bool { unsafe { from_glib(ffi::g_socket_get_multicast_loopback( self.as_ref().to_glib_none().0, )) } } fn multicast_ttl(&self) -> u32 { unsafe { ffi::g_socket_get_multicast_ttl(self.as_ref().to_glib_none().0) } } fn option(&self, level: i32, optname: i32) -> Result { unsafe { let mut value = mem::MaybeUninit::uninit(); let mut error = ptr::null_mut(); let _ = ffi::g_socket_get_option( self.as_ref().to_glib_none().0, level, optname, value.as_mut_ptr(), &mut error, ); let value = value.assume_init(); if error.is_null() { Ok(value) } else { Err(from_glib_full(error)) } } } fn protocol(&self) -> SocketProtocol { unsafe { from_glib(ffi::g_socket_get_protocol(self.as_ref().to_glib_none().0)) } } fn remote_address(&self) -> Result { unsafe { let mut error = 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)) } } } fn socket_type(&self) -> SocketType { unsafe { from_glib(ffi::g_socket_get_socket_type( self.as_ref().to_glib_none().0, )) } } fn timeout(&self) -> u32 { unsafe { ffi::g_socket_get_timeout(self.as_ref().to_glib_none().0) } } fn ttl(&self) -> u32 { unsafe { ffi::g_socket_get_ttl(self.as_ref().to_glib_none().0) } } fn is_closed(&self) -> bool { unsafe { from_glib(ffi::g_socket_is_closed(self.as_ref().to_glib_none().0)) } } fn is_connected(&self) -> bool { unsafe { from_glib(ffi::g_socket_is_connected(self.as_ref().to_glib_none().0)) } } fn join_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn join_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn leave_multicast_group>( &self, group: &P, source_specific: bool, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[cfg(any(feature = "v2_56", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_56")))] fn leave_multicast_group_ssm, Q: IsA>( &self, group: &P, source_specific: Option<&Q>, iface: Option<&str>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn listen(&self) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_listen(self.as_ref().to_glib_none().0, &mut error); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_blocking(&self, blocking: bool) { unsafe { ffi::g_socket_set_blocking(self.as_ref().to_glib_none().0, blocking.into_glib()); } } fn set_broadcast(&self, broadcast: bool) { unsafe { ffi::g_socket_set_broadcast(self.as_ref().to_glib_none().0, broadcast.into_glib()); } } fn set_keepalive(&self, keepalive: bool) { unsafe { ffi::g_socket_set_keepalive(self.as_ref().to_glib_none().0, keepalive.into_glib()); } } fn set_listen_backlog(&self, backlog: i32) { unsafe { ffi::g_socket_set_listen_backlog(self.as_ref().to_glib_none().0, backlog); } } fn set_multicast_loopback(&self, loopback: bool) { unsafe { ffi::g_socket_set_multicast_loopback( self.as_ref().to_glib_none().0, loopback.into_glib(), ); } } fn set_multicast_ttl(&self, ttl: u32) { unsafe { ffi::g_socket_set_multicast_ttl(self.as_ref().to_glib_none().0, ttl); } } fn set_option(&self, level: i32, optname: i32, value: i32) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_set_option( self.as_ref().to_glib_none().0, level, optname, value, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn set_timeout(&self, timeout: u32) { unsafe { ffi::g_socket_set_timeout(self.as_ref().to_glib_none().0, timeout); } } fn set_ttl(&self, ttl: u32) { unsafe { ffi::g_socket_set_ttl(self.as_ref().to_glib_none().0, ttl); } } fn shutdown(&self, shutdown_read: bool, shutdown_write: bool) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_socket_shutdown( self.as_ref().to_glib_none().0, shutdown_read.into_glib(), shutdown_write.into_glib(), &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn speaks_ipv4(&self) -> bool { unsafe { from_glib(ffi::g_socket_speaks_ipv4(self.as_ref().to_glib_none().0)) } } fn type_(&self) -> SocketType { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"type\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `type` getter") } } fn connect_blocking_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_blocking_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_blocking_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_broadcast_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_broadcast_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_broadcast_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_keepalive_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_keepalive_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_keepalive_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_listen_backlog_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_listen_backlog_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_listen_backlog_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_local_address_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_local_address_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_local_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_multicast_loopback_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_loopback_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_multicast_loopback_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_multicast_ttl_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_multicast_ttl_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_multicast_ttl_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_remote_address_notify( &self, f: F, ) -> SignalHandlerId { unsafe extern "C" fn notify_remote_address_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_remote_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_timeout_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_timeout_trampoline< P: IsA, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_ttl_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_ttl_trampoline, F: Fn(&P) + Send + '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(transmute::<_, unsafe extern "C" fn()>( notify_ttl_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Socket { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Socket") } } gio-0.14.8/src/auto/socket_address.rs000064400000000000000000000063670072674642500156420ustar 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::SocketConnectable; use crate::SocketFamily; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GSocketAddress")] pub struct SocketAddress(Object) @implements SocketConnectable; match fn { type_ => || ffi::g_socket_address_get_type(), } } impl SocketAddress { //#[doc(alias = "g_socket_address_new_from_native")] //#[doc(alias = "new_from_native")] //pub fn from_native(native: /*Unimplemented*/Fundamental: Pointer, len: usize) -> SocketAddress { // unsafe { TODO: call ffi:g_socket_address_new_from_native() } //} } unsafe impl Send for SocketAddress {} unsafe impl Sync for SocketAddress {} pub const NONE_SOCKET_ADDRESS: Option<&SocketAddress> = None; pub trait SocketAddressExt: 'static { #[doc(alias = "g_socket_address_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily; #[doc(alias = "g_socket_address_get_native_size")] #[doc(alias = "get_native_size")] fn native_size(&self) -> isize; //#[doc(alias = "g_socket_address_to_native")] //fn to_native(&self, dest: /*Unimplemented*/Option, destlen: usize) -> Result<(), glib::Error>; #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId; } impl> SocketAddressExt for O { fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_address_get_family( self.as_ref().to_glib_none().0, )) } } fn native_size(&self) -> isize { unsafe { ffi::g_socket_address_get_native_size(self.as_ref().to_glib_none().0) } } //fn to_native(&self, dest: /*Unimplemented*/Option, destlen: usize) -> Result<(), glib::Error> { // unsafe { TODO: call ffi:g_socket_address_to_native() } //} 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(transmute::<_, unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for SocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketAddress") } } gio-0.14.8/src/auto/socket_address_enumerator.rs000064400000000000000000000075710072674642500201010ustar 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::AsyncResult; use crate::Cancellable; use crate::SocketAddress; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GSocketAddressEnumerator")] pub struct SocketAddressEnumerator(Object); match fn { type_ => || ffi::g_socket_address_enumerator_get_type(), } } pub const NONE_SOCKET_ADDRESS_ENUMERATOR: Option<&SocketAddressEnumerator> = None; pub trait SocketAddressEnumeratorExt: 'static { #[doc(alias = "g_socket_address_enumerator_next")] fn next>( &self, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_socket_address_enumerator_next_async")] fn next_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); fn next_async_future( &self, ) -> Pin> + 'static>>; } impl> SocketAddressEnumeratorExt for O { fn next>( &self, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn next_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn next_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_future( &self, ) -> Pin> + 'static>> { Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.next_async(Some(cancellable), move |res| { send.resolve(res); }); }, )) } } impl fmt::Display for SocketAddressEnumerator { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketAddressEnumerator") } } gio-0.14.8/src/auto/socket_client.rs000064400000000000000000001017730072674642500154700ustar 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::AsyncResult; use crate::Cancellable; use crate::IOStream; use crate::ProxyResolver; use crate::SocketAddress; use crate::SocketClientEvent; use crate::SocketConnectable; use crate::SocketConnection; use crate::SocketFamily; use crate::SocketProtocol; use crate::SocketType; use crate::TlsCertificateFlags; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GSocketClient")] pub struct SocketClient(Object); match fn { type_ => || ffi::g_socket_client_get_type(), } } impl SocketClient { #[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() } } pub const NONE_SOCKET_CLIENT: Option<&SocketClient> = None; pub trait SocketClientExt: 'static { #[doc(alias = "g_socket_client_add_application_proxy")] fn add_application_proxy(&self, protocol: &str); #[doc(alias = "g_socket_client_connect")] fn connect, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_socket_client_connect_async")] fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ); fn connect_async_future + Clone + 'static>( &self, connectable: &P, ) -> Pin> + 'static>>; #[doc(alias = "g_socket_client_connect_to_host")] fn connect_to_host>( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_socket_client_connect_to_host_async")] fn connect_to_host_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ); fn connect_to_host_async_future( &self, host_and_port: &str, default_port: u16, ) -> Pin> + 'static>>; #[doc(alias = "g_socket_client_connect_to_service")] fn connect_to_service>( &self, domain: &str, service: &str, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_socket_client_connect_to_service_async")] fn connect_to_service_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, domain: &str, service: &str, cancellable: Option<&P>, callback: Q, ); fn connect_to_service_async_future( &self, domain: &str, service: &str, ) -> Pin> + 'static>>; #[doc(alias = "g_socket_client_connect_to_uri")] fn connect_to_uri>( &self, uri: &str, default_port: u16, cancellable: Option<&P>, ) -> Result; #[doc(alias = "g_socket_client_connect_to_uri_async")] fn connect_to_uri_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, uri: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ); fn connect_to_uri_async_future( &self, uri: &str, default_port: u16, ) -> Pin> + 'static>>; #[doc(alias = "g_socket_client_get_enable_proxy")] #[doc(alias = "get_enable_proxy")] fn enables_proxy(&self) -> bool; #[doc(alias = "g_socket_client_get_family")] #[doc(alias = "get_family")] fn family(&self) -> SocketFamily; #[doc(alias = "g_socket_client_get_local_address")] #[doc(alias = "get_local_address")] fn local_address(&self) -> Option; #[doc(alias = "g_socket_client_get_protocol")] #[doc(alias = "get_protocol")] fn protocol(&self) -> SocketProtocol; #[doc(alias = "g_socket_client_get_proxy_resolver")] #[doc(alias = "get_proxy_resolver")] fn proxy_resolver(&self) -> ProxyResolver; #[doc(alias = "g_socket_client_get_socket_type")] #[doc(alias = "get_socket_type")] fn socket_type(&self) -> SocketType; #[doc(alias = "g_socket_client_get_timeout")] #[doc(alias = "get_timeout")] fn timeout(&self) -> u32; #[doc(alias = "g_socket_client_get_tls")] #[doc(alias = "get_tls")] fn is_tls(&self) -> bool; #[doc(alias = "g_socket_client_get_tls_validation_flags")] #[doc(alias = "get_tls_validation_flags")] fn tls_validation_flags(&self) -> TlsCertificateFlags; #[doc(alias = "g_socket_client_set_enable_proxy")] fn set_enable_proxy(&self, enable: bool); #[doc(alias = "g_socket_client_set_family")] fn set_family(&self, family: SocketFamily); #[doc(alias = "g_socket_client_set_local_address")] fn set_local_address>(&self, address: Option<&P>); #[doc(alias = "g_socket_client_set_protocol")] fn set_protocol(&self, protocol: SocketProtocol); #[doc(alias = "g_socket_client_set_proxy_resolver")] fn set_proxy_resolver>(&self, proxy_resolver: Option<&P>); #[doc(alias = "g_socket_client_set_socket_type")] fn set_socket_type(&self, type_: SocketType); #[doc(alias = "g_socket_client_set_timeout")] fn set_timeout(&self, timeout: u32); #[doc(alias = "g_socket_client_set_tls")] fn set_tls(&self, tls: bool); #[doc(alias = "g_socket_client_set_tls_validation_flags")] fn set_tls_validation_flags(&self, flags: TlsCertificateFlags); #[doc(alias = "type")] fn type_(&self) -> SocketType; #[doc(alias = "type")] fn set_type(&self, type_: SocketType); #[doc(alias = "event")] fn connect_event< F: Fn(&Self, SocketClientEvent, &SocketConnectable, Option<&IOStream>) + 'static, >( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "enable-proxy")] fn connect_enable_proxy_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "family")] fn connect_family_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "local-address")] fn connect_local_address_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "protocol")] fn connect_protocol_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "proxy-resolver")] fn connect_proxy_resolver_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "timeout")] fn connect_timeout_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "tls")] fn connect_tls_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "tls-validation-flags")] fn connect_tls_validation_flags_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "type")] fn connect_type_notify(&self, f: F) -> SignalHandlerId; } impl> SocketClientExt for O { 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, ); } } fn connect, Q: IsA>( &self, connectable: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connectable: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, connectable: &P, ) -> 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); }); }, )) } fn connect_to_host>( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn connect_to_host_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, host_and_port: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_to_host_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }, ); }, )) } fn connect_to_service>( &self, domain: &str, service: &str, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn connect_to_service_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, domain: &str, service: &str, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_to_service_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn connect_to_uri>( &self, uri: &str, default_port: u16, cancellable: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn connect_to_uri_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, uri: &str, default_port: u16, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_to_uri_async_trampoline< Q: FnOnce(Result) + Send + '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_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 _); 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_async_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); }); }, )) } fn enables_proxy(&self) -> bool { unsafe { from_glib(ffi::g_socket_client_get_enable_proxy( self.as_ref().to_glib_none().0, )) } } fn family(&self) -> SocketFamily { unsafe { from_glib(ffi::g_socket_client_get_family( self.as_ref().to_glib_none().0, )) } } fn local_address(&self) -> Option { unsafe { from_glib_none(ffi::g_socket_client_get_local_address( self.as_ref().to_glib_none().0, )) } } fn protocol(&self) -> SocketProtocol { unsafe { from_glib(ffi::g_socket_client_get_protocol( self.as_ref().to_glib_none().0, )) } } fn proxy_resolver(&self) -> ProxyResolver { unsafe { from_glib_none(ffi::g_socket_client_get_proxy_resolver( self.as_ref().to_glib_none().0, )) } } fn socket_type(&self) -> SocketType { unsafe { from_glib(ffi::g_socket_client_get_socket_type( self.as_ref().to_glib_none().0, )) } } fn timeout(&self) -> u32 { unsafe { ffi::g_socket_client_get_timeout(self.as_ref().to_glib_none().0) } } fn is_tls(&self) -> bool { unsafe { from_glib(ffi::g_socket_client_get_tls(self.as_ref().to_glib_none().0)) } } fn tls_validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_socket_client_get_tls_validation_flags( self.as_ref().to_glib_none().0, )) } } 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(), ); } } fn set_family(&self, family: SocketFamily) { unsafe { ffi::g_socket_client_set_family(self.as_ref().to_glib_none().0, family.into_glib()); } } fn set_local_address>(&self, address: Option<&P>) { 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, ); } } fn set_protocol(&self, protocol: SocketProtocol) { unsafe { ffi::g_socket_client_set_protocol(self.as_ref().to_glib_none().0, protocol.into_glib()); } } fn set_proxy_resolver>(&self, proxy_resolver: Option<&P>) { 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, ); } } 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()); } } fn set_timeout(&self, timeout: u32) { unsafe { ffi::g_socket_client_set_timeout(self.as_ref().to_glib_none().0, timeout); } } fn set_tls(&self, tls: bool) { unsafe { ffi::g_socket_client_set_tls(self.as_ref().to_glib_none().0, tls.into_glib()); } } 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(), ); } } fn type_(&self) -> SocketType { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"type\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `type` getter") } } fn set_type(&self, type_: SocketType) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"type\0".as_ptr() as *const _, type_.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_enable_proxy_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_family_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_local_address_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_protocol_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_proxy_resolver_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_timeout_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_tls_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_tls_validation_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_type_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for SocketClient { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketClient") } } gio-0.14.8/src/auto/socket_connectable.rs000064400000000000000000000033510072674642500164600ustar 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::SocketAddressEnumerator; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GSocketConnectable")] pub struct SocketConnectable(Interface); match fn { type_ => || ffi::g_socket_connectable_get_type(), } } pub const NONE_SOCKET_CONNECTABLE: Option<&SocketConnectable> = None; pub trait SocketConnectableExt: 'static { #[doc(alias = "g_socket_connectable_enumerate")] fn enumerate(&self) -> SocketAddressEnumerator; #[doc(alias = "g_socket_connectable_proxy_enumerate")] fn proxy_enumerate(&self) -> SocketAddressEnumerator; #[doc(alias = "g_socket_connectable_to_string")] fn to_string(&self) -> glib::GString; } impl> SocketConnectableExt for O { fn enumerate(&self) -> SocketAddressEnumerator { unsafe { from_glib_full(ffi::g_socket_connectable_enumerate( self.as_ref().to_glib_none().0, )) } } fn proxy_enumerate(&self) -> SocketAddressEnumerator { unsafe { from_glib_full(ffi::g_socket_connectable_proxy_enumerate( self.as_ref().to_glib_none().0, )) } } fn to_string(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_socket_connectable_to_string( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for SocketConnectable { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketConnectable") } } gio-0.14.8/src/auto/socket_connection.rs000064400000000000000000000156070072674642500163510ustar 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::AsyncResult; use crate::Cancellable; use crate::IOStream; use crate::Socket; use crate::SocketAddress; use crate::SocketFamily; use crate::SocketType; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GSocketConnection")] pub struct SocketConnection(Object) @extends IOStream; match fn { type_ => || ffi::g_socket_connection_get_type(), } } impl SocketConnection { #[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, ); } } } pub const NONE_SOCKET_CONNECTION: Option<&SocketConnection> = None; pub trait SocketConnectionExt: 'static { #[doc(alias = "g_socket_connection_connect")] fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_connection_connect_async")] fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ); fn connect_async_future + Clone + 'static>( &self, address: &P, ) -> Pin> + 'static>>; #[doc(alias = "g_socket_connection_get_local_address")] #[doc(alias = "get_local_address")] fn local_address(&self) -> Result; #[doc(alias = "g_socket_connection_get_remote_address")] #[doc(alias = "get_remote_address")] fn remote_address(&self) -> Result; #[doc(alias = "g_socket_connection_get_socket")] #[doc(alias = "get_socket")] fn socket(&self) -> Socket; #[doc(alias = "g_socket_connection_is_connected")] fn is_connected(&self) -> bool; } impl> SocketConnectionExt for O { fn connect, Q: IsA>( &self, address: &P, cancellable: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn connect_async< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, address: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn connect_async_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, address: &P, ) -> 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); }); }, )) } fn local_address(&self) -> Result { unsafe { let mut error = 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)) } } } fn remote_address(&self) -> Result { unsafe { let mut error = 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)) } } } fn socket(&self) -> Socket { unsafe { from_glib_none(ffi::g_socket_connection_get_socket( self.as_ref().to_glib_none().0, )) } } fn is_connected(&self) -> bool { unsafe { from_glib(ffi::g_socket_connection_is_connected( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for SocketConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketConnection") } } gio-0.14.8/src/auto/socket_listener.rs000064400000000000000000000371060072674642500160350ustar 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::AsyncResult; use crate::Cancellable; use crate::Socket; use crate::SocketAddress; use crate::SocketConnection; use crate::SocketListenerEvent; use crate::SocketProtocol; use crate::SocketType; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GSocketListener")] pub struct SocketListener(Object); match fn { type_ => || ffi::g_socket_listener_get_type(), } } impl SocketListener { #[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() } } pub const NONE_SOCKET_LISTENER: Option<&SocketListener> = None; pub trait SocketListenerExt: 'static { #[doc(alias = "g_socket_listener_accept")] fn accept>( &self, cancellable: Option<&P>, ) -> Result<(SocketConnection, Option), glib::Error>; #[doc(alias = "g_socket_listener_accept_async")] fn accept_async< P: IsA, Q: FnOnce(Result<(SocketConnection, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); fn accept_async_future( &self, ) -> Pin< Box_< dyn std::future::Future< Output = Result<(SocketConnection, Option), glib::Error>, > + 'static, >, >; #[doc(alias = "g_socket_listener_accept_socket")] fn accept_socket>( &self, cancellable: Option<&P>, ) -> Result<(Socket, Option), glib::Error>; #[doc(alias = "g_socket_listener_accept_socket_async")] fn accept_socket_async< P: IsA, Q: FnOnce(Result<(Socket, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ); fn accept_socket_async_future( &self, ) -> Pin< Box_< dyn std::future::Future), glib::Error>> + 'static, >, >; #[doc(alias = "g_socket_listener_add_address")] fn add_address, Q: IsA>( &self, address: &P, type_: SocketType, protocol: SocketProtocol, source_object: Option<&Q>, ) -> Result; #[doc(alias = "g_socket_listener_add_any_inet_port")] fn add_any_inet_port>( &self, source_object: Option<&P>, ) -> Result; #[doc(alias = "g_socket_listener_add_inet_port")] fn add_inet_port>( &self, port: u16, source_object: Option<&P>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_listener_add_socket")] fn add_socket, Q: IsA>( &self, socket: &P, source_object: Option<&Q>, ) -> Result<(), glib::Error>; #[doc(alias = "g_socket_listener_close")] fn close(&self); #[doc(alias = "g_socket_listener_set_backlog")] fn set_backlog(&self, listen_backlog: i32); #[doc(alias = "listen-backlog")] fn listen_backlog(&self) -> i32; #[doc(alias = "listen-backlog")] fn set_listen_backlog(&self, listen_backlog: i32); #[doc(alias = "event")] fn connect_event( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "listen-backlog")] fn connect_listen_backlog_notify(&self, f: F) -> SignalHandlerId; } impl> SocketListenerExt for O { fn accept>( &self, cancellable: Option<&P>, ) -> Result<(SocketConnection, Option), glib::Error> { unsafe { let mut source_object = ptr::null_mut(); let mut error = 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)) } } } fn accept_async< P: IsA, Q: FnOnce(Result<(SocketConnection, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn accept_async_trampoline< Q: FnOnce(Result<(SocketConnection, Option), glib::Error>) + Send + '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 source_object = 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 _); 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_async_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); }); }, )) } fn accept_socket>( &self, cancellable: Option<&P>, ) -> Result<(Socket, Option), glib::Error> { unsafe { let mut source_object = ptr::null_mut(); let mut error = 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)) } } } fn accept_socket_async< P: IsA, Q: FnOnce(Result<(Socket, Option), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn accept_socket_async_trampoline< Q: FnOnce(Result<(Socket, Option), glib::Error>) + Send + '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 source_object = 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 _); 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_async_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); }); }, )) } fn add_address, Q: IsA>( &self, address: &P, type_: SocketType, protocol: SocketProtocol, source_object: Option<&Q>, ) -> Result { unsafe { let mut effective_address = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(from_glib_full(effective_address)) } else { Err(from_glib_full(error)) } } } fn add_any_inet_port>( &self, source_object: Option<&P>, ) -> Result { unsafe { let mut error = 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)) } } } fn add_inet_port>( &self, port: u16, source_object: Option<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn add_socket, Q: IsA>( &self, socket: &P, source_object: Option<&Q>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = 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, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn close(&self) { unsafe { ffi::g_socket_listener_close(self.as_ref().to_glib_none().0); } } fn set_backlog(&self, listen_backlog: i32) { unsafe { ffi::g_socket_listener_set_backlog(self.as_ref().to_glib_none().0, listen_backlog); } } fn listen_backlog(&self) -> i32 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"listen-backlog\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `listen-backlog` getter") } } fn set_listen_backlog(&self, listen_backlog: i32) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"listen-backlog\0".as_ptr() as *const _, listen_backlog.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( event_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_listen_backlog_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for SocketListener { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketListener") } } gio-0.14.8/src/auto/socket_service.rs000064400000000000000000000112210072674642500156360ustar 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::SocketConnection; use crate::SocketListener; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GSocketService")] pub struct SocketService(Object) @extends SocketListener; match fn { type_ => || ffi::g_socket_service_get_type(), } } impl SocketService { #[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() } } pub const NONE_SOCKET_SERVICE: Option<&SocketService> = None; pub trait SocketServiceExt: 'static { #[doc(alias = "g_socket_service_is_active")] fn is_active(&self) -> bool; #[doc(alias = "g_socket_service_start")] fn start(&self); #[doc(alias = "g_socket_service_stop")] fn stop(&self); fn set_active(&self, active: bool); #[doc(alias = "incoming")] fn connect_incoming) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId; #[doc(alias = "active")] fn connect_active_notify(&self, f: F) -> SignalHandlerId; } impl> SocketServiceExt for O { fn is_active(&self) -> bool { unsafe { from_glib(ffi::g_socket_service_is_active( self.as_ref().to_glib_none().0, )) } } fn start(&self) { unsafe { ffi::g_socket_service_start(self.as_ref().to_glib_none().0); } } fn stop(&self) { unsafe { ffi::g_socket_service_stop(self.as_ref().to_glib_none().0); } } fn set_active(&self, active: bool) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"active\0".as_ptr() as *const _, active.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( incoming_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_active_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for SocketService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SocketService") } } gio-0.14.8/src/auto/srv_target.rs000064400000000000000000000035620072674642500150170ustar 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 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*/&[&Fundamental: Pointer]) -> /*Unimplemented*/Vec { // unsafe { TODO: call ffi:g_srv_target_list_sort() } //} } gio-0.14.8/src/auto/subprocess.rs000064400000000000000000000320040072674642500150200ustar 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::AsyncResult; use crate::Cancellable; use crate::Initable; use crate::InputStream; use crate::OutputStream; use crate::SubprocessFlags; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; 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*/Fundamental: 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 = 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<&P>, ) -> Result<(Option, Option), glib::Error> { unsafe { let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = 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, ); 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: IsA, Q: FnOnce(Result<(Option, Option), glib::Error>) + Send + 'static, >( &self, stdin_buf: Option<&glib::Bytes>, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn communicate_async_trampoline< Q: FnOnce(Result<(Option, Option), glib::Error>) + Send + '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 stdout_buf = ptr::null_mut(); let mut stderr_buf = 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 _); 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_async_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<&P>, ) -> Result<(Option, Option), glib::Error> { unsafe { let mut stdout_buf = ptr::null_mut(); let mut stderr_buf = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = 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, ); 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(any(not(windows), feature = "dox"))] #[cfg_attr(feature = "dox", 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<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_subprocess_wait( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_wait_async")] pub fn wait_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn wait_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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<&P>, ) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_subprocess_wait_check( self.to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } #[doc(alias = "g_subprocess_wait_check_async")] pub fn wait_check_async< P: IsA, Q: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn wait_check_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } } impl fmt::Display for Subprocess { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Subprocess") } } gio-0.14.8/src/auto/subprocess_launcher.rs000064400000000000000000000136510072674642500167100ustar 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::Subprocess; use crate::SubprocessFlags; use glib::translate::*; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] use std::boxed::Box as Box_; use std::fmt; use std::ptr; 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())) } } #[doc(alias = "g_subprocess_launcher_getenv")] pub fn getenv>(&self, variable: P) -> Option { unsafe { from_glib_none(ffi::g_subprocess_launcher_getenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, )) } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", 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(user_data: glib::ffi::gpointer) { let callback: &P = &*(user_data as *mut _); (*callback)(); } let child_setup = Some(child_setup_func::

as _); unsafe extern "C" fn destroy_notify_func(data: glib::ffi::gpointer) { let _callback: Box_

= Box_::from_raw(data as *mut _); } 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: P) { 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stderr_file_path")] pub fn set_stderr_file_path>(&self, path: P) { unsafe { ffi::g_subprocess_launcher_set_stderr_file_path( self.to_glib_none().0, path.as_ref().to_glib_none().0, ); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stdin_file_path")] pub fn set_stdin_file_path(&self, path: &str) { unsafe { ffi::g_subprocess_launcher_set_stdin_file_path( self.to_glib_none().0, path.to_glib_none().0, ); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_set_stdout_file_path")] pub fn set_stdout_file_path>(&self, path: P) { unsafe { ffi::g_subprocess_launcher_set_stdout_file_path( self.to_glib_none().0, path.as_ref().to_glib_none().0, ); } } #[doc(alias = "g_subprocess_launcher_setenv")] pub fn setenv, Q: AsRef>( &self, variable: P, value: Q, 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*/Fundamental: 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 = 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: P) { unsafe { ffi::g_subprocess_launcher_unsetenv( self.to_glib_none().0, variable.as_ref().to_glib_none().0, ); } } } impl fmt::Display for SubprocessLauncher { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("SubprocessLauncher") } } gio-0.14.8/src/auto/task.rs000064400000000000000000000147020072674642500135770ustar 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::AsyncResult; use crate::Cancellable; use glib::object::IsA; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GTask")] pub struct Task(Object) @implements AsyncResult; match fn { type_ => || ffi::g_task_get_type(), } } impl Task { //#[doc(alias = "g_task_attach_source")] //pub fn attach_source bool + 'static>(&self, source: &glib::Source, callback: P) { // unsafe { TODO: call ffi:g_task_attach_source() } //} #[doc(alias = "g_task_get_cancellable")] #[doc(alias = "get_cancellable")] pub fn cancellable(&self) -> Cancellable { 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_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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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_get_source_tag")] //#[doc(alias = "get_source_tag")] //pub fn source_tag(&self) -> /*Unimplemented*/Option { // unsafe { TODO: call ffi:g_task_get_source_tag() } //} #[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 = "g_task_return_error_if_cancelled")] pub 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_new_error")] //pub fn return_new_error(&self, domain: glib::Quark, code: i32, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:g_task_return_new_error() } //} //#[doc(alias = "g_task_run_in_thread_sync")] //pub fn run_in_thread_sync(&self, task_func: /*Unimplemented*/FnOnce(&Task, &glib::Object, /*Unimplemented*/Option, Option<&Cancellable>)) { // unsafe { TODO: call ffi:g_task_run_in_thread_sync() } //} #[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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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_set_source_tag")] //pub fn set_source_tag(&self, source_tag: /*Unimplemented*/Option) { // unsafe { TODO: call ffi:g_task_set_source_tag() } //} #[doc(alias = "g_task_is_valid")] pub fn is_valid, Q: IsA>( result: &P, source_object: Option<&Q>, ) -> 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 = "g_task_report_error")] //pub fn report_error) + 'static>(source_object: Option<&glib::Object>, callback: P, source_tag: /*Unimplemented*/Option, error: &mut glib::Error) { // unsafe { TODO: call ffi:g_task_report_error() } //} //#[doc(alias = "g_task_report_new_error")] //pub fn report_new_error) + 'static>(source_object: Option<&glib::Object>, callback: P, source_tag: /*Unimplemented*/Option, domain: glib::Quark, code: i32, format: &str, : /*Unknown conversion*//*Unimplemented*/Fundamental: VarArgs) { // unsafe { TODO: call ffi:g_task_report_new_error() } //} #[doc(alias = "completed")] pub fn connect_completed_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_completed_trampoline( this: *mut ffi::GTask, _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::completed\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_completed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Task { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Task") } } gio-0.14.8/src/auto/tcp_connection.rs000064400000000000000000000053550072674642500156460ustar 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::IOStream; use crate::SocketConnection; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GTcpConnection")] pub struct TcpConnection(Object) @extends SocketConnection, IOStream; match fn { type_ => || ffi::g_tcp_connection_get_type(), } } pub const NONE_TCP_CONNECTION: Option<&TcpConnection> = None; pub trait TcpConnectionExt: 'static { #[doc(alias = "g_tcp_connection_get_graceful_disconnect")] #[doc(alias = "get_graceful_disconnect")] fn is_graceful_disconnect(&self) -> bool; #[doc(alias = "g_tcp_connection_set_graceful_disconnect")] fn set_graceful_disconnect(&self, graceful_disconnect: bool); #[doc(alias = "graceful-disconnect")] fn connect_graceful_disconnect_notify(&self, f: F) -> SignalHandlerId; } impl> TcpConnectionExt for O { fn is_graceful_disconnect(&self) -> bool { unsafe { from_glib(ffi::g_tcp_connection_get_graceful_disconnect( self.as_ref().to_glib_none().0, )) } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_graceful_disconnect_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TcpConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TcpConnection") } } gio-0.14.8/src/auto/themed_icon.rs000064400000000000000000000073250072674642500151160ustar 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::Icon; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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 i32; 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"use-default-fallbacks\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `use-default-fallbacks` getter") } } #[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(transmute::<_, unsafe extern "C" fn()>( notify_names_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ThemedIcon { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ThemedIcon") } } gio-0.14.8/src/auto/threaded_socket_service.rs000064400000000000000000000061520072674642500175050ustar 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::SocketConnection; use crate::SocketListener; use crate::SocketService; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GThreadedSocketService")] pub struct ThreadedSocketService(Object) @extends SocketService, SocketListener; match fn { type_ => || ffi::g_threaded_socket_service_get_type(), } } pub const NONE_THREADED_SOCKET_SERVICE: Option<&ThreadedSocketService> = None; pub trait ThreadedSocketServiceExt: 'static { #[doc(alias = "max-threads")] fn max_threads(&self) -> i32; #[doc(alias = "run")] fn connect_run) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId; } impl> ThreadedSocketServiceExt for O { fn max_threads(&self) -> i32 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"max-threads\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `max-threads` getter") } } 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(transmute::<_, unsafe extern "C" fn()>( run_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ThreadedSocketService { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ThreadedSocketService") } } gio-0.14.8/src/auto/tls_backend.rs000064400000000000000000000114300072674642500151010ustar 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::TlsDatabase; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GTlsBackend")] pub struct TlsBackend(Interface); match fn { type_ => || ffi::g_tls_backend_get_type(), } } impl TlsBackend { #[doc(alias = "g_tls_backend_get_default")] #[doc(alias = "get_default")] pub fn default() -> TlsBackend { unsafe { from_glib_none(ffi::g_tls_backend_get_default()) } } } pub const NONE_TLS_BACKEND: Option<&TlsBackend> = None; pub trait TlsBackendExt: 'static { #[doc(alias = "g_tls_backend_get_certificate_type")] #[doc(alias = "get_certificate_type")] fn certificate_type(&self) -> glib::types::Type; #[doc(alias = "g_tls_backend_get_client_connection_type")] #[doc(alias = "get_client_connection_type")] fn client_connection_type(&self) -> glib::types::Type; #[doc(alias = "g_tls_backend_get_default_database")] #[doc(alias = "get_default_database")] fn default_database(&self) -> TlsDatabase; #[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; #[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; #[doc(alias = "g_tls_backend_get_file_database_type")] #[doc(alias = "get_file_database_type")] fn file_database_type(&self) -> glib::types::Type; #[doc(alias = "g_tls_backend_get_server_connection_type")] #[doc(alias = "get_server_connection_type")] fn server_connection_type(&self) -> glib::types::Type; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_backend_set_default_database")] fn set_default_database>(&self, database: Option<&P>); #[doc(alias = "g_tls_backend_supports_dtls")] fn supports_dtls(&self) -> bool; #[doc(alias = "g_tls_backend_supports_tls")] fn supports_tls(&self) -> bool; } impl> TlsBackendExt for O { fn certificate_type(&self) -> glib::types::Type { unsafe { from_glib(ffi::g_tls_backend_get_certificate_type( self.as_ref().to_glib_none().0, )) } } 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, )) } } fn default_database(&self) -> TlsDatabase { unsafe { from_glib_full(ffi::g_tls_backend_get_default_database( self.as_ref().to_glib_none().0, )) } } 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, )) } } 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, )) } } 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, )) } } 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn set_default_database>(&self, database: Option<&P>) { 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, ); } } fn supports_dtls(&self) -> bool { unsafe { from_glib(ffi::g_tls_backend_supports_dtls( self.as_ref().to_glib_none().0, )) } } fn supports_tls(&self) -> bool { unsafe { from_glib(ffi::g_tls_backend_supports_tls( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for TlsBackend { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsBackend") } } gio-0.14.8/src/auto/tls_certificate.rs000064400000000000000000000134000072674642500157730ustar 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::SocketConnectable; use crate::TlsCertificateFlags; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use std::fmt; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsCertificate")] pub struct TlsCertificate(Object); match fn { type_ => || ffi::g_tls_certificate_get_type(), } } impl TlsCertificate { #[doc(alias = "g_tls_certificate_new_from_file")] #[doc(alias = "new_from_file")] pub fn from_file>(file: P) -> Result { unsafe { let mut error = 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)) } } } #[doc(alias = "g_tls_certificate_new_from_files")] #[doc(alias = "new_from_files")] pub fn from_files, Q: AsRef>( cert_file: P, key_file: Q, ) -> Result { unsafe { let mut error = 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 isize; unsafe { let mut error = 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)) } } } #[doc(alias = "g_tls_certificate_list_new_from_file")] pub fn list_new_from_file>( file: P, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } } pub const NONE_TLS_CERTIFICATE: Option<&TlsCertificate> = None; pub trait TlsCertificateExt: 'static { #[doc(alias = "g_tls_certificate_get_issuer")] #[doc(alias = "get_issuer")] fn issuer(&self) -> Option; #[doc(alias = "g_tls_certificate_is_same")] fn is_same>(&self, cert_two: &P) -> bool; #[doc(alias = "g_tls_certificate_verify")] fn verify, Q: IsA>( &self, identity: Option<&P>, trusted_ca: Option<&Q>, ) -> TlsCertificateFlags; fn certificate(&self) -> Option; #[doc(alias = "certificate-pem")] fn certificate_pem(&self) -> Option; } impl> TlsCertificateExt for O { fn issuer(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_certificate_get_issuer( self.as_ref().to_glib_none().0, )) } } fn is_same>(&self, cert_two: &P) -> 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, )) } } fn verify, Q: IsA>( &self, identity: Option<&P>, trusted_ca: Option<&Q>, ) -> 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"certificate\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `certificate` getter") } } fn certificate_pem(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"certificate-pem\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `certificate-pem` getter") } } } impl fmt::Display for TlsCertificate { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsCertificate") } } gio-0.14.8/src/auto/tls_client_connection.rs000064400000000000000000000221760072674642500172200ustar 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::IOStream; use crate::SocketConnectable; use crate::TlsCertificateFlags; use crate::TlsConnection; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsClientConnection")] pub struct TlsClientConnection(Interface) @requires TlsConnection, IOStream; match fn { type_ => || ffi::g_tls_client_connection_get_type(), } } impl TlsClientConnection { #[doc(alias = "g_tls_client_connection_new")] pub fn new, Q: IsA>( base_io_stream: &P, server_identity: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } } pub const NONE_TLS_CLIENT_CONNECTION: Option<&TlsClientConnection> = None; pub trait TlsClientConnectionExt: 'static { #[doc(alias = "g_tls_client_connection_copy_session_state")] fn copy_session_state>(&self, source: &P); #[doc(alias = "g_tls_client_connection_get_accepted_cas")] #[doc(alias = "get_accepted_cas")] fn accepted_cas(&self) -> Vec; #[doc(alias = "g_tls_client_connection_get_server_identity")] #[doc(alias = "get_server_identity")] fn server_identity(&self) -> Option; #[cfg_attr(feature = "v2_56", deprecated = "Since 2.56")] #[doc(alias = "g_tls_client_connection_get_use_ssl3")] #[doc(alias = "get_use_ssl3")] fn uses_ssl3(&self) -> bool; #[doc(alias = "g_tls_client_connection_get_validation_flags")] #[doc(alias = "get_validation_flags")] fn validation_flags(&self) -> TlsCertificateFlags; #[doc(alias = "g_tls_client_connection_set_server_identity")] fn set_server_identity>(&self, identity: &P); #[cfg_attr(feature = "v2_56", deprecated = "Since 2.56")] #[doc(alias = "g_tls_client_connection_set_use_ssl3")] fn set_use_ssl3(&self, use_ssl3: bool); #[doc(alias = "g_tls_client_connection_set_validation_flags")] fn set_validation_flags(&self, flags: TlsCertificateFlags); #[doc(alias = "accepted-cas")] fn connect_accepted_cas_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "server-identity")] fn connect_server_identity_notify(&self, f: F) -> SignalHandlerId; #[cfg_attr(feature = "v2_56", deprecated = "Since 2.56")] #[doc(alias = "use-ssl3")] fn connect_use_ssl3_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "validation-flags")] fn connect_validation_flags_notify(&self, f: F) -> SignalHandlerId; } impl> TlsClientConnectionExt for O { fn copy_session_state>(&self, source: &P) { unsafe { ffi::g_tls_client_connection_copy_session_state( self.as_ref().to_glib_none().0, source.as_ref().to_glib_none().0, ); } } 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, )) } } fn server_identity(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_client_connection_get_server_identity( self.as_ref().to_glib_none().0, )) } } fn uses_ssl3(&self) -> bool { unsafe { from_glib(ffi::g_tls_client_connection_get_use_ssl3( self.as_ref().to_glib_none().0, )) } } fn validation_flags(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_tls_client_connection_get_validation_flags( self.as_ref().to_glib_none().0, )) } } fn set_server_identity>(&self, identity: &P) { unsafe { ffi::g_tls_client_connection_set_server_identity( self.as_ref().to_glib_none().0, identity.as_ref().to_glib_none().0, ); } } fn set_use_ssl3(&self, use_ssl3: bool) { unsafe { ffi::g_tls_client_connection_set_use_ssl3( self.as_ref().to_glib_none().0, use_ssl3.into_glib(), ); } } 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(), ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_accepted_cas_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_server_identity_trampoline:: as *const (), )), Box_::into_raw(f), ) } } fn connect_use_ssl3_notify(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn notify_use_ssl3_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::use-ssl3\0".as_ptr() as *const _, Some(transmute::<_, unsafe extern "C" fn()>( notify_use_ssl3_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_validation_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsClientConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsClientConnection") } } gio-0.14.8/src/auto/tls_connection.rs000064400000000000000000000564150072674642500156650ustar 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::AsyncResult; use crate::Cancellable; use crate::IOStream; use crate::TlsCertificate; use crate::TlsCertificateFlags; use crate::TlsDatabase; use crate::TlsInteraction; use crate::TlsRehandshakeMode; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsConnection")] pub struct TlsConnection(Object) @extends IOStream; match fn { type_ => || ffi::g_tls_connection_get_type(), } } pub const NONE_TLS_CONNECTION: Option<&TlsConnection> = None; pub trait TlsConnectionExt: 'static { #[doc(alias = "g_tls_connection_emit_accept_certificate")] fn emit_accept_certificate>( &self, peer_cert: &P, errors: TlsCertificateFlags, ) -> bool; #[doc(alias = "g_tls_connection_get_certificate")] #[doc(alias = "get_certificate")] fn certificate(&self) -> Option; #[doc(alias = "g_tls_connection_get_database")] #[doc(alias = "get_database")] fn database(&self) -> Option; #[doc(alias = "g_tls_connection_get_interaction")] #[doc(alias = "get_interaction")] fn interaction(&self) -> Option; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_connection_get_negotiated_protocol")] #[doc(alias = "get_negotiated_protocol")] fn negotiated_protocol(&self) -> Option; #[doc(alias = "g_tls_connection_get_peer_certificate")] #[doc(alias = "get_peer_certificate")] fn peer_certificate(&self) -> Option; #[doc(alias = "g_tls_connection_get_peer_certificate_errors")] #[doc(alias = "get_peer_certificate_errors")] fn peer_certificate_errors(&self) -> TlsCertificateFlags; #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[doc(alias = "g_tls_connection_get_rehandshake_mode")] #[doc(alias = "get_rehandshake_mode")] fn rehandshake_mode(&self) -> TlsRehandshakeMode; #[doc(alias = "g_tls_connection_get_require_close_notify")] #[doc(alias = "get_require_close_notify")] fn requires_close_notify(&self) -> bool; #[doc(alias = "g_tls_connection_handshake")] fn handshake>(&self, cancellable: Option<&P>) -> Result<(), glib::Error>; #[doc(alias = "g_tls_connection_handshake_async")] fn handshake_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn handshake_async_future( &self, io_priority: glib::Priority, ) -> Pin> + 'static>>; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "g_tls_connection_set_advertised_protocols")] fn set_advertised_protocols(&self, protocols: &[&str]); #[doc(alias = "g_tls_connection_set_certificate")] fn set_certificate>(&self, certificate: &P); #[doc(alias = "g_tls_connection_set_database")] fn set_database>(&self, database: Option<&P>); #[doc(alias = "g_tls_connection_set_interaction")] fn set_interaction>(&self, interaction: Option<&P>); #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[doc(alias = "g_tls_connection_set_rehandshake_mode")] fn set_rehandshake_mode(&self, mode: TlsRehandshakeMode); #[doc(alias = "g_tls_connection_set_require_close_notify")] fn set_require_close_notify(&self, require_close_notify: bool); #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "advertised-protocols")] fn advertised_protocols(&self) -> Vec; #[doc(alias = "base-io-stream")] fn base_io_stream(&self) -> Option; #[doc(alias = "accept-certificate")] fn connect_accept_certificate< F: Fn(&Self, &TlsCertificate, TlsCertificateFlags) -> bool + 'static, >( &self, f: F, ) -> SignalHandlerId; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "advertised-protocols")] fn connect_advertised_protocols_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "certificate")] fn connect_certificate_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "database")] fn connect_database_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "interaction")] fn connect_interaction_notify(&self, f: F) -> SignalHandlerId; #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] #[doc(alias = "negotiated-protocol")] fn connect_negotiated_protocol_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "peer-certificate")] fn connect_peer_certificate_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "peer-certificate-errors")] fn connect_peer_certificate_errors_notify( &self, f: F, ) -> SignalHandlerId; #[cfg_attr(feature = "v2_60", deprecated = "Since 2.60")] #[doc(alias = "rehandshake-mode")] fn connect_rehandshake_mode_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "require-close-notify")] fn connect_require_close_notify_notify(&self, f: F) -> SignalHandlerId; } impl> TlsConnectionExt for O { fn emit_accept_certificate>( &self, peer_cert: &P, 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(), )) } } fn certificate(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_certificate( self.as_ref().to_glib_none().0, )) } } fn database(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_database( self.as_ref().to_glib_none().0, )) } } fn interaction(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_interaction( self.as_ref().to_glib_none().0, )) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn negotiated_protocol(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_negotiated_protocol( self.as_ref().to_glib_none().0, )) } } fn peer_certificate(&self) -> Option { unsafe { from_glib_none(ffi::g_tls_connection_get_peer_certificate( self.as_ref().to_glib_none().0, )) } } fn peer_certificate_errors(&self) -> TlsCertificateFlags { unsafe { from_glib(ffi::g_tls_connection_get_peer_certificate_errors( self.as_ref().to_glib_none().0, )) } } fn rehandshake_mode(&self) -> TlsRehandshakeMode { unsafe { from_glib(ffi::g_tls_connection_get_rehandshake_mode( self.as_ref().to_glib_none().0, )) } } fn requires_close_notify(&self) -> bool { unsafe { from_glib(ffi::g_tls_connection_get_require_close_notify( self.as_ref().to_glib_none().0, )) } } fn handshake>(&self, cancellable: Option<&P>) -> Result<(), glib::Error> { unsafe { let mut error = ptr::null_mut(); let _ = ffi::g_tls_connection_handshake( self.as_ref().to_glib_none().0, cancellable.map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) } } } fn handshake_async, Q: FnOnce(Result<(), glib::Error>) + Send + 'static>( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn handshake_async_trampoline< Q: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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_async_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); }); }, )) } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn set_advertised_protocols(&self, protocols: &[&str]) { unsafe { ffi::g_tls_connection_set_advertised_protocols( self.as_ref().to_glib_none().0, protocols.to_glib_none().0, ); } } fn set_certificate>(&self, certificate: &P) { unsafe { ffi::g_tls_connection_set_certificate( self.as_ref().to_glib_none().0, certificate.as_ref().to_glib_none().0, ); } } fn set_database>(&self, database: Option<&P>) { unsafe { ffi::g_tls_connection_set_database( self.as_ref().to_glib_none().0, database.map(|p| p.as_ref()).to_glib_none().0, ); } } fn set_interaction>(&self, interaction: Option<&P>) { unsafe { ffi::g_tls_connection_set_interaction( self.as_ref().to_glib_none().0, interaction.map(|p| p.as_ref()).to_glib_none().0, ); } } 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(), ); } } 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] fn advertised_protocols(&self) -> Vec { unsafe { let mut value = glib::Value::from_type( as StaticType>::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"advertised-protocols\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `advertised-protocols` getter") } } fn base_io_stream(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"base-io-stream\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `base-io-stream` getter") } } 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(transmute::<_, unsafe extern "C" fn()>( accept_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 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(transmute::<_, unsafe extern "C" fn()>( notify_advertised_protocols_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_database_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_interaction_trampoline:: as *const (), )), Box_::into_raw(f), ) } } #[cfg(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_60")))] 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(transmute::<_, unsafe extern "C" fn()>( notify_negotiated_protocol_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_peer_certificate_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_peer_certificate_errors_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_rehandshake_mode_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_require_close_notify_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsConnection") } } gio-0.14.8/src/auto/tls_database.rs000064400000000000000000000522220072674642500152620ustar 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::AsyncResult; use crate::Cancellable; use crate::SocketConnectable; use crate::TlsCertificate; use crate::TlsCertificateFlags; use crate::TlsDatabaseLookupFlags; use crate::TlsDatabaseVerifyFlags; use crate::TlsInteraction; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsDatabase")] pub struct TlsDatabase(Object); match fn { type_ => || ffi::g_tls_database_get_type(), } } pub const NONE_TLS_DATABASE: Option<&TlsDatabase> = None; pub trait TlsDatabaseExt: 'static { #[doc(alias = "g_tls_database_create_certificate_handle")] fn create_certificate_handle>( &self, certificate: &P, ) -> Option; #[doc(alias = "g_tls_database_lookup_certificate_for_handle")] fn lookup_certificate_for_handle, Q: IsA>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, glib::Error>; #[doc(alias = "g_tls_database_lookup_certificate_for_handle_async")] fn lookup_certificate_for_handle_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ); fn lookup_certificate_for_handle_async_future + Clone + 'static>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, ) -> Pin> + 'static>>; #[doc(alias = "g_tls_database_lookup_certificate_issuer")] fn lookup_certificate_issuer< P: IsA, Q: IsA, R: IsA, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, ) -> Result; #[doc(alias = "g_tls_database_lookup_certificate_issuer_async")] fn lookup_certificate_issuer_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, callback: S, ); fn lookup_certificate_issuer_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, ) -> Pin> + 'static>>; #[doc(alias = "g_tls_database_lookup_certificates_issued_by")] fn lookup_certificates_issued_by, Q: IsA>( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, glib::Error>; #[doc(alias = "g_tls_database_lookup_certificates_issued_by_async")] fn lookup_certificates_issued_by_async< P: IsA, Q: IsA, R: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ); fn lookup_certificates_issued_by_async_future + Clone + 'static>( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, ) -> Pin< Box_, glib::Error>> + 'static>, >; #[doc(alias = "g_tls_database_verify_chain")] fn verify_chain< P: IsA, Q: IsA, R: IsA, S: IsA, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, ) -> Result; #[doc(alias = "g_tls_database_verify_chain_async")] fn verify_chain_async< P: IsA, Q: IsA, R: IsA, S: IsA, T: FnOnce(Result) + Send + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, callback: T, ); fn verify_chain_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, R: IsA + Clone + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, ) -> Pin< Box_> + 'static>, >; } impl> TlsDatabaseExt for O { fn create_certificate_handle>( &self, certificate: &P, ) -> 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, )) } } fn lookup_certificate_for_handle, Q: IsA>( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_certificate_for_handle_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, handle: &str, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_certificate_for_handle_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, handle: &str, interaction: Option<&P>, 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); }, ); }, )) } fn lookup_certificate_issuer< P: IsA, Q: IsA, R: IsA, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, ) -> Result { unsafe { let mut error = 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)) } } } fn lookup_certificate_issuer_async< P: IsA, Q: IsA, R: IsA, S: FnOnce(Result) + Send + 'static, >( &self, certificate: &P, interaction: Option<&Q>, flags: TlsDatabaseLookupFlags, cancellable: Option<&R>, callback: S, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_certificate_issuer_async_trampoline< S: FnOnce(Result) + Send + '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_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 _); 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_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, >( &self, certificate: &P, interaction: Option<&Q>, 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); }, ); }, )) } fn lookup_certificates_issued_by, Q: IsA>( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, ) -> Result, glib::Error> { unsafe { let mut error = 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)) } } } fn lookup_certificates_issued_by_async< P: IsA, Q: IsA, R: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, flags: TlsDatabaseLookupFlags, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn lookup_certificates_issued_by_async_trampoline< R: FnOnce(Result, glib::Error>) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, issuer_raw_dn: &glib::ByteArray, interaction: Option<&P>, 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); }, ); }, )) } fn verify_chain< P: IsA, Q: IsA, R: IsA, S: IsA, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, ) -> Result { unsafe { let mut error = 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)) } } } fn verify_chain_async< P: IsA, Q: IsA, R: IsA, S: IsA, T: FnOnce(Result) + Send + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, flags: TlsDatabaseVerifyFlags, cancellable: Option<&S>, callback: T, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn verify_chain_async_trampoline< T: FnOnce(Result) + Send + '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_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 _); 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_async_future< P: IsA + Clone + 'static, Q: IsA + Clone + 'static, R: IsA + Clone + 'static, >( &self, chain: &P, purpose: &str, identity: Option<&Q>, interaction: Option<&R>, 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 fmt::Display for TlsDatabase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsDatabase") } } gio-0.14.8/src/auto/tls_file_database.rs000064400000000000000000000066120072674642500162630ustar 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::TlsDatabase; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsFileDatabase")] pub struct TlsFileDatabase(Interface) @requires TlsDatabase; match fn { type_ => || ffi::g_tls_file_database_get_type(), } } impl TlsFileDatabase { #[doc(alias = "g_tls_file_database_new")] pub fn new>(anchors: P) -> Result { unsafe { let mut error = 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)) } } } } pub const NONE_TLS_FILE_DATABASE: Option<&TlsFileDatabase> = None; pub trait TlsFileDatabaseExt: 'static { fn anchors(&self) -> Option; fn set_anchors(&self, anchors: Option<&str>); #[doc(alias = "anchors")] fn connect_anchors_notify(&self, f: F) -> SignalHandlerId; } impl> TlsFileDatabaseExt for O { fn anchors(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"anchors\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `anchors` getter") } } fn set_anchors(&self, anchors: Option<&str>) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"anchors\0".as_ptr() as *const _, anchors.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_anchors_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsFileDatabase { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsFileDatabase") } } gio-0.14.8/src/auto/tls_interaction.rs000064400000000000000000000246140072674642500160410ustar 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::AsyncResult; use crate::Cancellable; use crate::TlsCertificateRequestFlags; use crate::TlsConnection; use crate::TlsInteractionResult; use crate::TlsPassword; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsInteraction")] pub struct TlsInteraction(Object); match fn { type_ => || ffi::g_tls_interaction_get_type(), } } pub const NONE_TLS_INTERACTION: Option<&TlsInteraction> = None; pub trait TlsInteractionExt: 'static { #[doc(alias = "g_tls_interaction_ask_password")] fn ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_tls_interaction_ask_password_async")] fn ask_password_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, password: &P, cancellable: Option<&Q>, callback: R, ); fn ask_password_async_future + Clone + 'static>( &self, password: &P, ) -> Pin< Box_> + 'static>, >; #[doc(alias = "g_tls_interaction_invoke_ask_password")] fn invoke_ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_tls_interaction_invoke_request_certificate")] fn invoke_request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_tls_interaction_request_certificate")] fn request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result; #[doc(alias = "g_tls_interaction_request_certificate_async")] fn request_certificate_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, callback: R, ); fn request_certificate_async_future + Clone + 'static>( &self, connection: &P, flags: TlsCertificateRequestFlags, ) -> Pin< Box_> + 'static>, >; } impl> TlsInteractionExt for O { fn ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn ask_password_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, password: &P, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn ask_password_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, password: &P, ) -> 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); }); }, )) } fn invoke_ask_password, Q: IsA>( &self, password: &P, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn invoke_request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn request_certificate, Q: IsA>( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } fn request_certificate_async< P: IsA, Q: IsA, R: FnOnce(Result) + Send + 'static, >( &self, connection: &P, flags: TlsCertificateRequestFlags, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn request_certificate_async_trampoline< R: FnOnce(Result) + Send + '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_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 _); 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_async_future + Clone + 'static>( &self, connection: &P, 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 fmt::Display for TlsInteraction { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsInteraction") } } gio-0.14.8/src/auto/tls_password.rs000064400000000000000000000142020072674642500153540ustar 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::TlsPasswordFlags; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GTlsPassword")] pub struct TlsPassword(Object); match fn { type_ => || ffi::g_tls_password_get_type(), } } impl TlsPassword { #[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, )) } } } pub const NONE_TLS_PASSWORD: Option<&TlsPassword> = None; pub trait TlsPasswordExt: 'static { #[doc(alias = "g_tls_password_get_description")] #[doc(alias = "get_description")] fn description(&self) -> glib::GString; #[doc(alias = "g_tls_password_get_flags")] #[doc(alias = "get_flags")] fn flags(&self) -> TlsPasswordFlags; #[doc(alias = "g_tls_password_get_warning")] #[doc(alias = "get_warning")] fn warning(&self) -> glib::GString; #[doc(alias = "g_tls_password_set_description")] fn set_description(&self, description: &str); #[doc(alias = "g_tls_password_set_flags")] fn set_flags(&self, flags: TlsPasswordFlags); //#[doc(alias = "g_tls_password_set_value_full")] //fn set_value_full(&self, value: &[u8]); #[doc(alias = "g_tls_password_set_warning")] fn set_warning(&self, warning: &str); #[doc(alias = "description")] fn connect_description_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "flags")] fn connect_flags_notify(&self, f: F) -> SignalHandlerId; #[doc(alias = "warning")] fn connect_warning_notify(&self, f: F) -> SignalHandlerId; } impl> TlsPasswordExt for O { fn description(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_tls_password_get_description( self.as_ref().to_glib_none().0, )) } } fn flags(&self) -> TlsPasswordFlags { unsafe { from_glib(ffi::g_tls_password_get_flags( self.as_ref().to_glib_none().0, )) } } fn warning(&self) -> glib::GString { unsafe { from_glib_none(ffi::g_tls_password_get_warning( self.as_ref().to_glib_none().0, )) } } 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, ); } } fn set_flags(&self, flags: TlsPasswordFlags) { unsafe { ffi::g_tls_password_set_flags(self.as_ref().to_glib_none().0, flags.into_glib()); } } //fn set_value_full(&self, value: &[u8]) { // unsafe { TODO: call ffi:g_tls_password_set_value_full() } //} 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, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_description_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_flags_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( notify_warning_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsPassword { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsPassword") } } gio-0.14.8/src/auto/tls_server_connection.rs000064400000000000000000000100630072674642500172400ustar 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::IOStream; use crate::TlsAuthenticationMode; use crate::TlsCertificate; use crate::TlsConnection; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use glib::ToValue; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::ptr; glib::wrapper! { #[doc(alias = "GTlsServerConnection")] pub struct TlsServerConnection(Interface) @requires TlsConnection, IOStream; match fn { type_ => || ffi::g_tls_server_connection_get_type(), } } impl TlsServerConnection { #[doc(alias = "g_tls_server_connection_new")] pub fn new, Q: IsA>( base_io_stream: &P, certificate: Option<&Q>, ) -> Result { unsafe { let mut error = 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)) } } } } pub const NONE_TLS_SERVER_CONNECTION: Option<&TlsServerConnection> = None; pub trait TlsServerConnectionExt: 'static { #[doc(alias = "authentication-mode")] fn authentication_mode(&self) -> TlsAuthenticationMode; #[doc(alias = "authentication-mode")] fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode); #[doc(alias = "authentication-mode")] fn connect_authentication_mode_notify(&self, f: F) -> SignalHandlerId; } impl> TlsServerConnectionExt for O { fn authentication_mode(&self) -> TlsAuthenticationMode { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"authentication-mode\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `authentication-mode` getter") } } fn set_authentication_mode(&self, authentication_mode: TlsAuthenticationMode) { unsafe { glib::gobject_ffi::g_object_set_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"authentication-mode\0".as_ptr() as *const _, authentication_mode.to_value().to_glib_none().0, ); } } 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(transmute::<_, unsafe extern "C" fn()>( notify_authentication_mode_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for TlsServerConnection { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("TlsServerConnection") } } gio-0.14.8/src/auto/unix_fd_list.rs000064400000000000000000000022120072674642500153150ustar 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 glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GUnixFDList")] pub struct UnixFDList(Object); match fn { type_ => || ffi::g_unix_fd_list_get_type(), } } impl UnixFDList { #[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() } } pub const NONE_UNIX_FD_LIST: Option<&UnixFDList> = None; pub trait UnixFDListExt: 'static { #[doc(alias = "g_unix_fd_list_get_length")] #[doc(alias = "get_length")] fn length(&self) -> i32; } impl> UnixFDListExt for O { fn length(&self) -> i32 { unsafe { ffi::g_unix_fd_list_get_length(self.as_ref().to_glib_none().0) } } } impl fmt::Display for UnixFDList { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("UnixFDList") } } gio-0.14.8/src/auto/unix_input_stream.rs000064400000000000000000000022220072674642500164040ustar 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::InputStream; use crate::PollableInputStream; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GUnixInputStream")] pub struct UnixInputStream(Object) @extends InputStream, @implements PollableInputStream; match fn { type_ => || ffi::g_unix_input_stream_get_type(), } } pub const NONE_UNIX_INPUT_STREAM: Option<&UnixInputStream> = None; pub trait UnixInputStreamExt: 'static { #[doc(alias = "g_unix_input_stream_get_close_fd")] #[doc(alias = "get_close_fd")] fn closes_fd(&self) -> bool; } impl> UnixInputStreamExt for O { fn closes_fd(&self) -> bool { unsafe { from_glib(ffi::g_unix_input_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for UnixInputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("UnixInputStream") } } gio-0.14.8/src/auto/unix_mount_entry.rs000064400000000000000000000010550072674642500162600ustar 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 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(), } } gio-0.14.8/src/auto/unix_mount_point.rs000064400000000000000000000117710072674642500162560ustar 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::Icon; use glib::translate::*; use std::cmp; #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] use std::mem; 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(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] #[doc(alias = "g_unix_mount_point_at")] pub fn at>(mount_path: P) -> (Option, u64) { unsafe { let mut time_read = 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(), )); let time_read = time_read.assume_init(); (ret, time_read) } } } 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 { self.compare(other).partial_cmp(&0) } } impl Ord for UnixMountPoint { #[inline] fn cmp(&self, other: &Self) -> cmp::Ordering { self.compare(other).cmp(&0) } } gio-0.14.8/src/auto/unix_output_stream.rs000064400000000000000000000022440072674642500166110ustar 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::OutputStream; use crate::PollableOutputStream; use glib::object::IsA; use glib::translate::*; use std::fmt; glib::wrapper! { #[doc(alias = "GUnixOutputStream")] pub struct UnixOutputStream(Object) @extends OutputStream, @implements PollableOutputStream; match fn { type_ => || ffi::g_unix_output_stream_get_type(), } } pub const NONE_UNIX_OUTPUT_STREAM: Option<&UnixOutputStream> = None; pub trait UnixOutputStreamExt: 'static { #[doc(alias = "g_unix_output_stream_get_close_fd")] #[doc(alias = "get_close_fd")] fn closes_fd(&self) -> bool; } impl> UnixOutputStreamExt for O { fn closes_fd(&self) -> bool { unsafe { from_glib(ffi::g_unix_output_stream_get_close_fd( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for UnixOutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("UnixOutputStream") } } gio-0.14.8/src/auto/unix_socket_address.rs000064400000000000000000000065450072674642500167030ustar 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::SocketAddress; use crate::SocketConnectable; use crate::UnixSocketAddressType; use glib::object::IsA; use glib::translate::*; use glib::StaticType; use std::fmt; 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 { //#[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 {} pub const NONE_UNIX_SOCKET_ADDRESS: Option<&UnixSocketAddress> = None; pub trait UnixSocketAddressExt: 'static { #[doc(alias = "g_unix_socket_address_get_address_type")] #[doc(alias = "get_address_type")] fn address_type(&self) -> UnixSocketAddressType; #[doc(alias = "g_unix_socket_address_get_is_abstract")] #[doc(alias = "get_is_abstract")] fn is_abstract(&self) -> bool; #[doc(alias = "g_unix_socket_address_get_path_len")] #[doc(alias = "get_path_len")] fn path_len(&self) -> usize; #[doc(alias = "path-as-array")] fn path_as_array(&self) -> Option; } impl> UnixSocketAddressExt for O { fn address_type(&self) -> UnixSocketAddressType { unsafe { from_glib(ffi::g_unix_socket_address_get_address_type( self.as_ref().to_glib_none().0, )) } } fn is_abstract(&self) -> bool { unsafe { from_glib(ffi::g_unix_socket_address_get_is_abstract( self.as_ref().to_glib_none().0, )) } } fn path_len(&self) -> usize { unsafe { ffi::g_unix_socket_address_get_path_len(self.as_ref().to_glib_none().0) } } fn path_as_array(&self) -> Option { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, b"path-as-array\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `path-as-array` getter") } } } impl fmt::Display for UnixSocketAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("UnixSocketAddress") } } gio-0.14.8/src/auto/versions.txt000064400000000000000000000002040072674642500146700ustar 00000000000000Generated by gir (https://github.com/gtk-rs/gir @ 8891a2f2c34b) from gir-files (https://github.com/gtk-rs/gir-files @ 7d95377690e9) gio-0.14.8/src/auto/vfs.rs000064400000000000000000000162270072674642500134370ustar 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::File; use glib::object::IsA; use glib::translate::*; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] use std::boxed::Box as Box_; use std::fmt; glib::wrapper! { #[doc(alias = "GVfs")] pub struct Vfs(Object); match fn { type_ => || ffi::g_vfs_get_type(), } } impl Vfs { #[doc(alias = "g_vfs_get_default")] #[doc(alias = "get_default")] 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 {} pub const NONE_VFS: Option<&Vfs> = None; pub trait VfsExt: 'static { #[doc(alias = "g_vfs_get_file_for_path")] #[doc(alias = "get_file_for_path")] fn file_for_path(&self, path: &str) -> File; #[doc(alias = "g_vfs_get_file_for_uri")] #[doc(alias = "get_file_for_uri")] fn file_for_uri(&self, uri: &str) -> File; #[doc(alias = "g_vfs_get_supported_uri_schemes")] #[doc(alias = "get_supported_uri_schemes")] fn supported_uri_schemes(&self) -> Vec; #[doc(alias = "g_vfs_is_active")] fn is_active(&self) -> bool; #[doc(alias = "g_vfs_parse_name")] fn parse_name(&self, parse_name: &str) -> File; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[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; #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] #[doc(alias = "g_vfs_unregister_uri_scheme")] fn unregister_uri_scheme(&self, scheme: &str) -> bool; } impl> VfsExt for O { 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, )) } } 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, )) } } 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, )) } } fn is_active(&self) -> bool { unsafe { from_glib(ffi::g_vfs_is_active(self.as_ref().to_glib_none().0)) } } 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, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] 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: &Option File + 'static>> = &*(user_data as *mut _); let res = if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") }; res.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: &Option File + 'static>> = &*(user_data as *mut _); let res = if let Some(ref callback) = *callback { callback(&vfs, identifier.as_str()) } else { panic!("cannot get closure...") }; res.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_ File + 'static>>> = Box_::from_raw(data as *mut _); } let destroy_call4 = Some(uri_destroy_func as _); unsafe extern "C" fn parse_name_destroy_func(data: glib::ffi::gpointer) { let _callback: Box_ File + 'static>>> = Box_::from_raw(data as *mut _); } 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, )) } } #[cfg(any(feature = "v2_50", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_50")))] 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 fmt::Display for Vfs { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Vfs") } } gio-0.14.8/src/auto/volume.rs000064400000000000000000000274670072674642500141600ustar 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::AsyncResult; use crate::Cancellable; use crate::Drive; use crate::File; use crate::Icon; use crate::Mount; use crate::MountMountFlags; use crate::MountOperation; use crate::MountUnmountFlags; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; use std::pin::Pin; use std::ptr; glib::wrapper! { #[doc(alias = "GVolume")] pub struct Volume(Interface); match fn { type_ => || ffi::g_volume_get_type(), } } pub const NONE_VOLUME: Option<&Volume> = None; pub trait VolumeExt: 'static { #[doc(alias = "g_volume_can_eject")] fn can_eject(&self) -> bool; #[doc(alias = "g_volume_can_mount")] fn can_mount(&self) -> bool; #[doc(alias = "g_volume_eject_with_operation")] fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn eject_with_operation_future + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_volume_enumerate_identifiers")] fn enumerate_identifiers(&self) -> Vec; #[doc(alias = "g_volume_get_activation_root")] #[doc(alias = "get_activation_root")] fn activation_root(&self) -> Option; #[doc(alias = "g_volume_get_drive")] #[doc(alias = "get_drive")] fn drive(&self) -> Option; #[doc(alias = "g_volume_get_icon")] #[doc(alias = "get_icon")] fn icon(&self) -> Icon; #[doc(alias = "g_volume_get_identifier")] #[doc(alias = "get_identifier")] fn identifier(&self, kind: &str) -> Option; #[doc(alias = "g_volume_get_mount")] fn get_mount(&self) -> Option; #[doc(alias = "g_volume_get_name")] #[doc(alias = "get_name")] fn name(&self) -> glib::GString; #[doc(alias = "g_volume_get_sort_key")] #[doc(alias = "get_sort_key")] fn sort_key(&self) -> Option; #[doc(alias = "g_volume_get_symbolic_icon")] #[doc(alias = "get_symbolic_icon")] fn symbolic_icon(&self) -> Icon; #[doc(alias = "g_volume_get_uuid")] #[doc(alias = "get_uuid")] fn uuid(&self) -> Option; #[doc(alias = "g_volume_mount")] fn mount< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ); fn mount_future + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> Pin> + 'static>>; #[doc(alias = "g_volume_should_automount")] fn should_automount(&self) -> bool; #[doc(alias = "changed")] fn connect_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "removed")] fn connect_removed(&self, f: F) -> SignalHandlerId; } impl> VolumeExt for O { fn can_eject(&self) -> bool { unsafe { from_glib(ffi::g_volume_can_eject(self.as_ref().to_glib_none().0)) } } fn can_mount(&self) -> bool { unsafe { from_glib(ffi::g_volume_can_mount(self.as_ref().to_glib_none().0)) } } fn eject_with_operation< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn eject_with_operation_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountUnmountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn enumerate_identifiers(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_enumerate_identifiers( self.as_ref().to_glib_none().0, )) } } fn activation_root(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_activation_root( self.as_ref().to_glib_none().0, )) } } fn drive(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_drive(self.as_ref().to_glib_none().0)) } } fn icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_volume_get_icon(self.as_ref().to_glib_none().0)) } } 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, )) } } fn get_mount(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_mount(self.as_ref().to_glib_none().0)) } } fn name(&self) -> glib::GString { unsafe { from_glib_full(ffi::g_volume_get_name(self.as_ref().to_glib_none().0)) } } fn sort_key(&self) -> Option { unsafe { from_glib_none(ffi::g_volume_get_sort_key(self.as_ref().to_glib_none().0)) } } fn symbolic_icon(&self) -> Icon { unsafe { from_glib_full(ffi::g_volume_get_symbolic_icon( self.as_ref().to_glib_none().0, )) } } fn uuid(&self) -> Option { unsafe { from_glib_full(ffi::g_volume_get_uuid(self.as_ref().to_glib_none().0)) } } fn mount< P: IsA, Q: IsA, R: FnOnce(Result<(), glib::Error>) + Send + 'static, >( &self, flags: MountMountFlags, mount_operation: Option<&P>, cancellable: Option<&Q>, callback: R, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn mount_trampoline< R: FnOnce(Result<(), glib::Error>) + Send + '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_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 _); 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 + Clone + 'static>( &self, flags: MountMountFlags, mount_operation: Option<&P>, ) -> 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); }, ); }, )) } fn should_automount(&self) -> bool { unsafe { from_glib(ffi::g_volume_should_automount( self.as_ref().to_glib_none().0, )) } } 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(transmute::<_, unsafe extern "C" fn()>( changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for Volume { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Volume") } } gio-0.14.8/src/auto/volume_monitor.rs000064400000000000000000000376200072674642500157170ustar 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::Drive; use crate::Mount; use crate::Volume; use glib::object::Cast; use glib::object::IsA; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; glib::wrapper! { #[doc(alias = "GVolumeMonitor")] pub struct VolumeMonitor(Object); match fn { type_ => || ffi::g_volume_monitor_get_type(), } } impl VolumeMonitor { #[doc(alias = "g_volume_monitor_get")] pub fn get() -> VolumeMonitor { unsafe { from_glib_full(ffi::g_volume_monitor_get()) } } } pub const NONE_VOLUME_MONITOR: Option<&VolumeMonitor> = None; pub trait VolumeMonitorExt: 'static { #[doc(alias = "g_volume_monitor_get_connected_drives")] #[doc(alias = "get_connected_drives")] fn connected_drives(&self) -> Vec; #[doc(alias = "g_volume_monitor_get_mount_for_uuid")] #[doc(alias = "get_mount_for_uuid")] fn mount_for_uuid(&self, uuid: &str) -> Option; #[doc(alias = "g_volume_monitor_get_mounts")] #[doc(alias = "get_mounts")] fn mounts(&self) -> Vec; #[doc(alias = "g_volume_monitor_get_volume_for_uuid")] #[doc(alias = "get_volume_for_uuid")] fn volume_for_uuid(&self, uuid: &str) -> Option; #[doc(alias = "g_volume_monitor_get_volumes")] #[doc(alias = "get_volumes")] fn volumes(&self) -> Vec; #[doc(alias = "drive-changed")] fn connect_drive_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "drive-connected")] fn connect_drive_connected(&self, f: F) -> SignalHandlerId; #[doc(alias = "drive-disconnected")] fn connect_drive_disconnected(&self, f: F) -> SignalHandlerId; #[doc(alias = "drive-eject-button")] fn connect_drive_eject_button(&self, f: F) -> SignalHandlerId; #[doc(alias = "drive-stop-button")] fn connect_drive_stop_button(&self, f: F) -> SignalHandlerId; #[doc(alias = "mount-added")] fn connect_mount_added(&self, f: F) -> SignalHandlerId; #[doc(alias = "mount-changed")] fn connect_mount_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "mount-pre-unmount")] fn connect_mount_pre_unmount(&self, f: F) -> SignalHandlerId; #[doc(alias = "mount-removed")] fn connect_mount_removed(&self, f: F) -> SignalHandlerId; #[doc(alias = "volume-added")] fn connect_volume_added(&self, f: F) -> SignalHandlerId; #[doc(alias = "volume-changed")] fn connect_volume_changed(&self, f: F) -> SignalHandlerId; #[doc(alias = "volume-removed")] fn connect_volume_removed(&self, f: F) -> SignalHandlerId; } impl> VolumeMonitorExt for O { fn connected_drives(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_connected_drives( self.as_ref().to_glib_none().0, )) } } 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, )) } } fn mounts(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_mounts( self.as_ref().to_glib_none().0, )) } } 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, )) } } fn volumes(&self) -> Vec { unsafe { FromGlibPtrContainer::from_glib_full(ffi::g_volume_monitor_get_volumes( self.as_ref().to_glib_none().0, )) } } 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(transmute::<_, unsafe extern "C" fn()>( drive_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( drive_connected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( drive_disconnected_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( drive_eject_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( drive_stop_button_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( mount_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( mount_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( mount_pre_unmount_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( mount_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( volume_added_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( volume_changed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } 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(transmute::<_, unsafe extern "C" fn()>( volume_removed_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for VolumeMonitor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("VolumeMonitor") } } gio-0.14.8/src/auto/zlib_compressor.rs000064400000000000000000000065740072674642500160610ustar 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::Converter; use crate::FileInfo; use crate::ZlibCompressorFormat; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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")] 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")] 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"format\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `format` getter") } } pub fn level(&self) -> i32 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"level\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `level` getter") } } #[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(transmute::<_, unsafe extern "C" fn()>( notify_file_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ZlibCompressor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ZlibCompressor") } } gio-0.14.8/src/auto/zlib_decompressor.rs000064400000000000000000000053210072674642500163570ustar 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::Converter; use crate::FileInfo; use crate::ZlibCompressorFormat; use glib::object::ObjectType as ObjectType_; use glib::signal::connect_raw; use glib::signal::SignalHandlerId; use glib::translate::*; use glib::StaticType; use std::boxed::Box as Box_; use std::fmt; use std::mem::transmute; 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")] 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 { unsafe { let mut value = glib::Value::from_type(::static_type()); glib::gobject_ffi::g_object_get_property( self.as_ptr() as *mut glib::gobject_ffi::GObject, b"format\0".as_ptr() as *const _, value.to_glib_none_mut().0, ); value .get() .expect("Return Value for property `format` getter") } } #[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(transmute::<_, unsafe extern "C" fn()>( notify_file_info_trampoline:: as *const (), )), Box_::into_raw(f), ) } } } impl fmt::Display for ZlibDecompressor { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("ZlibDecompressor") } } gio-0.14.8/src/cancellable.rs000064400000000000000000000004360072674642500141110ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; #[test] fn check_callback() { let c = crate::Cancellable::new(); c.connect_cancelled(|_| {}); c.cancel(); // if it doesn't crash at this point, then we're good to go! } gio-0.14.8/src/converter.rs000064400000000000000000000037660072674642500137040ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Converter; use crate::ConverterFlags; use crate::ConverterResult; use glib::object::IsA; use glib::translate::*; use std::mem; use std::ptr; pub trait ConverterExtManual { #[doc(alias = "g_converter_convert")] fn convert, OUT: AsMut<[u8]>>( &self, inbuf: IN, outbuf: OUT, flags: ConverterFlags, ) -> Result<(ConverterResult, usize, usize), glib::Error>; } impl> ConverterExtManual for O { #[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)) } } } } gio-0.14.8/src/data_input_stream.rs000064400000000000000000000373310072674642500153730ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Cancellable; use crate::DataInputStream; use glib::object::IsA; use glib::translate::*; use glib::GString; use std::boxed::Box as Box_; use std::mem; use std::pin::Pin; use std::ptr; pub trait DataInputStreamExtManual: 'static { #[doc(alias = "g_data_input_stream_read_line")] fn read_line>( &self, cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_data_input_stream_read_line_async")] fn read_line_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn read_line_async_future( &self, io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>>; #[doc(alias = "g_data_input_stream_read_line_utf8")] fn read_line_utf8>( &self, cancellable: Option<&P>, ) -> Result, glib::Error>; fn read_line_utf8_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn read_line_utf8_async_future( &self, io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>>; #[cfg_attr(feature = "v2_56", deprecated)] #[doc(alias = "g_data_input_stream_read_until")] fn read_until>( &self, stop_chars: &[u8], cancellable: Option<&P>, ) -> Result, glib::Error>; #[cfg_attr(feature = "v2_56", deprecated)] #[doc(alias = "g_data_input_stream_read_until_async")] fn read_until_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, stop_chars: &[u8], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); #[cfg_attr(feature = "v2_56", deprecated)] fn read_until_async_future( &self, stop_chars: &[u8], io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>>; #[doc(alias = "g_data_input_stream_read_upto")] fn read_upto>( &self, stop_chars: &[u8], cancellable: Option<&P>, ) -> Result, glib::Error>; #[doc(alias = "g_data_input_stream_read_upto_async")] fn read_upto_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, stop_chars: &[u8], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn read_upto_async_future( &self, stop_chars: &[u8], io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>>; } impl> DataInputStreamExtManual for O { 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)) } } } fn read_line_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_line_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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 _); 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_async_future( &self, io_priority: glib::Priority, ) -> Pin, 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); }); }, )) } 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>) + Send + 'static, >( &self, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_line_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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 _); 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_async_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); }); }, )) } fn read_until>( &self, stop_chars: &[u8], cancellable: Option<&P>, ) -> Result, glib::Error> { // Need to ensure that it does not contain a NUL byte and then NUL-terminate it ourselves assert!(!stop_chars.contains(&b'0')); let stop_chars = stop_chars .iter() .copied() .chain(std::iter::once(b'0')) .collect::>(); unsafe { let mut error = ptr::null_mut(); let mut length = mem::MaybeUninit::uninit(); let ret = ffi::g_data_input_stream_read_until( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0 as *const _, 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 as *const u8, length, )) } else { Err(from_glib_full(error)) } } } fn read_until_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, stop_chars: &[u8], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_until_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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_until_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 *const _, length, )) } else { Err(from_glib_full(error)) }; let callback: Box_ = Box_::from_raw(user_data as *mut _); callback(result); } // Need to ensure that it does not contain a NUL byte and then NUL-terminate it ourselves assert!(!stop_chars.contains(&b'0')); let stop_chars = stop_chars .iter() .copied() .chain(std::iter::once(b'0')) .collect::>(); let callback = read_until_async_trampoline::; unsafe { ffi::g_data_input_stream_read_until_async( self.as_ref().to_glib_none().0, stop_chars.to_glib_none().0 as *const _, 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_until_async_future( &self, stop_chars: &[u8], io_priority: glib::Priority, ) -> Pin, glib::Error>> + 'static>> { let stop_chars = Vec::from(stop_chars); Box_::pin(crate::GioFuture::new( self, move |obj, cancellable, send| { obj.read_until_async(&stop_chars, io_priority, Some(cancellable), move |res| { send.resolve(res); }); }, )) } 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 *const _, length, )) } else { Err(from_glib_full(error)) } } } fn read_upto_async< P: IsA, Q: FnOnce(Result, glib::Error>) + Send + 'static, >( &self, stop_chars: &[u8], io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let stop_chars_len = stop_chars.len() as isize; let user_data: Box_ = Box_::new(callback); unsafe extern "C" fn read_upto_async_trampoline< Q: FnOnce(Result, glib::Error>) + Send + '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 *const _, length, )) } else { Err(from_glib_full(error)) }; let callback: Box_ = Box_::from_raw(user_data as *mut _); 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_async_future( &self, stop_chars: &[u8], io_priority: glib::Priority, ) -> Pin, 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); }); }, )) } } gio-0.14.8/src/dbus.rs000064400000000000000000000120530072674642500126170ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::BusNameOwnerFlags; use crate::BusNameWatcherFlags; use crate::BusType; use crate::DBusConnection; use glib::translate::*; use std::num::NonZeroU32; #[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) + Send + Sync + 'static, { glib::Closure::new(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) + Send + Sync + 'static, { glib::Closure::new(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) + Send + Sync + 'static, { glib::Closure::new(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) + Send + Sync + 'static, NameLost: Fn(DBusConnection, &str) + Send + Sync + '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) + Send + Sync + 'static, NameAcquired: Fn(DBusConnection, &str) + Send + Sync + 'static, NameLost: Fn(Option, &str) + Send + Sync + '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(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) + Send + Sync + 'static, NameVanished: Fn(DBusConnection, &str) + Send + Sync + '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) + Send + Sync + 'static, NameVanished: Fn(DBusConnection, &str) + Send + Sync + '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.14.8/src/dbus_connection.rs000064400000000000000000000300360072674642500150370ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ActionGroup; use crate::DBusConnection; use crate::DBusInterfaceInfo; use crate::DBusMessage; use crate::DBusMethodInvocation; use crate::DBusSignalFlags; use crate::MenuModel; use glib::object::IsA; use glib::translate::*; use std::boxed::Box as Box_; use std::num::NonZeroU32; #[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); impl DBusConnection { #[doc(alias = "g_dbus_connection_register_object_with_closures")] pub fn register_object( &self, object_path: &str, interface_info: &DBusInterfaceInfo, method_call: MethodCall, get_property: GetProperty, set_property: SetProperty, ) -> Result where MethodCall: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant, DBusMethodInvocation) + Send + Sync + 'static, GetProperty: Fn(DBusConnection, &str, &str, &str, &str) -> glib::Variant + Send + Sync + 'static, SetProperty: Fn(DBusConnection, &str, &str, &str, &str, glib::Variant) -> bool + Send + Sync + 'static, { use glib::ToValue; unsafe { let mut error = std::ptr::null_mut(); let id = ffi::g_dbus_connection_register_object_with_closures( self.to_glib_none().0, object_path.to_glib_none().0, interface_info.to_glib_none().0, glib::Closure::new(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(); method_call( conn, sender, object_path, interface_name, method_name, parameters, invocation, ); None }) .to_glib_none() .0, glib::Closure::new(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 = get_property(conn, sender, object_path, interface_name, property_name); Some(result.to_value()) }) .to_glib_none() .0, glib::Closure::new(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 = set_property( conn, sender, object_path, interface_name, property_name, value, ); 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)) } } } #[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.to_glib_full() } 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")] 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.14.8/src/dbus_message.rs000064400000000000000000000004120072674642500143170ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::DBusMessage; use std::fmt; impl fmt::Display for DBusMessage { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.print(0)) } } gio-0.14.8/src/dbus_method_invocation.rs000064400000000000000000000016050072674642500164110ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::DBusMethodInvocation; use glib::error::ErrorDomain; use glib::translate::*; 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.14.8/src/desktop_app_info.rs000064400000000000000000000125650072674642500152160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] use crate::AppLaunchContext; use crate::DesktopAppInfo; use glib::object::IsA; use glib::translate::*; #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] use glib::Error; use glib::GString; #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] use std::boxed::Box as Box_; #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] use std::ptr; #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] use std::os::unix::io::AsRawFd; 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 } } } pub trait DesktopAppInfoExtManual { #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] #[cfg_attr(feature = "dox", 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>; } impl> DesktopAppInfoExtManual for O { #[cfg(any(all(feature = "v2_58", unix), all(unix, feature = "dox")))] #[cfg_attr(feature = "dox", doc(cfg(all(feature = "v2_58", unix))))] 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: *mut Option<&mut dyn (FnMut(&DesktopAppInfo, glib::Pid))> = user_data as *const _ as usize 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 usize 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)) } } } } gio-0.14.8/src/error.rs000064400000000000000000000024210072674642500130110ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::IOErrorEnum; use std::io; 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), }) } gio-0.14.8/src/file.rs000064400000000000000000000163700072674642500126070ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Cancellable; use crate::File; use crate::FileCreateFlags; use crate::FileEnumerator; use crate::FileQueryInfoFlags; use glib::object::IsA; use glib::translate::*; use std::pin::Pin; use std::ptr; pub trait FileExtManual: 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)>) + Send + 'static, C: IsA, >( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&C>, callback: R, ); fn replace_contents_async_future + Send + 'static>( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, ) -> Pin< Box< dyn std::future::Future> + 'static, >, >; #[doc(alias = "g_file_enumerate_children_async")] fn enumerate_children_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &'static str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ); fn enumerate_children_async_future( &self, attributes: &'static str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>>; } impl> FileExtManual for O { fn replace_contents_async< B: AsRef<[u8]> + Send + 'static, R: FnOnce(Result<(B, glib::GString), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, contents: B, etag: Option<&str>, make_backup: bool, flags: FileCreateFlags, cancellable: Option<&C>, callback: R, ) { let etag = etag.to_glib_none(); let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((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).as_ref().unwrap().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)>) + Send + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, contents) = user_data.take().unwrap(); 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_async_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); }, ); }, )) } fn enumerate_children_async< P: IsA, Q: FnOnce(Result) + Send + 'static, >( &self, attributes: &'static str, flags: FileQueryInfoFlags, io_priority: glib::Priority, cancellable: Option<&P>, callback: Q, ) { let user_data: Box = Box::new(callback); unsafe extern "C" fn create_async_trampoline< Q: FnOnce(Result) + Send + '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 _); 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_async_future( &self, attributes: &'static str, flags: FileQueryInfoFlags, io_priority: glib::Priority, ) -> Pin> + 'static>> { 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); }, ); }, )) } } gio-0.14.8/src/file_attribute_matcher.rs000064400000000000000000000014250072674642500163700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::*; use glib::GString; use std::iter::{IntoIterator, Iterator}; 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 IntoIterator for crate::FileAttributeMatcher { type Item = GString; type IntoIter = FileAttributematcherIter; fn into_iter(self) -> Self::IntoIter { FileAttributematcherIter(self) } } gio-0.14.8/src/file_enumerator.rs000064400000000000000000000007510072674642500150440ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::FileEnumerator; use crate::FileInfo; use std::iter::Iterator; impl Iterator for FileEnumerator { type Item = Result; fn next(&mut self) -> Option> { match self.next_file(crate::NONE_CANCELLABLE) { Err(err) => Some(Err(err)), Ok(file_info) => file_info.map(Ok), } } } gio-0.14.8/src/file_info.rs000064400000000000000000000032330072674642500136140ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::FileInfo; use glib::translate::*; use std::mem; use std::time::{Duration, SystemTime}; 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 _, }), ); } } } gio-0.14.8/src/flags.rs000064400000000000000000000003140072674642500127530ustar 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.14.8/src/gio_future.rs000064400000000000000000000112470072674642500140360ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use futures_channel::oneshot; use futures_core::task::{Context, Poll}; use std::future::Future; use std::pin::{self, Pin}; use crate::prelude::*; use crate::Cancellable; pub struct GioFuture { obj: O, schedule_operation: Option, cancellable: Option, receiver: Option>>, } pub struct GioFutureResult { sender: ThreadGuard>>, } unsafe impl Send for GioFutureResult {} impl GioFutureResult { pub fn resolve(self, res: Result) { let _ = self.sender.into_inner().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 = Result; 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: ThreadGuard::new(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 Drop for GioFuture { fn drop(&mut self) { if let Some(cancellable) = self.cancellable.take() { cancellable.cancel(); } let _ = self.receiver.take(); } } impl Unpin for GioFuture {} // Actual thread IDs can be reused by the OS once the old thread finished. // This works around it by using our own counter for threads. // // Taken from the fragile crate use std::sync::atomic::{AtomicUsize, Ordering}; fn next_thread_id() -> usize { static mut COUNTER: AtomicUsize = AtomicUsize::new(0); unsafe { COUNTER.fetch_add(1, Ordering::SeqCst) } } #[doc(alias = "get_thread_id")] fn thread_id() -> usize { thread_local!(static THREAD_ID: usize = next_thread_id()); THREAD_ID.with(|&x| x) } // Taken from glib-rs, but we don't want this to be public API struct ThreadGuard { thread_id: usize, value: Option, } impl ThreadGuard { fn new(value: T) -> Self { Self { thread_id: thread_id(), value: Some(value), } } fn into_inner(mut self) -> T { if self.thread_id != thread_id() { panic!("Value accessed from different thread than where it was created"); } self.value.take().expect("into_inner() called twice") } } impl Drop for ThreadGuard { fn drop(&mut self) { if self.thread_id != thread_id() { panic!("Value dropped on a different thread than where it was created"); } } } unsafe impl Send for ThreadGuard {} gio-0.14.8/src/inet_address.rs000064400000000000000000000052570072674642500143360ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::InetAddress; use crate::SocketFamily; use glib::object::IsA; use glib::translate::*; use std::net::{IpAddr, Ipv4Addr, Ipv6Addr}; #[derive(Debug)] pub enum InetAddressBytes<'a> { V4(&'a [u8; 4]), V6(&'a [u8; 16]), } impl<'a> InetAddressBytes<'a> { 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(), )) } } } pub trait InetAddressExtManual { #[doc(alias = "g_inet_address_to_bytes")] fn to_bytes(&self) -> Option>; } impl> InetAddressExtManual for O { // 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")] 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 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.14.8/src/inet_socket_address.rs000064400000000000000000000007650072674642500157050ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::InetAddress; use crate::InetSocketAddress; use std::net::SocketAddr; impl From for InetSocketAddress { fn from(addr: SocketAddr) -> Self { Self::new::(&addr.ip().into(), addr.port()) } } impl From for SocketAddr { fn from(addr: InetSocketAddress) -> Self { Self::new(addr.address().into(), addr.port()) } } gio-0.14.8/src/initable.rs000064400000000000000000000015610072674642500134530ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::traits::InitableExt; use crate::Cancellable; use crate::Initable; use glib::object::IsA; use glib::object::IsClass; use glib::value::ToValue; use glib::Object; impl Initable { #[allow(clippy::new_ret_no_self)] pub fn new + IsA, P: IsA>( properties: &[(&str, &dyn ToValue)], cancellable: Option<&P>, ) -> Result { let object = Object::new::(properties)?; unsafe { object.init(cancellable)? }; Ok(object) } } #[derive(thiserror::Error, Debug)] pub enum InitableError { #[error("Object::new failed with {0:?}")] NewObjectFailed(#[from] glib::error::BoolError), #[error("Initable::init failed with {0:?}")] InitFailed(#[from] glib::Error), } gio-0.14.8/src/input_stream.rs000064400000000000000000000526410072674642500144030ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::error::to_std_io_result; use crate::prelude::*; use crate::Cancellable; use crate::InputStream; use crate::Seekable; use futures_core::task::{Context, Poll}; use futures_io::{AsyncBufRead, AsyncRead}; use glib::object::IsA; use glib::translate::*; use glib::Priority; use std::future::Future; use std::io; use std::mem; use std::pin::Pin; use std::ptr; pub trait InputStreamExtManual: Sized { #[doc(alias = "g_input_stream_read")] fn read, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result; #[doc(alias = "g_input_stream_read_all")] fn read_all, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result<(usize, Option), glib::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)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ); #[doc(alias = "g_input_stream_read_async")] fn read_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ); fn read_all_async_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin< Box< dyn std::future::Future< Output = Result<(B, usize, Option), (B, glib::Error)>, > + 'static, >, >; fn read_async_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin> + 'static>>; 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 { 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)) } } } 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)) } } } fn read_all_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let mut user_data: Box> = Box::new(Some((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).as_mut().unwrap().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)>) + Send + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); 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 _, ); } } fn read_async< B: AsMut<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let mut user_data: Box> = Box::new(Some((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).as_mut().unwrap().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)>) + Send + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); 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_async_future<'a, B: AsMut<[u8]> + 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_async_future<'a, B: AsMut<[u8]> + 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); }); }, )) } } #[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::NONE_CANCELLABLE); 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::NONE_CANCELLABLE) .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_async_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(); 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 {} bytes as only {} are available", amt, 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(thiserror::Error, Debug)] enum BufReadError { #[error("Previous read operation failed")] 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 crate::prelude::*; use crate::test_util::run_async; use crate::MemoryInputStream; use glib::Bytes; use std::io::Read; #[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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE).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::NONE_CANCELLABLE); 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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.14.8/src/io_stream.rs000064400000000000000000000052550072674642500136520ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::IOStream; use crate::InputStreamAsyncRead; use crate::OutputStreamAsyncWrite; use crate::PollableInputStream; use crate::PollableOutputStream; use futures_core::task::{Context, Poll}; use futures_io::{AsyncRead, AsyncWrite}; use glib::object::{Cast, IsA}; use std::io; use std::pin::Pin; pub trait IOStreamExtManual: 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.14.8/src/lib.rs000064400000000000000000000063310072674642500124320ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. //! # Rust GIO bindings //! //! This library contains safe Rust bindings for [GIO](https://developer.gnome.org/gio/). //! It is a part of [gtk-rs](https://gtk-rs.org/). //! //! GIO 2.48 is the lowest supported version for the underlying library. #![cfg_attr(feature = "dox", feature(doc_cfg))] #![allow(clippy::type_complexity)] #![allow(clippy::too_many_arguments)] #![allow(clippy::missing_safety_doc)] #![allow(clippy::upper_case_acronyms)] pub use ffi; pub use glib; mod app_info; mod application; #[cfg(test)] mod cancellable; mod converter; mod data_input_stream; 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; #[cfg(any(all(not(windows), not(target_os = "macos")), feature = "dox"))] mod desktop_app_info; mod error; mod file; mod file_attribute_matcher; pub use crate::file_attribute_matcher::FileAttributematcherIter; mod file_enumerator; 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_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::{compile_resources, resources_register_include_impl}; mod settings; pub use crate::settings::BindingBuilder; mod socket; mod subprocess; mod subprocess_launcher; mod threaded_socket_service; #[cfg(any(unix, feature = "dox"))] mod unix_fd_list; #[cfg(any(unix, feature = "dox"))] mod unix_input_stream; #[cfg(any(unix, feature = "dox"))] #[cfg(any(feature = "v2_54", feature = "dox"))] mod unix_mount_entry; #[cfg(any(unix, feature = "dox"))] #[cfg(any(feature = "v2_54", feature = "dox"))] mod unix_mount_point; #[cfg(any(unix, feature = "dox"))] mod unix_output_stream; #[cfg(any(unix, feature = "dox"))] mod unix_socket_address; #[cfg(test)] mod test_util; pub use crate::auto::functions::*; pub use crate::auto::*; pub mod prelude; #[allow(clippy::wrong_self_convention)] #[allow(clippy::new_ret_no_self)] #[allow(clippy::let_and_return)] #[allow(unused_imports)] mod auto; mod gio_future; pub use crate::gio_future::*; #[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 tls_connection; pub mod task; #[cfg(target_family = "windows")] mod win32_input_stream; #[cfg(target_family = "windows")] pub use self::win32_input_stream::{Win32InputStream, NONE_WIN32_INPUT_STREAM}; #[cfg(target_family = "windows")] mod win32_output_stream; #[cfg(target_family = "windows")] pub use self::win32_output_stream::{Win32OutputStream, NONE_WIN32_OUTPUT_STREAM}; gio-0.14.8/src/list_store.rs000064400000000000000000000044050072674642500140530ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ListStore; use glib::translate::*; use glib::{IsA, Object}; use std::cmp::Ordering; pub trait ListStoreExtManual { #[doc(alias = "g_list_store_insert_sorted")] fn insert_sorted, F: FnMut(&Object, &Object) -> Ordering>( &self, item: &P, compare_func: F, ) -> u32; #[doc(alias = "g_list_store_sort")] fn sort Ordering>(&self, compare_func: F); } impl> ListStoreExtManual for O { 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.as_ref().to_glib_none().0, item.as_ref().to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } 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.as_ref().to_glib_none().0, Some(compare_func_trampoline), func_ptr, ) } } } 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); match (*func)(&a, &b) { Ordering::Less => -1, Ordering::Equal => 0, Ordering::Greater => 1, } } gio-0.14.8/src/memory_input_stream.rs000064400000000000000000000121340072674642500157640ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(test)] mod tests { use crate::prelude::*; use crate::MemoryInputStream; use futures_util::io::{AsyncBufReadExt, AsyncReadExt}; use glib::Bytes; use std::error::Error; #[test] fn new() { let strm = MemoryInputStream::new(); let ret = strm.skip(1, crate::NONE_CANCELLABLE); assert!(!ret.is_err()); assert_eq!(ret.unwrap(), 0); let mut buf = vec![0; 10]; let ret = strm.read(&mut buf, crate::NONE_CANCELLABLE).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::NONE_CANCELLABLE).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::NONE_CANCELLABLE).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::NONE_CANCELLABLE).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::NONE_CANCELLABLE).unwrap(); assert_eq!(ret, 0); } #[test] fn read_async_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_async_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.14.8/src/memory_output_stream.rs000064400000000000000000000015610072674642500161670ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(test)] mod tests { use crate::prelude::*; use crate::MemoryOutputStream; #[test] fn steal_empty() { let strm = MemoryOutputStream::new_resizable(); assert_eq!(strm.data_size(), 0); assert!(strm.close(crate::NONE_CANCELLABLE).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::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.data_size(), 3); assert!(strm.write(&[4, 5], crate::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.data_size(), 5); assert!(strm.close(crate::NONE_CANCELLABLE).is_ok()); assert_eq!(strm.steal_as_bytes(), [1, 2, 3, 4, 5].as_ref()); } } gio-0.14.8/src/output_stream.rs000064400000000000000000000322350072674642500146010ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::error::to_std_io_result; use crate::prelude::*; use crate::Cancellable; use crate::OutputStream; use crate::Seekable; use glib::object::IsA; use glib::translate::*; use glib::Priority; use std::io; use std::mem; use std::pin::Pin; use std::ptr; pub trait OutputStreamExtManual: Sized + OutputStreamExt { #[doc(alias = "g_output_stream_write_async")] fn write_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ); #[doc(alias = "g_output_stream_write_all")] fn write_all>( &self, buffer: &[u8], cancellable: Option<&C>, ) -> Result<(usize, Option), glib::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)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ); fn write_async_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin> + 'static>>; fn write_all_async_future + Send + 'static>( &self, buffer: B, io_priority: Priority, ) -> Pin< Box< dyn std::future::Future< Output = Result<(B, usize, Option), (B, glib::Error)>, > + 'static, >, >; fn into_write(self) -> OutputStreamWrite where Self: IsA, { OutputStreamWrite(self) } } impl> OutputStreamExtManual for O { fn write_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((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).as_ref().unwrap().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)>) + Send + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); 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 _, ); } } 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() as usize; 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)) } } } fn write_all_async< B: AsRef<[u8]> + Send + 'static, Q: FnOnce(Result<(B, usize, Option), (B, glib::Error)>) + Send + 'static, C: IsA, >( &self, buffer: B, io_priority: Priority, cancellable: Option<&C>, callback: Q, ) { let cancellable = cancellable.map(|c| c.as_ref()); let gcancellable = cancellable.to_glib_none(); let user_data: Box> = Box::new(Some((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).as_ref().unwrap().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)>) + Send + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let mut user_data: Box> = Box::from_raw(user_data as *mut _); let (callback, buffer) = user_data.take().unwrap(); 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_async_future<'a, B: AsRef<[u8]> + 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_async_future<'a, B: AsRef<[u8]> + 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); }); }, )) } } #[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::NONE_CANCELLABLE) .map(|size| size as usize); to_std_io_result(result) } fn flush(&mut self) -> io::Result<()> { let gio_result = self.0.as_ref().flush(crate::NONE_CANCELLABLE); 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::NONE_CANCELLABLE) .map(|_| seekable.tell() as u64); to_std_io_result(gio_result) } } #[cfg(test)] mod tests { use crate::prelude::*; use crate::test_util::run_async; use crate::MemoryInputStream; use crate::MemoryOutputStream; use glib::Bytes; use std::io::Write; #[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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE).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); } } gio-0.14.8/src/pollable_input_stream.rs000064400000000000000000000165310072674642500162530ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::Cancellable; use crate::PollableInputStream; use futures_core::task::{Context, Poll}; use futures_io::AsyncRead; use glib::object::{Cast, IsA}; use glib::translate::*; use std::cell::RefCell; use std::io; use std::mem::transmute; use std::ptr; use futures_core::stream::Stream; use std::pin::Pin; pub trait PollableInputStreamExtManual: 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::Continue + 'static, C: IsA; fn create_source_future>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; fn create_source_stream>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; #[doc(alias = "g_pollable_input_stream_read_nonblocking")] fn read_nonblocking>( &self, buffer: &mut [u8], cancellable: Option<&C>, ) -> Result; fn into_async_read(self) -> Result, Self> where Self: IsA, { if self.can_poll() { Ok(InputStreamAsyncRead(self)) } else { Err(self) } } } impl> PollableInputStreamExtManual for O { fn create_source( &self, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O) -> glib::Continue + '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(); (&mut *func)(PollableInputStream::from_glib_borrow(stream).unsafe_cast_ref()) .into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { 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::< _, 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 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() as usize; 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 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::Continue(false) }) })) } 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::Continue(false) } else { glib::Continue(true) } }) })) } } #[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::NONE_CANCELLABLE); match gio_result { Ok(size) => Poll::Ready(Ok(size as usize)), Err(err) => { let kind = err.kind::().unwrap(); if kind == crate::IOErrorEnum::WouldBlock { let mut waker = Some(cx.waker().clone()); let source = stream.0.as_ref().create_source( crate::NONE_CANCELLABLE, None, glib::PRIORITY_DEFAULT, move |_| { if let Some(waker) = waker.take() { waker.wake(); } glib::Continue(false) }, ); 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.14.8/src/pollable_output_stream.rs000064400000000000000000000206570072674642500164600ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::error::to_std_io_result; use crate::prelude::*; use crate::Cancellable; use crate::PollableOutputStream; use futures_channel::oneshot; use futures_core::task::{Context, Poll}; use futures_core::Future; use futures_io::AsyncWrite; use glib::object::{Cast, IsA}; use glib::translate::*; use std::cell::RefCell; use std::io; use std::mem::transmute; use std::pin::Pin; use futures_core::stream::Stream; pub trait PollableOutputStreamExtManual { #[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::Continue + 'static, C: IsA; fn create_source_future>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; fn create_source_stream>( &self, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; 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 { fn create_source( &self, cancellable: Option<&C>, name: Option<&str>, priority: glib::Priority, func: F, ) -> glib::Source where F: FnMut(&Self) -> glib::Continue + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O) -> glib::Continue + '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(); (&mut *func)(PollableOutputStream::from_glib_borrow(stream).unsafe_cast_ref()) .into_glib() } unsafe extern "C" fn destroy_closure(ptr: glib::ffi::gpointer) { 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::< _, 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::Continue(false) }) })) } 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::Continue(false) } else { glib::Continue(true) } }) })) } } #[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::NONE_CANCELLABLE); match gio_result { Ok(size) => Poll::Ready(Ok(size as usize)), Err(err) => { let kind = err.kind::().unwrap(); if kind == crate::IOErrorEnum::WouldBlock { let mut waker = Some(cx.waker().clone()); let source = stream.0.as_ref().create_source( crate::NONE_CANCELLABLE, None, glib::PRIORITY_DEFAULT, move |_| { if let Some(waker) = waker.take() { waker.wake(); } glib::Continue(false) }, ); 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))) } } } } 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::NONE_CANCELLABLE, 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::NONE_CANCELLABLE, 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.14.8/src/prelude.rs000064400000000000000000000030740072674642500133250ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. //! Traits and essential types intended for blanket imports. #[doc(hidden)] pub use glib::prelude::*; pub use crate::auto::traits::*; #[cfg(any(feature = "v2_60", feature = "dox"))] pub use crate::app_info::AppInfoExtManual; pub use crate::application::*; pub use crate::converter::*; pub use crate::data_input_stream::DataInputStreamExtManual; #[cfg(any(feature = "v2_58", feature = "dox"))] #[cfg(any(all(not(windows), not(target_os = "macos")), feature = "dox"))] pub use crate::desktop_app_info::DesktopAppInfoExtManual; pub use crate::file::FileExtManual; pub use crate::inet_address::InetAddressExtManual; pub use crate::initable::InitableError; pub use crate::input_stream::InputStreamExtManual; pub use crate::io_stream::IOStreamExtManual; pub use crate::list_store::ListStoreExtManual; pub use crate::output_stream::OutputStreamExtManual; pub use crate::pollable_input_stream::PollableInputStreamExtManual; pub use crate::pollable_output_stream::PollableOutputStreamExtManual; pub use crate::settings::SettingsExtManual; pub use crate::socket::*; pub use crate::tls_connection::TlsConnectionExtManual; #[cfg(any(unix, feature = "dox"))] pub use crate::unix_fd_list::UnixFDListExtManual; #[cfg(any(unix, feature = "dox"))] pub use crate::unix_input_stream::UnixInputStreamExtManual; #[cfg(any(unix, feature = "dox"))] pub use crate::unix_output_stream::UnixOutputStreamExtManual; #[cfg(any(unix, feature = "dox"))] pub use crate::unix_socket_address::{UnixSocketAddressExtManual, UnixSocketAddressPath}; gio-0.14.8/src/read_input_stream.rs000064400000000000000000000311740072674642500153740ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::subclass::prelude::*; use crate::InputStream; use std::any::Any; use std::io::{Read, Seek}; mod imp { use super::*; use std::cell::RefCell; 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"; type Type = super::ReadInputStream; type ParentType = InputStream; type Interfaces = (crate::Seekable,); } impl ObjectImpl for ReadInputStream {} impl InputStreamImpl for ReadInputStream { fn read( &self, _stream: &Self::Type, 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, _stream: &Self::Type, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { let _ = self.read.borrow_mut().take(); Ok(()) } } impl SeekableImpl for ReadInputStream { fn tell(&self, _seekable: &Self::Type) -> 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, _seekable: &Self::Type) -> bool { let read = self.read.borrow(); matches!(*read, Some(Reader::ReadSeek(_))) } fn seek( &self, _seekable: &Self::Type, 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, _seekable: &Self::Type) -> bool { false } fn truncate( &self, _seekable: &Self::Type, _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 = glib::Object::new(&[]).expect("Failed to create read input stream"); let imp = imp::ReadInputStream::from_instance(&obj); *imp.read.borrow_mut() = Some(imp::Reader::Read(AnyReader::new(read))); obj } pub fn new_seekable(read: R) -> ReadInputStream { let obj = glib::Object::new(&[]).expect("Failed to create read input stream"); let imp = imp::ReadInputStream::from_instance(&obj); *imp.read.borrow_mut() = Some(imp::Reader::ReadSeek(AnyReader::new_seekable(read))); obj } pub fn close_and_take(&self) -> Box { let imp = imp::ReadInputStream::from_instance(self); let inner = imp.read.borrow_mut().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::NONE_CANCELLABLE); 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 super::*; use std::io::Cursor; #[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::NONE_CANCELLABLE), Ok(10)); assert_eq!(&buf[..10], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..]); assert_eq!(stream.read(&mut buf[..], crate::NONE_CANCELLABLE), 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::NONE_CANCELLABLE), Ok(10)); assert_eq!(&buf[..10], &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10][..]); assert_eq!(stream.read(&mut buf[..], crate::NONE_CANCELLABLE), Ok(0)); assert!(stream.can_seek()); assert_eq!( stream.seek(0, glib::SeekType::Set, crate::NONE_CANCELLABLE), Ok(()) ); assert_eq!(stream.read(&mut buf[..], crate::NONE_CANCELLABLE), 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.14.8/src/resource.rs000064400000000000000000000061270072674642500135160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::{resources_register, Resource}; use glib::translate::*; use std::env; use std::mem; use std::path::Path; use std::process::Command; use std::ptr; 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 = 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)) } } } } // rustdoc-stripper-ignore-next /// Call from build script to run `glib-compile-resources` to generate compiled gresources to embed /// in binary with [resources_register_include]. `target` is relative to `OUT_DIR`. /// /// ```no_run /// gio::compile_resources( /// "resources", /// "resources/resources.gresource.xml", /// "compiled.gresource", /// ); /// ``` pub fn compile_resources>(source_dir: P, gresource: &str, target: &str) { let out_dir = env::var("OUT_DIR").unwrap(); let status = Command::new("glib-compile-resources") .arg("--sourcedir") .arg(source_dir.as_ref()) .arg("--target") .arg(&format!("{}/{}", out_dir, target)) .arg(gresource) .status() .unwrap(); if !status.success() { panic!("glib-compile-resources failed with exit status {}", status); } println!("cargo:rerun-if-changed={}", gresource); let output = Command::new("glib-compile-resources") .arg("--sourcedir") .arg(source_dir.as_ref()) .arg("--generate-dependencies") .arg(gresource) .output() .unwrap() .stdout; let output = String::from_utf8(output).unwrap(); for dep in output.split_whitespace() { println!("cargo:rerun-if-changed={}", dep); } } #[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 [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.14.8/src/settings.rs000064400000000000000000000166030072674642500135270ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::{Settings, SettingsBindFlags}; use glib::translate::{from_glib_borrow, from_glib_none, IntoGlib, ToGlibPtr}; use glib::variant::FromVariant; use glib::{BoolError, IsA, ToVariant}; #[must_use] pub struct BindingBuilder<'a> { settings: &'a Settings, key: &'a str, object: &'a glib::Object, property: &'a str, flags: SettingsBindFlags, get_mapping: Option Option>>, set_mapping: Option Option>>, } impl<'a> BindingBuilder<'a> { pub fn flags(mut self, flags: SettingsBindFlags) -> Self { self.flags = flags; 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)).to_glib_full() } unsafe extern "C" fn destroy_closure(ptr: *mut libc::c_void) { 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), ) } } } } pub trait SettingsExtManual { fn get(&self, key: &str) -> U; fn set(&self, key: &str, value: &U) -> Result<(), BoolError>; #[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>; } impl> SettingsExtManual for O { 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().to_str(), val.type_() ) }) } fn set(&self, key: &str, value: &U) -> Result<(), BoolError> { self.set_value(key, &value.to_variant()) } 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, } } } #[cfg(test)] mod test { use super::*; use std::env::set_var; use std::process::Command; use std::str::from_utf8; use std::sync::Once; 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.14.8/src/socket.rs000064400000000000000000000355140072674642500131610ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Cancellable; use crate::Socket; use crate::SocketAddress; use glib::object::{Cast, IsA}; use glib::translate::*; use std::cell::RefCell; use std::mem::transmute; #[cfg(all(not(unix), feature = "dox"))] use std::os::raw::c_int; #[cfg(all(not(windows), feature = "dox"))] use std::os::raw::c_void; use std::pin::Pin; use std::ptr; use futures_core::stream::Stream; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(windows)] use std::os::windows::io::{AsRawSocket, FromRawSocket, IntoRawSocket, RawSocket}; impl Socket { #[cfg(any(unix, feature = "dox"))] pub unsafe fn from_fd(fd: T) -> 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(any(windows, feature = "dox"))] pub unsafe fn from_socket(socket: T) -> 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(any(unix, feature = "dox"))] impl AsRawFd for Socket { fn as_raw_fd(&self) -> RawFd { unsafe { ffi::g_socket_get_fd(self.to_glib_none().0) as _ } } } #[cfg(any(windows, feature = "dox"))] impl AsRawSocket for Socket { fn as_raw_socket(&self) -> RawSocket { unsafe { ffi::g_socket_get_fd(self.to_glib_none().0) as _ } } } pub trait SocketExtManual: Sized { #[doc(alias = "g_socket_receive")] fn receive, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result; #[doc(alias = "g_socket_receive_from")] fn receive_from, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result<(usize, SocketAddress), glib::Error>; #[doc(alias = "g_socket_receive_with_blocking")] fn receive_with_blocking, C: IsA>( &self, buffer: B, blocking: bool, cancellable: Option<&C>, ) -> Result; #[doc(alias = "g_socket_send")] fn send, C: IsA>( &self, buffer: B, cancellable: Option<&C>, ) -> Result; #[doc(alias = "g_socket_send_to")] fn send_to, P: IsA, C: IsA>( &self, address: Option<&P>, buffer: B, cancellable: Option<&C>, ) -> Result; #[doc(alias = "g_socket_send_with_blocking")] fn send_with_blocking, C: IsA>( &self, buffer: B, blocking: bool, cancellable: Option<&C>, ) -> Result; #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "get_fd")] #[doc(alias = "g_socket_get_fd")] fn fd(&self) -> T; #[cfg(any(windows, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(windows)))] #[doc(alias = "get_socket")] #[doc(alias = "g_socket_get_fd")] fn socket(&self) -> T; #[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::Continue + 'static, C: IsA; fn create_source_future>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; fn create_source_stream>( &self, condition: glib::IOCondition, cancellable: Option<&C>, priority: glib::Priority, ) -> Pin + 'static>>; } impl> SocketExtManual for O { 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)) } } } 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)) } } } 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)) } } } 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)) } } } 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)) } } } 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(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] fn fd(&self) -> T { unsafe { FromRawFd::from_raw_fd(ffi::g_socket_get_fd(self.as_ref().to_glib_none().0)) } } #[cfg(any(windows, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(windows)))] fn socket(&self) -> T { unsafe { FromRawSocket::from_raw_socket(ffi::g_socket_get_fd(self.as_ref().to_glib_none().0) as _) } } 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::Continue + 'static, C: IsA, { unsafe extern "C" fn trampoline< O: IsA, F: FnMut(&O, glib::IOCondition) -> glib::Continue + '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(); (&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) { 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::< _, 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::Continue(false) }, ) })) } 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::Continue(false) } else { glib::Continue(true) } }, ) })) } } #[cfg(all(not(unix), feature = "dox"))] pub trait IntoRawFd { fn into_raw_fd(self) -> c_int; } #[cfg(all(not(unix), feature = "dox"))] pub trait FromRawFd { unsafe fn from_raw_fd(fd: c_int) -> Self; } #[cfg(all(not(unix), feature = "dox"))] pub trait AsRawFd { fn as_raw_fd(&self) -> RawFd; } #[cfg(all(not(unix), feature = "dox"))] pub type RawFd = c_int; #[cfg(all(not(windows), feature = "dox"))] pub trait IntoRawSocket { fn into_raw_socket(self) -> u64; } #[cfg(all(not(windows), feature = "dox"))] pub trait FromRawSocket { unsafe fn from_raw_socket(sock: u64) -> Self; } #[cfg(all(not(windows), feature = "dox"))] pub trait AsRawSocket { fn as_raw_socket(&self) -> RawSocket; } #[cfg(all(not(windows), feature = "dox"))] pub type RawSocket = *mut c_void; gio-0.14.8/src/subclass/action_group.rs000064400000000000000000000716360072674642500162060ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ActionGroup; use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, GString, ObjectExt, Quark, Variant, VariantType}; use once_cell::sync::Lazy; use std::mem; use std::ptr; pub trait ActionGroupImpl: ObjectImpl { fn action_added(&self, action_group: &Self::Type, action_name: &str) { self.parent_action_added(action_group, action_name); } fn action_enabled_changed(&self, action_group: &Self::Type, action_name: &str, enabled: bool) { self.parent_action_enabled_changed(action_group, action_name, enabled); } fn action_removed(&self, action_group: &Self::Type, action_name: &str) { self.parent_action_removed(action_group, action_name); } fn action_state_changed(&self, action_group: &Self::Type, action_name: &str, state: &Variant) { self.parent_action_state_changed(action_group, action_name, state); } fn activate_action( &self, action_group: &Self::Type, action_name: &str, parameter: Option<&Variant>, ) { self.parent_activate_action(action_group, action_name, parameter); } fn change_action_state(&self, action_group: &Self::Type, action_name: &str, value: &Variant) { self.parent_change_action_state(action_group, action_name, value) } #[doc(alias = "get_action_enabled")] fn action_is_enabled(&self, action_group: &Self::Type, action_name: &str) -> bool { self.parent_action_is_enabled(action_group, action_name) } #[doc(alias = "get_action_parameter_type")] fn action_parameter_type( &self, action_group: &Self::Type, action_name: &str, ) -> Option { self.parent_action_parameter_type(action_group, action_name) } #[doc(alias = "get_action_state")] fn action_state(&self, action_group: &Self::Type, action_name: &str) -> Option { self.parent_action_state(action_group, action_name) } #[doc(alias = "get_action_state_hint")] fn action_state_hint(&self, action_group: &Self::Type, action_name: &str) -> Option { self.parent_action_state_hint(action_group, action_name) } #[doc(alias = "get_action_state_type")] fn action_state_type( &self, action_group: &Self::Type, action_name: &str, ) -> Option { self.parent_action_state_type(action_group, action_name) } fn has_action(&self, action_group: &Self::Type, action_name: &str) -> bool { self.parent_has_action(action_group, action_name) } fn list_actions(&self, action_group: &Self::Type) -> Vec; fn query_action( &self, action_group: &Self::Type, action_name: &str, ) -> Option<( bool, Option, Option, Option, Option, )>; } pub trait ActionGroupImplExt: ObjectSubclass { fn parent_action_added(&self, action_group: &Self::Type, action_name: &str); fn parent_action_enabled_changed( &self, action_group: &Self::Type, action_name: &str, enabled: bool, ); fn parent_action_removed(&self, action_group: &Self::Type, action_name: &str); fn parent_action_state_changed( &self, action_group: &Self::Type, action_name: &str, state: &Variant, ); fn parent_activate_action( &self, action_group: &Self::Type, action_name: &str, parameter: Option<&Variant>, ); fn parent_change_action_state( &self, action_group: &Self::Type, action_name: &str, value: &Variant, ); fn parent_action_is_enabled(&self, action_group: &Self::Type, action_name: &str) -> bool; fn parent_action_parameter_type( &self, action_group: &Self::Type, action_name: &str, ) -> Option; fn parent_action_state(&self, action_group: &Self::Type, action_name: &str) -> Option; fn parent_action_state_hint( &self, action_group: &Self::Type, action_name: &str, ) -> Option; fn parent_action_state_type( &self, action_group: &Self::Type, action_name: &str, ) -> Option; fn parent_has_action(&self, action_group: &Self::Type, action_name: &str) -> bool; fn parent_list_actions(&self, action_group: &Self::Type) -> Vec; fn parent_query_action( &self, action_group: &Self::Type, action_name: &str, ) -> Option<( bool, Option, Option, Option, Option, )>; } impl ActionGroupImplExt for T { fn parent_action_added(&self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); } } } fn parent_action_enabled_changed( &self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, enabled.into_glib(), ); } } } fn parent_action_removed(&self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); } } } fn parent_action_state_changed( &self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, state.to_glib_none().0, ); } } } fn parent_activate_action( &self, action_group: &Self::Type, 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( action_group .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_group: &Self::Type, 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( action_group .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_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib(ret) } } fn parent_action_parameter_type( &self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state(&self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state_hint( &self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_action_state_type( &self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_has_action(&self, action_group: &Self::Type, 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, action_name.to_glib_none().0, ); from_glib(ret) } } fn parent_list_actions(&self, action_group: &Self::Type) -> 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( action_group .unsafe_cast_ref::() .to_glib_none() .0, ); FromGlibPtrContainer::from_glib_none(ret) } } fn parent_query_action( &self, action_group: &Self::Type, 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( action_group .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), )) } } } } 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::); } fn instance_init(_instance: &mut glib::subclass::InitializingObject) {} } 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.impl_(); imp.has_action( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_is_enabled( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &action_name, ) .into_glib() } /// 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) } } static ACTION_GROUP_GET_ACTION_PARAMETER_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-get-action-parameter")); 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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.action_parameter_type(wrap.unsafe_cast_ref(), &action_name); if let Some(param_type) = ret { let param_type = param_type.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_GET_ACTION_PARAMETER_QUARK, PtrHolder(param_type, |ptr| glib::ffi::g_free(ptr as *mut _)), ); param_type } else { ptr::null() } } static ACTION_GROUP_GET_ACTION_STATE_TYPE_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-get-action-state-type")); 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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.action_state_type(wrap.unsafe_cast_ref(), &action_name); if let Some(state_type) = ret { let state_type = state_type.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_GET_ACTION_STATE_TYPE_QUARK, PtrHolder(state_type, |ptr| glib::ffi::g_free(ptr as *mut _)), ); state_type } else { ptr::null() } } static ACTION_GROUP_GET_ACTION_STATE_HINT_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-get-action-state-hint")); 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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.action_state_hint(wrap.unsafe_cast_ref(), &action_name); if let Some(state_hint) = ret { let state_hint_ptr = state_hint.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_GET_ACTION_STATE_HINT_QUARK, PtrHolder(state_hint_ptr, |ptr| glib::ffi::g_variant_unref(ptr)), ); state_hint_ptr } else { ptr::null_mut() } } static ACTION_GROUP_GET_ACTION_STATE_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-get-action-state")); 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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.action_state(wrap.unsafe_cast_ref(), &action_name); if let Some(state) = ret { let state_ptr = state.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_GET_ACTION_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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let state = Variant::from_glib_borrow(stateptr); imp.change_action_state( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let param: Borrowed> = from_glib_borrow(parameterptr); imp.activate_action( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_added( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_removed( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); imp.action_enabled_changed( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let state = Variant::from_glib_borrow(stateptr); imp.action_state_changed( from_glib_borrow::<_, ActionGroup>(action_group).unsafe_cast_ref(), &action_name, &state, ) } static ACTION_GROUP_LIST_ACTIONS_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-list-actions")); 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.impl_(); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let actions = imp.list_actions(wrap.unsafe_cast_ref()); { let actionsptr = actions.to_glib_full(); wrap.set_qdata(*ACTION_GROUP_LIST_ACTIONS_QUARK, actionsptr); actionsptr } } static ACTION_GROUP_QUERY_ACTION_PARAM_TYPE_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-query-action-parameter-type")); static ACTION_GROUP_QUERY_ACTION_STATE_TYPE_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-query-action-state-type")); static ACTION_GROUP_QUERY_ACTION_STATE_HINT_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-query-action-state-hint")); static ACTION_GROUP_QUERY_ACTION_STATE_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-group-query-action-state")); 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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); let wrap = from_glib_borrow::<_, ActionGroup>(action_group); let ret = imp.query_action(wrap.unsafe_cast_ref(), &action_name); if let Some((rs_enabled, rs_parameter_type, rs_state_type, rs_state_hint, rs_state)) = ret { if !enabled.is_null() { *enabled = rs_enabled.into_glib(); } if !parameter_type.is_null() { if let Some(rs_parameter_type) = rs_parameter_type { let ret = rs_parameter_type.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_QUERY_ACTION_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 ret = rs_state_type.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_QUERY_ACTION_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 ret = rs_state_hint.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_QUERY_ACTION_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 ret = rs_state.to_glib_full(); wrap.set_qdata( *ACTION_GROUP_QUERY_ACTION_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.14.8/src/subclass/action_map.rs000064400000000000000000000117060072674642500156170ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::{Action, ActionMap}; use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, GString, IsA, ObjectExt, Quark}; use once_cell::sync::Lazy; use std::collections::HashMap; pub trait ActionMapImpl: ObjectImpl { fn lookup_action(&self, action_map: &Self::Type, action_name: &str) -> Option; fn add_action(&self, action_map: &Self::Type, action: &Action); fn remove_action(&self, action_map: &Self::Type, action_name: &str); } pub trait ActionMapImplExt: ObjectSubclass { fn parent_lookup_action(&self, action_map: &Self::Type, action_name: &str) -> Option; fn parent_add_action(&self, action_map: &Self::Type, action: &Action); fn parent_remove_action(&self, action_map: &Self::Type, action_name: &str); } impl ActionMapImplExt for T { fn parent_lookup_action(&self, action_map: &Self::Type, 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( action_map.unsafe_cast_ref::().to_glib_none().0, name.to_glib_none().0, ); from_glib_none(ret) } } fn parent_add_action(&self, action_map: &Self::Type, 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( action_map.unsafe_cast_ref::().to_glib_none().0, action.to_glib_none().0, ); } } fn parent_remove_action(&self, action_map: &Self::Type, 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( action_map.unsafe_cast_ref::().to_glib_none().0, action_name.to_glib_none().0, ); } } } 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::); } fn instance_init(_instance: &mut glib::subclass::InitializingObject) {} } static ACTION_MAP_LOOKUP_ACTION_QUARK: Lazy = Lazy::new(|| Quark::from_string("gtk-rs-subclass-action-map-lookup-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.impl_(); let wrap = from_glib_borrow::<_, ActionMap>(action_map); let ret = imp.lookup_action(wrap.unsafe_cast_ref(), &action_name); if let Some(action) = ret { let actionptr = action.to_glib_none().0; let mut map = wrap .steal_qdata::>(*ACTION_MAP_LOOKUP_ACTION_QUARK) .unwrap_or_else(HashMap::new); map.insert(action_name.to_string(), action); wrap.set_qdata(*ACTION_MAP_LOOKUP_ACTION_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.impl_(); let action: Borrowed = from_glib_borrow(actionptr); imp.add_action( from_glib_borrow::<_, ActionMap>(action_map).unsafe_cast_ref(), &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.impl_(); let action_name = GString::from_glib_borrow(action_nameptr); imp.remove_action( from_glib_borrow::<_, ActionMap>(action_map).unsafe_cast_ref(), &action_name, ); } gio-0.14.8/src/subclass/application.rs000064400000000000000000000443600072674642500160120ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::*; use glib::subclass::prelude::*; use glib::{Cast, VariantDict}; use crate::Application; use libc::{c_char, c_int, c_void}; use std::ffi::OsString; use std::fmt; use std::ops::Deref; use std::ptr; 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]; 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, application: &Self::Type) { self.parent_activate(application) } fn after_emit(&self, application: &Self::Type, platform_data: &glib::Variant) { self.parent_after_emit(application, platform_data) } fn before_emit(&self, application: &Self::Type, platform_data: &glib::Variant) { self.parent_before_emit(application, platform_data) } fn command_line( &self, application: &Self::Type, command_line: &crate::ApplicationCommandLine, ) -> i32 { self.parent_command_line(application, command_line) } fn local_command_line( &self, application: &Self::Type, arguments: &mut ArgumentList, ) -> Option { self.parent_local_command_line(application, arguments) } fn open(&self, application: &Self::Type, files: &[crate::File], hint: &str) { self.parent_open(application, files, hint) } fn quit_mainloop(&self, application: &Self::Type) { self.parent_quit_mainloop(application) } fn run_mainloop(&self, application: &Self::Type) { self.parent_run_mainloop(application) } fn shutdown(&self, application: &Self::Type) { self.parent_shutdown(application) } fn startup(&self, application: &Self::Type) { self.parent_startup(application) } fn handle_local_options(&self, application: &Self::Type, options: &VariantDict) -> i32 { self.parent_handle_local_options(application, options) } } pub trait ApplicationImplExt: ObjectSubclass { fn parent_activate(&self, application: &Self::Type); fn parent_after_emit(&self, application: &Self::Type, platform_data: &glib::Variant); fn parent_before_emit(&self, application: &Self::Type, platform_data: &glib::Variant); fn parent_command_line( &self, application: &Self::Type, command_line: &crate::ApplicationCommandLine, ) -> i32; fn parent_local_command_line( &self, application: &Self::Type, arguments: &mut ArgumentList, ) -> Option; fn parent_open(&self, application: &Self::Type, files: &[crate::File], hint: &str); fn parent_quit_mainloop(&self, application: &Self::Type); fn parent_run_mainloop(&self, application: &Self::Type); fn parent_shutdown(&self, application: &Self::Type); fn parent_startup(&self, application: &Self::Type); fn parent_handle_local_options(&self, application: &Self::Type, options: &VariantDict) -> i32; } impl ApplicationImplExt for T { fn parent_activate(&self, application: &Self::Type) { unsafe { let data = T::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(application .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_after_emit(&self, application: &Self::Type, platform_data: &glib::Variant) { unsafe { let data = T::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( application .unsafe_cast_ref::() .to_glib_none() .0, platform_data.to_glib_none().0, ) } } fn parent_before_emit(&self, application: &Self::Type, platform_data: &glib::Variant) { unsafe { let data = T::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( application .unsafe_cast_ref::() .to_glib_none() .0, platform_data.to_glib_none().0, ) } } fn parent_command_line( &self, application: &Self::Type, command_line: &crate::ApplicationCommandLine, ) -> i32 { unsafe { let data = T::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( application .unsafe_cast_ref::() .to_glib_none() .0, command_line.to_glib_none().0, ) } } fn parent_local_command_line( &self, application: &Self::Type, arguments: &mut ArgumentList, ) -> Option { unsafe { let data = T::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( application .unsafe_cast_ref::() .to_glib_none() .0, arguments.ptr, &mut exit_status, ); arguments.refresh(); match res { glib::ffi::GFALSE => None, _ => Some(exit_status), } } } fn parent_open(&self, application: &Self::Type, files: &[crate::File], hint: &str) { unsafe { let data = T::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( application .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, application: &Self::Type) { unsafe { let data = T::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(application .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_run_mainloop(&self, application: &Self::Type) { unsafe { let data = T::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(application .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_shutdown(&self, application: &Self::Type) { unsafe { let data = T::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(application .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_startup(&self, application: &Self::Type) { unsafe { let data = T::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(application .unsafe_cast_ref::() .to_glib_none() .0) } } fn parent_handle_local_options(&self, application: &Self::Type, options: &VariantDict) -> i32 { unsafe { let data = T::type_data(); let parent_class = data.as_ref().parent_class() as *mut ffi::GApplicationClass; if let Some(f) = (*parent_class).handle_local_options { f( application .unsafe_cast_ref::() .to_glib_none() .0, options.to_glib_none().0, ) } else { // Continue default handling -1 } } } } unsafe impl IsSubclassable for Application { fn class_init(class: &mut ::glib::Class) { >::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::); } fn instance_init(instance: &mut glib::subclass::InitializingObject) { >::instance_init(instance); } } unsafe extern "C" fn application_activate(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.activate(wrap.unsafe_cast_ref()) } 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.after_emit(wrap.unsafe_cast_ref(), &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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.before_emit(wrap.unsafe_cast_ref(), &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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.command_line(wrap.unsafe_cast_ref(), &from_glib_borrow(command_line)) } 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); let mut args = ArgumentList::new(arguments); let res = imp.local_command_line(wrap.unsafe_cast_ref(), &mut args); args.refresh(); match res { Some(ret) => { ptr::write(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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); let files: Vec = FromGlibContainer::from_glib_none_num(files, num_files as usize); imp.open( wrap.unsafe_cast_ref(), 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.quit_mainloop(wrap.unsafe_cast_ref()) } unsafe extern "C" fn application_run_mainloop(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.run_mainloop(wrap.unsafe_cast_ref()) } unsafe extern "C" fn application_shutdown(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.shutdown(wrap.unsafe_cast_ref()) } unsafe extern "C" fn application_startup(ptr: *mut ffi::GApplication) { let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.startup(wrap.unsafe_cast_ref()) } 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); imp.handle_local_options(wrap.unsafe_cast_ref(), &from_glib_borrow(options)) } #[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, _application: &Self::Type, cmd_line: &crate::ApplicationCommandLine, ) -> i32 { let arguments = cmd_line.arguments(); for arg in arguments { // TODO: we need https://github.com/rust-lang/rust/issues/49802 let a = arg.into_string().unwrap(); assert!(!a.starts_with("--local-")) } EXIT_STATUS } fn local_command_line( &self, _application: &Self::Type, 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.clone().into_string().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::new::(&[ ("application-id", &"org.gtk-rs.SimpleApplication"), ("flags", &crate::ApplicationFlags::empty()), ]) .unwrap() .upcast::(); app.set_inactivity_timeout(10000); assert_eq!(app.run_with_args(&["--local"]), EXIT_STATUS); } } gio-0.14.8/src/subclass/initable.rs000064400000000000000000000147070072674642500153000ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::object::Cast; use glib::translate::*; use glib::Error; use glib::subclass::prelude::*; use std::ptr; use crate::Cancellable; use crate::Initable; pub trait InitableImpl: ObjectImpl { fn init(&self, initable: &Self::Type, cancellable: Option<&Cancellable>) -> Result<(), Error>; } pub trait InitableImplExt: ObjectSubclass { fn parent_init( &self, initable: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; } impl InitableImplExt for T { fn parent_init( &self, initable: &Self::Type, 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( initable.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)) } } } } unsafe impl IsImplementable for Initable { fn interface_init(iface: &mut glib::Interface) { let iface = iface.as_mut(); iface.init = Some(initable_init::); } fn instance_init(_instance: &mut glib::subclass::InitializingObject) {} } 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.impl_(); match imp.init( from_glib_borrow::<_, Initable>(initable).unsafe_cast_ref(), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(()) => glib::ffi::GTRUE, Err(e) => { if !error.is_null() { *error = e.into_raw(); } glib::ffi::GFALSE } } } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; use crate::traits::InitableExt; use crate::{Cancellable, Initable}; pub mod imp { use super::*; use crate::Cancellable; use crate::Initable; use std::cell::Cell; pub struct InitableTestType(pub Cell); #[glib::object_subclass] impl ObjectSubclass for InitableTestType { const NAME: &'static str = "InitableTestType"; type Type = super::InitableTestType; type ParentType = glib::Object; type Interfaces = (Initable,); fn new() -> Self { Self(Cell::new(0)) } } impl InitableImpl for InitableTestType { fn init( &self, initable: &Self::Type, _cancellable: Option<&Cancellable>, ) -> Result<(), glib::Error> { InitableTestType::from_instance(initable) .0 .set(0x123456789abcdef); Ok(()) } } impl ObjectImpl for InitableTestType {} } pub mod ffi { use super::*; pub type InitableTestType = ::Instance; #[no_mangle] pub unsafe extern "C" fn initable_test_type_get_type() -> glib::ffi::GType { imp::InitableTestType::type_().into_glib() } #[no_mangle] pub unsafe extern "C" fn initable_test_type_get_value(this: *mut InitableTestType) -> u64 { let this = super::InitableTestType::from_glib_borrow(this); imp::InitableTestType::from_instance(&this).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 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(&[]).expect("Failed creation of InitableTestType object") } pub fn value(&self) -> u64 { imp::InitableTestType::from_instance(self).0.get() } } #[test] fn test_initable_with_init() { let test = InitableTestType::new_uninit(); assert_ne!(0x123456789abcdef, test.value()); let result = unsafe { test.init(Option::<&Cancellable>::None) }; assert!(result.is_ok()); assert_eq!(0x123456789abcdef, test.value()); } #[test] fn test_initable_with_initable_new() { let test = InitableTestType::new(); assert_eq!(0x123456789abcdef, test.value()); } #[test] fn test_initable_new_failure() { let value: u32 = 2; match Initable::new::( &[("invalid-property", &value)], Option::<&Cancellable>::None, ) { Err(InitableError::NewObjectFailed(_)) => (), v => panic!("expected InitableError::NewObjectFailed, got {:?}", v), } } #[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.14.8/src/subclass/input_stream.rs000064400000000000000000000263030072674642500162160ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, Error}; use crate::Cancellable; use crate::InputStream; use std::ptr; pub trait InputStreamImpl: ObjectImpl + InputStreamImplExt + Send { fn read( &self, stream: &Self::Type, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result { self.parent_read(stream, buffer, cancellable) } fn close(&self, stream: &Self::Type, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(stream, cancellable) } fn skip( &self, stream: &Self::Type, count: usize, cancellable: Option<&Cancellable>, ) -> Result { self.parent_skip(stream, count, cancellable) } } pub trait InputStreamImplExt: ObjectSubclass { fn parent_read( &self, stream: &Self::Type, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result; fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn parent_skip( &self, stream: &Self::Type, count: usize, cancellable: Option<&Cancellable>, ) -> Result; } impl InputStreamImplExt for T { fn parent_read( &self, stream: &Self::Type, buffer: &mut [u8], cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = T::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( stream.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 { assert!(res >= 0); let res = res as usize; assert!(res <= buffer.len()); Ok(res) } } } fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unsafe { let data = T::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( stream.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, stream: &Self::Type, count: usize, cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = T::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( stream.unsafe_cast_ref::().to_glib_none().0, count, cancellable.to_glib_none().0, &mut err, ); if res == -1 { Err(from_glib_full(err)) } else { assert!(res >= 0); let res = res as usize; assert!(res <= count); Ok(res) } } } } unsafe impl IsSubclassable for InputStream { fn class_init(class: &mut ::glib::Class) { >::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::); } fn instance_init(instance: &mut glib::subclass::InitializingObject) { >::instance_init(instance); } } 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 { use std::isize; use std::slice; assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.read( wrap.unsafe_cast_ref(), 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_raw(); } -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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.close( wrap.unsafe_cast_ref(), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_raw(); } 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 { use std::isize; assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.skip( wrap.unsafe_cast_ref(), 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_raw(); } -1 } } } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; use crate::subclass::prelude::*; use std::cell::RefCell; 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, _stream: &Self::Type, 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, _seekable: &Self::Type) -> i64 { *self.pos.borrow() as i64 } fn can_seek(&self, _seekable: &Self::Type) -> bool { true } fn seek( &self, _seekable: &Self::Type, 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, _seekable: &Self::Type) -> bool { false } fn truncate( &self, _seekable: &Self::Type, _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::(&[]).unwrap(); let mut buf = [0; 16]; assert_eq!(stream.read(&mut buf, crate::NONE_CANCELLABLE), 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::NONE_CANCELLABLE), Ok(2)); assert_eq!(stream.read(&mut buf, crate::NONE_CANCELLABLE), 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::NONE_CANCELLABLE), Ok(()) ); assert_eq!(seekable.tell(), 0); assert_eq!(stream.read(&mut buf, crate::NONE_CANCELLABLE), 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::NONE_CANCELLABLE), Ok(())); } } gio-0.14.8/src/subclass/io_stream.rs000064400000000000000000000135250072674642500154700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::prelude::*; use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, Error}; use crate::Cancellable; use crate::{IOStream, InputStream, OutputStream}; use std::ptr; use once_cell::sync::Lazy; pub trait IOStreamImpl: ObjectImpl + IOStreamImplExt + Send { fn input_stream(&self, stream: &Self::Type) -> InputStream { self.parent_input_stream(stream) } fn output_stream(&self, stream: &Self::Type) -> OutputStream { self.parent_output_stream(stream) } fn close(&self, stream: &Self::Type, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(stream, cancellable) } } pub trait IOStreamImplExt: ObjectSubclass { fn parent_input_stream(&self, stream: &Self::Type) -> InputStream; fn parent_output_stream(&self, stream: &Self::Type) -> OutputStream; fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; } impl IOStreamImplExt for T { fn parent_input_stream(&self, stream: &Self::Type) -> InputStream { unsafe { let data = T::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(stream.unsafe_cast_ref::().to_glib_none().0)) } } fn parent_output_stream(&self, stream: &Self::Type) -> OutputStream { unsafe { let data = T::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(stream.unsafe_cast_ref::().to_glib_none().0)) } } fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unsafe { let data = T::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( stream.unsafe_cast_ref::().to_glib_none().0, cancellable.to_glib_none().0, &mut err, )) { Ok(()) } else { Err(from_glib_full(err)) } } else { Ok(()) } } } } unsafe impl IsSubclassable for IOStream { fn class_init(class: &mut ::glib::Class) { >::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::); } fn instance_init(instance: &mut glib::subclass::InitializingObject) { >::instance_init(instance); } } static OUTPUT_STREAM_QUARK: Lazy = Lazy::new(|| glib::Quark::from_string("gtk-rs-subclass-output-stream")); static INPUT_STREAM_QUARK: Lazy = Lazy::new(|| glib::Quark::from_string("gtk-rs-subclass-input-stream")); 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); let ret = imp.input_stream(wrap.unsafe_cast_ref()); // 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. if let Some(old_stream) = wrap.qdata::(*INPUT_STREAM_QUARK) { assert_eq!( old_stream.as_ref(), &ret, "Did not return same input stream again" ); } wrap.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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); let ret = imp.output_stream(wrap.unsafe_cast_ref()); // 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. if let Some(old_stream) = wrap.qdata::(*OUTPUT_STREAM_QUARK) { assert_eq!( old_stream.as_ref(), &ret, "Did not return same output stream again" ); } wrap.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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.close( wrap.unsafe_cast_ref(), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_raw(); } glib::ffi::GFALSE } } } gio-0.14.8/src/subclass/list_model.rs000064400000000000000000000116450072674642500156420ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::ListModel; use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, IsA, ObjectExt}; use once_cell::sync::Lazy; pub trait ListModelImpl: ObjectImpl { #[doc(alias = "get_item_type")] fn item_type(&self, list_model: &Self::Type) -> glib::Type; #[doc(alias = "get_n_items")] fn n_items(&self, list_model: &Self::Type) -> u32; #[doc(alias = "get_item")] fn item(&self, list_model: &Self::Type, position: u32) -> Option; } pub trait ListModelImplExt: ObjectSubclass { fn parent_item_type(&self, list_model: &Self::Type) -> glib::Type; fn parent_n_items(&self, list_model: &Self::Type) -> u32; fn parent_item(&self, list_model: &Self::Type, position: u32) -> Option; } impl ListModelImplExt for T { fn parent_item_type(&self, list_model: &Self::Type) -> 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(list_model.unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_n_items(&self, list_model: &Self::Type) -> 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(list_model.unsafe_cast_ref::().to_glib_none().0) } } fn parent_item(&self, list_model: &Self::Type, 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( list_model.unsafe_cast_ref::().to_glib_none().0, position, ); from_glib_full(ret) } } } 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::); } fn instance_init(_instance: &mut glib::subclass::InitializingObject) {} } static LIST_ITEM_TYPE_QUARK: Lazy = Lazy::new(|| glib::Quark::from_string("gtk-rs-subclass-list-model-item-type")); 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.impl_(); let wrap = from_glib_borrow::<_, ListModel>(list_model); let type_ = imp.item_type(wrap.unsafe_cast_ref()).into_glib(); // Store the type so we can enforce that it doesn't change. match wrap.qdata(*LIST_ITEM_TYPE_QUARK) { Some(old_type) => { assert_eq!( type_, *old_type.as_ref(), "ListModel's get_item_type cannot be changed" ); } None => { wrap.set_qdata(*LIST_ITEM_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.impl_(); imp.n_items(from_glib_borrow::<_, ListModel>(list_model).unsafe_cast_ref()) } 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.impl_(); let wrap = from_glib_borrow::<_, ListModel>(list_model); let item = imp.item(wrap.unsafe_cast_ref(), position); if let Some(ref i) = item { let type_ = imp.item_type(wrap.unsafe_cast_ref()); assert!( i.type_().is_a(type_), "All ListModel items need to be of type {} or a subtype of it", type_.name() ); }; item.to_glib_full() } gio-0.14.8/src/subclass/mod.rs000064400000000000000000000017000072674642500142550ustar 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 initable; mod input_stream; mod io_stream; mod list_model; mod output_stream; mod seekable; pub use self::application::ArgumentList; pub mod prelude { #[doc(hidden)] pub use glib::subclass::prelude::*; pub use super::action_group::{ActionGroupImpl, ActionGroupImplExt}; pub use super::action_map::{ActionMapImpl, ActionMapImplExt}; pub use super::application::{ApplicationImpl, ApplicationImplExt}; pub use super::initable::{InitableImpl, InitableImplExt}; pub use super::input_stream::{InputStreamImpl, InputStreamImplExt}; pub use super::io_stream::{IOStreamImpl, IOStreamImplExt}; pub use super::list_model::{ListModelImpl, ListModelImplExt}; pub use super::output_stream::{OutputStreamImpl, OutputStreamImplExt}; pub use super::seekable::{SeekableImpl, SeekableImplExt}; } gio-0.14.8/src/subclass/output_stream.rs000064400000000000000000000254430072674642500164230ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::subclass::prelude::*; use glib::translate::*; use glib::{Cast, Error}; use crate::Cancellable; use crate::InputStream; use crate::OutputStream; use crate::OutputStreamSpliceFlags; use std::ptr; pub trait OutputStreamImpl: ObjectImpl + OutputStreamImplExt + Send { fn write( &self, stream: &Self::Type, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result { self.parent_write(stream, buffer, cancellable) } fn close(&self, stream: &Self::Type, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_close(stream, cancellable) } fn flush(&self, stream: &Self::Type, cancellable: Option<&Cancellable>) -> Result<(), Error> { self.parent_flush(stream, cancellable) } fn splice( &self, stream: &Self::Type, input_stream: &InputStream, flags: OutputStreamSpliceFlags, cancellable: Option<&Cancellable>, ) -> Result { self.parent_splice(stream, input_stream, flags, cancellable) } } pub trait OutputStreamImplExt: ObjectSubclass { fn parent_write( &self, stream: &Self::Type, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result; fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn parent_flush( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn parent_splice( &self, stream: &Self::Type, input_stream: &InputStream, flags: OutputStreamSpliceFlags, cancellable: Option<&Cancellable>, ) -> Result; } impl OutputStreamImplExt for T { fn parent_write( &self, stream: &Self::Type, buffer: &[u8], cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = T::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( stream.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 { assert!(res >= 0); let res = res as usize; assert!(res <= buffer.len()); Ok(res) } } } fn parent_close( &self, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unsafe { let data = T::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( stream.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, stream: &Self::Type, cancellable: Option<&Cancellable>, ) -> Result<(), Error> { unsafe { let data = T::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( stream.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, stream: &Self::Type, input_stream: &InputStream, flags: OutputStreamSpliceFlags, cancellable: Option<&Cancellable>, ) -> Result { unsafe { let data = T::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( stream.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 { assert!(res >= 0); let res = res as usize; Ok(res) } } } } unsafe impl IsSubclassable for OutputStream { fn class_init(class: &mut ::glib::Class) { >::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::); } fn instance_init(instance: &mut glib::subclass::InitializingObject) { >::instance_init(instance); } } 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 { use std::isize; use std::slice; assert!(count <= isize::MAX as usize); let instance = &*(ptr as *mut T::Instance); let imp = instance.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.write( wrap.unsafe_cast_ref(), 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_raw(); } -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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.close( wrap.unsafe_cast_ref(), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_raw(); } 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.flush( wrap.unsafe_cast_ref(), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(_) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_raw(); } 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.impl_(); let wrap: Borrowed = from_glib_borrow(ptr); match imp.splice( wrap.unsafe_cast_ref(), &from_glib_borrow(input_stream), from_glib(flags), Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(res) => { use std::isize; assert!(res <= isize::MAX as usize); res as isize } Err(e) => { if !err.is_null() { *err = e.into_raw(); } -1 } } } #[cfg(test)] mod tests { use super::*; use crate::prelude::*; use std::cell::RefCell; 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, _stream: &Self::Type, 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::(&[]).unwrap(); assert_eq!( *imp::SimpleOutputStream::from_instance(&stream).sum.borrow(), 0 ); assert_eq!( stream.write(&[1, 2, 3, 4, 5], crate::NONE_CANCELLABLE), Ok(5) ); assert_eq!( *imp::SimpleOutputStream::from_instance(&stream).sum.borrow(), 15 ); } } gio-0.14.8/src/subclass/seekable.rs000064400000000000000000000166730072674642500152700ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::*; use glib::Cast; use glib::Error; use glib::SeekType; use glib::subclass::prelude::*; use std::ptr; use crate::Cancellable; use crate::Seekable; pub trait SeekableImpl: ObjectImpl + Send { fn tell(&self, seekable: &Self::Type) -> i64; fn can_seek(&self, seekable: &Self::Type) -> bool; fn seek( &self, seekable: &Self::Type, offset: i64, type_: SeekType, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn can_truncate(&self, seekable: &Self::Type) -> bool; fn truncate( &self, seekable: &Self::Type, offset: i64, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; } pub trait SeekableImplExt: ObjectSubclass { fn parent_tell(&self, seekable: &Self::Type) -> i64; fn parent_can_seek(&self, seekable: &Self::Type) -> bool; fn parent_seek( &self, seekable: &Self::Type, offset: i64, type_: SeekType, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; fn parent_can_truncate(&self, seekable: &Self::Type) -> bool; fn parent_truncate( &self, seekable: &Self::Type, offset: i64, cancellable: Option<&Cancellable>, ) -> Result<(), Error>; } impl SeekableImplExt for T { fn parent_tell(&self, seekable: &Self::Type) -> 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(seekable.unsafe_cast_ref::().to_glib_none().0) } } fn parent_can_seek(&self, seekable: &Self::Type) -> 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(seekable.unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_seek( &self, seekable: &Self::Type, 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( seekable.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, seekable: &Self::Type) -> 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(seekable.unsafe_cast_ref::().to_glib_none().0); from_glib(ret) } } fn parent_truncate( &self, seekable: &Self::Type, 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( seekable.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)) } } } } 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::); } fn instance_init(_instance: &mut glib::subclass::InitializingObject) {} } unsafe extern "C" fn seekable_tell(seekable: *mut ffi::GSeekable) -> i64 { let instance = &*(seekable as *mut T::Instance); let imp = instance.impl_(); imp.tell(from_glib_borrow::<_, Seekable>(seekable).unsafe_cast_ref()) } unsafe extern "C" fn seekable_can_seek( seekable: *mut ffi::GSeekable, ) -> glib::ffi::gboolean { let instance = &*(seekable as *mut T::Instance); let imp = instance.impl_(); imp.can_seek(from_glib_borrow::<_, Seekable>(seekable).unsafe_cast_ref()) .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.impl_(); match imp.seek( from_glib_borrow::<_, Seekable>(seekable).unsafe_cast_ref(), 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_raw(); } 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.impl_(); imp.can_truncate(from_glib_borrow::<_, Seekable>(seekable).unsafe_cast_ref()) .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.impl_(); match imp.truncate( from_glib_borrow::<_, Seekable>(seekable).unsafe_cast_ref(), offset, Option::::from_glib_borrow(cancellable) .as_ref() .as_ref(), ) { Ok(()) => glib::ffi::GTRUE, Err(e) => { if !err.is_null() { *err = e.into_raw(); } glib::ffi::GFALSE } } } gio-0.14.8/src/subprocess.rs000064400000000000000000000054050072674642500140550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Cancellable; use crate::Subprocess; use glib::object::IsA; use glib::translate::*; use glib::GString; use libc::c_char; use std::pin::Pin; use std::ptr; impl Subprocess { #[doc(alias = "g_subprocess_communicate_utf8_async")] pub fn communicate_utf8_async< R: FnOnce(Result<(Option, Option), glib::Error>) + Send + 'static, C: IsA, >( &self, stdin_buf: Option, cancellable: Option<&C>, callback: R, ) { 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<(R, *mut c_char)> = Box::new((callback, stdin_buf)); unsafe extern "C" fn communicate_utf8_async_trampoline< R: FnOnce(Result<(Option, Option), glib::Error>) + Send + '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<(R, *mut c_char)> = Box::from_raw(user_data as *mut _); glib::ffi::g_free(callback.1 as *mut _); callback.0(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_async_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.14.8/src/subprocess_launcher.rs000064400000000000000000000035220072674642500157340ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::SubprocessLauncher; #[cfg(any(unix, feature = "dox"))] #[cfg(any(unix, feature = "dox"))] use glib::translate::*; #[cfg(any(unix, all(feature = "dox", unix)))] use std::os::unix::io::IntoRawFd; #[cfg(all(feature = "dox", not(unix)))] pub trait IntoRawFd: Sized { fn into_raw_fd(self) -> i32 { 0 } } impl SubprocessLauncher { #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_fd")] pub fn take_fd(&self, source_fd: F, target_fd: G) { unsafe { ffi::g_subprocess_launcher_take_fd( self.to_glib_none().0, source_fd.into_raw_fd(), target_fd.into_raw_fd(), ); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stderr_fd")] pub fn take_stderr_fd(&self, fd: F) { unsafe { ffi::g_subprocess_launcher_take_stderr_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stdin_fd")] pub fn take_stdin_fd(&self, fd: F) { unsafe { ffi::g_subprocess_launcher_take_stdin_fd(self.to_glib_none().0, fd.into_raw_fd()); } } #[cfg(any(unix, feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(unix)))] #[doc(alias = "g_subprocess_launcher_take_stdout_fd")] pub fn take_stdout_fd(&self, fd: F) { unsafe { ffi::g_subprocess_launcher_take_stdout_fd(self.to_glib_none().0, fd.into_raw_fd()); } } } gio-0.14.8/src/task.rs000064400000000000000000000232740072674642500126330ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::AsyncResult; use crate::Cancellable; use crate::Task; use glib::object::IsA; use glib::translate::*; use libc::c_void; use std::boxed::Box as Box_; use std::ptr; impl Task { #[doc(alias = "g_task_new")] pub fn new, Q: FnOnce(&AsyncResult, Option<&glib::Object>) + 'static>( source_object: Option<&glib::Object>, cancellable: Option<&P>, callback: Q, ) -> Task { let callback_data = Box_::new(callback); unsafe extern "C" fn trampoline< Q: FnOnce(&AsyncResult, Option<&glib::Object>) + 'static, >( source_object: *mut glib::gobject_ffi::GObject, res: *mut ffi::GAsyncResult, user_data: glib::ffi::gpointer, ) { let source_object = Option::::from_glib_borrow(source_object); let res = AsyncResult::from_glib_borrow(res); let callback: Box_ = Box::from_raw(user_data as *mut _); callback(&res, source_object.as_ref().as_ref()); } let callback = trampoline::; unsafe { from_glib_full(ffi::g_task_new( source_object.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_return_error")] pub fn return_error(&self, error: glib::Error) { unsafe { ffi::g_task_return_error(self.to_glib_none().0, error.to_glib_full() as *mut _); } } #[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_run_in_thread")] pub fn run_in_thread(&self, task_func: Q) where Q: FnOnce(&Self, Option<&glib::Object>, Option<&Cancellable>), Q: 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 { if !ffi::g_task_get_task_data(self.to_glib_none().0).is_null() { panic!("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 Q: FnOnce(&Task, Option<&glib::Object>, Option<&Cancellable>), Q: Send + 'static, { let task = Task::from_glib_borrow(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.as_ref(), source_object.as_ref().as_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)); } } pub fn return_value(&self, result: &glib::Value) { unsafe extern "C" fn value_free(value: *mut c_void) { glib::gobject_ffi::g_value_unset(value as *mut glib::gobject_ffi::GValue); glib::ffi::g_free(value); } unsafe { let value: *mut glib::gobject_ffi::GValue = <&glib::Value>::to_glib_full_from_slice(&[result]); ffi::g_task_return_pointer( self.to_glib_none().0, value as *mut c_void, Some(value_free), ) } } pub fn propagate_value(&self) -> Result { unsafe { let mut error = ptr::null_mut(); let value = ffi::g_task_propagate_pointer(self.to_glib_none().0, &mut error); if !error.is_null() { return Err(from_glib_full(error)); } let value = from_glib_full(value as *mut glib::gobject_ffi::GValue); match value { Some(value) => Ok(value), None => Ok(glib::Value::from_type(glib::types::Type::UNIT)), } } } } #[cfg(test)] mod test { use super::*; use crate::prelude::*; use crate::test_util::run_async_local; #[test] fn test_int_async_result() { match run_async_local(|tx, l| { let c = crate::Cancellable::new(); let t = crate::Task::new( None, Some(&c), move |a: &AsyncResult, _b: Option<&glib::Object>| { let t = a.downcast_ref::().unwrap(); tx.send(t.propagate_value()).unwrap(); l.quit(); }, ); t.return_value(&100_i32.to_value()); }) { Err(_) => panic!(), Ok(i) => { assert_eq!(i.get::().unwrap(), 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 ParentType = glib::Object; 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(&[]).expect("Failed to create MySimpleObject") } #[doc(alias = "get_size")] pub fn size(&self) -> Option { let imp = MySimpleObjectPrivate::from_instance(self); *imp.size.borrow() } pub fn set_size(&self, size: i64) { let imp = MySimpleObjectPrivate::from_instance(self); imp.size.borrow_mut().replace(size); } } impl Default for MySimpleObject { fn default() -> Self { Self::new() } } match run_async_local(|tx, l| { let c = crate::Cancellable::new(); let t = crate::Task::new( None, Some(&c), move |a: &AsyncResult, _b: Option<&glib::Object>| { let t = a.downcast_ref::().unwrap(); tx.send(t.propagate_value()).unwrap(); l.quit(); }, ); let my_object = MySimpleObject::new(); my_object.set_size(100); t.return_value(&my_object.upcast::().to_value()); }) { Err(_) => panic!(), Ok(o) => { let o = o .get::() .unwrap() .downcast::() .unwrap(); assert_eq!(o.size(), Some(100)); } } } #[test] fn test_error() { match run_async_local(|tx, l| { let c = crate::Cancellable::new(); let t = crate::Task::new( None, Some(&c), move |a: &AsyncResult, _b: Option<&glib::Object>| { let t = a.downcast_ref::().unwrap(); tx.send(t.propagate_value()).unwrap(); l.quit(); }, ); t.return_error(glib::Error::new( crate::IOErrorEnum::WouldBlock, "WouldBlock", )); }) { Err(e) => match e.kind().unwrap() { crate::IOErrorEnum::WouldBlock => {} _ => panic!(), }, Ok(_) => panic!(), } } #[test] fn test_cancelled() { match run_async_local(|tx, l| { let c = crate::Cancellable::new(); let t = crate::Task::new( None, Some(&c), move |a: &AsyncResult, _b: Option<&glib::Object>| { let t = a.downcast_ref::().unwrap(); tx.send(t.propagate_value()).unwrap(); l.quit(); }, ); c.cancel(); t.return_error_if_cancelled(); }) { Err(e) => match e.kind().unwrap() { crate::IOErrorEnum::Cancelled => {} _ => panic!(), }, Ok(_) => panic!(), } } } gio-0.14.8/src/test_util.rs000064400000000000000000000017220072674642500136770ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::*; use std::sync::mpsc::{channel, Sender}; #[allow(dead_code)] 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.push_thread_default(); c.invoke(move || { start(tx, l_clone); }); l.run(); c.pop_thread_default(); rx.recv().unwrap() } #[allow(dead_code)] 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.push_thread_default(); c.invoke_local(move || { start(tx, l_clone); }); l.run(); c.pop_thread_default(); rx.recv().unwrap() } gio-0.14.8/src/threaded_socket_service.rs000064400000000000000000000010760072674642500165350ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use glib::translate::FromGlibPtrFull; use glib::Cast; use crate::SocketService; use crate::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(ffi::g_threaded_socket_service_new(max_threads)) .unsafe_cast() } } } gio-0.14.8/src/tls_connection.rs000064400000000000000000000027530072674642500147110ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. #[cfg(any(feature = "v2_66", feature = "dox"))] use crate::TlsChannelBindingType; use crate::TlsConnection; #[cfg(any(feature = "v2_66", feature = "dox"))] use glib::translate::*; use glib::IsA; #[cfg(any(feature = "v2_66", feature = "dox"))] use std::ptr; pub trait TlsConnectionExtManual { #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", 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; } impl> TlsConnectionExtManual for O { #[cfg(any(feature = "v2_66", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_66")))] fn channel_binding_data( &self, type_: TlsChannelBindingType, ) -> Result { unsafe { let data = ptr::null_mut(); let mut error = ptr::null_mut(); let _ = 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)) } } } } gio-0.14.8/src/unix_fd_list.rs000064400000000000000000000054150072674642500143550ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::UnixFDList; use glib::object::IsA; use glib::translate::*; use std::{mem, ptr}; #[cfg(unix)] use std::os::unix::io::{AsRawFd, IntoRawFd, RawFd}; #[cfg(all(not(unix), feature = "dox"))] use socket::{AsRawFd, IntoRawFd, RawFd}; impl UnixFDList { #[doc(alias = "g_unix_fd_list_new_from_array")] pub fn from_array(fds: T) -> UnixFDList where T: IntoIterator, T::Item: IntoRawFd, { 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, )) } } } pub trait UnixFDListExtManual: Sized { #[doc(alias = "g_unix_fd_list_append")] fn append(&self, fd: T) -> Result; #[doc(alias = "g_unix_fd_list_get")] fn get(&self, index_: i32) -> Result; #[doc(alias = "g_unix_fd_list_peek_fds")] fn peek_fds(&self) -> Vec; #[doc(alias = "g_unix_fd_list_steal_fds")] fn steal_fds(&self) -> Vec; } impl> UnixFDListExtManual for O { 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)) } } } 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)) } } } 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 } } 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 } } } gio-0.14.8/src/unix_input_stream.rs000064400000000000000000000036130072674642500154410ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::InputStream; use crate::UnixInputStream; use glib::object::{Cast, IsA}; use glib::translate::*; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(all(not(unix), feature = "dox"))] use socket::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; impl UnixInputStream { #[allow(clippy::missing_safety_doc)] #[doc(alias = "g_unix_input_stream_new")] pub unsafe fn take_fd(fd: T) -> 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() } #[allow(clippy::missing_safety_doc)] #[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 _ } } } pub trait UnixInputStreamExtManual: Sized { #[doc(alias = "g_unix_input_stream_get_fd")] #[doc(alias = "get_fd")] fn fd(&self) -> T; #[allow(clippy::missing_safety_doc)] #[doc(alias = "g_unix_input_stream_set_close_fd")] unsafe fn set_close_fd(&self, close_fd: bool); } impl> UnixInputStreamExtManual for O { fn fd(&self) -> T { unsafe { T::from_raw_fd(ffi::g_unix_input_stream_get_fd( self.as_ref().to_glib_none().0, )) } } 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()); } } gio-0.14.8/src/unix_mount_entry.rs000064400000000000000000000141500072674642500153100ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::Icon; use crate::UnixMountEntry; use glib::translate::*; use glib::GString; use std::cmp; use std::mem; 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) } } #[cfg(any(feature = "v2_52", feature = "dox"))] #[cfg_attr(feature = "dox", doc(cfg(feature = "v2_52")))] #[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(any(feature = "v2_58", feature = "dox"))] #[cfg_attr(feature = "dox", 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(any(feature = "v2_60", feature = "dox"))] #[cfg_attr(feature = "dox", 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 { self.compare(other).partial_cmp(&0) } } impl Ord for UnixMountEntry { #[inline] fn cmp(&self, other: &Self) -> cmp::Ordering { self.compare(other).cmp(&0) } } gio-0.14.8/src/unix_mount_point.rs000064400000000000000000000015340072674642500153020ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::UnixMountPoint; use glib::translate::*; use std::mem; impl UnixMountPoint { #[cfg(any(unix, feature = "dox"))] #[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.14.8/src/unix_output_stream.rs000064400000000000000000000035100072674642500156360ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::OutputStream; use crate::UnixOutputStream; use glib::object::{Cast, IsA}; use glib::translate::*; #[cfg(unix)] use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; #[cfg(all(not(unix), feature = "dox"))] use socket::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; impl UnixOutputStream { #[doc(alias = "g_unix_output_stream_new")] pub unsafe fn take_fd(fd: T) -> 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() } #[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 _ } } } pub trait UnixOutputStreamExtManual: Sized { #[doc(alias = "g_unix_output_stream_get_fd")] #[doc(alias = "get_fd")] fn fd(&self) -> T; #[doc(alias = "g_unix_output_stream_set_close_fd")] unsafe fn set_close_fd(&self, close_fd: bool); } impl> UnixOutputStreamExtManual for O { fn fd(&self) -> T { unsafe { T::from_raw_fd(ffi::g_unix_output_stream_get_fd( self.as_ref().to_glib_none().0, )) } } 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(), ); } } gio-0.14.8/src/unix_socket_address.rs000064400000000000000000000062760072674642500157340ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::SocketAddress; use crate::UnixSocketAddress; use crate::UnixSocketAddressType; use glib::translate::*; #[cfg(not(feature = "dox"))] use std::ffi::OsStr; #[cfg(unix)] #[cfg(not(feature = "dox"))] use std::os::unix::ffi::OsStrExt; use std::path; use std::ptr; use std::slice; #[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 (path, len) = match address_type { Path(path) => (path.to_glib_none().0, path.as_os_str().len()), Abstract(path) | AbstractPadded(path) => { (path.to_glib_none().0 as *mut libc::c_char, path.len()) } Anonymous => (ptr::null_mut(), 0), }; unsafe { SocketAddress::from_glib_full(ffi::g_unix_socket_address_new_with_type( path, len as i32, type_.into_glib(), )) .unsafe_cast() } } } pub trait UnixSocketAddressExtManual { #[doc(alias = "g_unix_socket_address_get_path")] #[doc(alias = "get_path")] fn path(&self) -> Option; } impl> UnixSocketAddressExtManual for O { 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() { &[] } else { slice::from_raw_parts(path as *const u8, self.path_len()) } }; match self.address_type() { UnixSocketAddressType::Anonymous => Some(Anonymous), #[cfg(not(feature = "dox"))] UnixSocketAddressType::Path => Some(Path(path::Path::new(OsStr::from_bytes(path)))), #[cfg(feature = "dox")] UnixSocketAddressType::Path => unreachable!(), UnixSocketAddressType::Abstract => Some(Abstract(path)), UnixSocketAddressType::AbstractPadded => Some(AbstractPadded(path)), UnixSocketAddressType::Invalid | UnixSocketAddressType::__Unknown(_) => None, } } } gio-0.14.8/src/win32_input_stream.rs000064400000000000000000000055640072674642500154270ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::InputStream; use glib::object::{Cast, IsA}; use glib::translate::*; use std::fmt; use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; glib::wrapper! { pub struct Win32InputStream(Object) @extends InputStream; match fn { type_ => || ffi::g_win32_input_stream_get_type(), } } pub const NONE_WIN32_INPUT_STREAM: Option<&Win32InputStream> = None; pub trait Win32InputStreamExt: 'static { #[doc(alias = "g_win32_input_stream_get_close_handle")] #[doc(alias = "get_close_handle")] fn closes_handle(&self) -> bool; } impl> Win32InputStreamExt for O { fn closes_handle(&self) -> bool { unsafe { from_glib(ffi::g_win32_input_stream_get_close_handle( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for Win32InputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Win32InputStream") } } impl Win32InputStream { #[doc(alias = "g_win32_input_stream_new")] #[allow(clippy::missing_safety_doc)] pub unsafe fn take_handle(handle: T) -> 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() } #[doc(alias = "g_win32_input_stream_new")] #[allow(clippy::missing_safety_doc)] 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 _ } } } pub trait Win32InputStreamExtManual: Sized { #[doc(alias = "g_win32_input_stream_get_handle")] #[doc(alias = "get_handle")] fn handle(&self) -> T; #[doc(alias = "g_win32_input_stream_set_close_handle")] #[allow(clippy::missing_safety_doc)] unsafe fn set_close_handle(&self, close_handle: bool); } impl> Win32InputStreamExtManual for O { fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_input_stream_get_handle( self.as_ref().to_glib_none().0, )) } } 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(), ); } } gio-0.14.8/src/win32_output_stream.rs000064400000000000000000000056250072674642500156260ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::OutputStream; use glib::object::{Cast, IsA}; use glib::translate::*; use std::fmt; use std::os::windows::io::{AsRawHandle, FromRawHandle, IntoRawHandle, RawHandle}; glib::wrapper! { pub struct Win32OutputStream(Object) @extends OutputStream; match fn { type_ => || ffi::g_win32_output_stream_get_type(), } } pub const NONE_WIN32_OUTPUT_STREAM: Option<&Win32OutputStream> = None; pub trait Win32OutputStreamExt: 'static { #[doc(alias = "g_win32_output_stream_get_close_handle")] #[doc(alias = "get_close_handle")] fn closes_handle(&self) -> bool; } impl> Win32OutputStreamExt for O { fn closes_handle(&self) -> bool { unsafe { from_glib(ffi::g_win32_output_stream_get_close_handle( self.as_ref().to_glib_none().0, )) } } } impl fmt::Display for Win32OutputStream { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str("Win32OutputStream") } } impl Win32OutputStream { #[doc(alias = "g_win32_output_stream_new")] #[allow(clippy::missing_safety_doc)] pub unsafe fn take_handle(handle: T) -> 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() } #[doc(alias = "g_win32_output_stream_new")] #[allow(clippy::missing_safety_doc)] 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 _ } } } pub trait Win32OutputStreamExtManual: Sized { #[doc(alias = "g_win32_output_stream_get_handle")] #[doc(alias = "get_handle")] fn handle(&self) -> T; #[doc(alias = "g_win32_output_stream_set_close_handle")] #[allow(clippy::missing_safety_doc)] unsafe fn set_close_handle(&self, close_handle: bool); } impl> Win32OutputStreamExtManual for O { fn handle(&self) -> T { unsafe { T::from_raw_handle(ffi::g_win32_output_stream_get_handle( self.as_ref().to_glib_none().0, )) } } 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(), ); } } gio-0.14.8/src/write_output_stream.rs000064400000000000000000000260000072674642500160040ustar 00000000000000// Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; use crate::subclass::prelude::*; use crate::OutputStream; use std::any::Any; use std::io::{Seek, Write}; use crate::read_input_stream::std_error_to_gio_error; mod imp { use super::*; use std::cell::RefCell; 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"; type Type = super::WriteOutputStream; type ParentType = OutputStream; type Interfaces = (crate::Seekable,); } impl ObjectImpl for WriteOutputStream {} impl OutputStreamImpl for WriteOutputStream { fn write( &self, _stream: &Self::Type, 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, _stream: &Self::Type, _cancellable: Option<&crate::Cancellable>, ) -> Result<(), glib::Error> { let _ = self.write.borrow_mut().take(); Ok(()) } fn flush( &self, _stream: &Self::Type, _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, _seekable: &Self::Type) -> 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, _seekable: &Self::Type) -> bool { let write = self.write.borrow(); matches!(*write, Some(Writer::WriteSeek(_))) } fn seek( &self, _seekable: &Self::Type, 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, _seekable: &Self::Type) -> bool { false } fn truncate( &self, _seekable: &Self::Type, _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 = glib::Object::new(&[]).expect("Failed to create write input stream"); let imp = imp::WriteOutputStream::from_instance(&obj); *imp.write.borrow_mut() = Some(imp::Writer::Write(AnyWriter::new(write))); obj } pub fn new_seekable(write: W) -> WriteOutputStream { let obj = glib::Object::new(&[]).expect("Failed to create write input stream"); let imp = imp::WriteOutputStream::from_instance(&obj); *imp.write.borrow_mut() = Some(imp::Writer::WriteSeek(AnyWriter::new_seekable(write))); obj } pub fn close_and_take(&self) -> Box { let imp = imp::WriteOutputStream::from_instance(self); let inner = imp.write.borrow_mut().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::NONE_CANCELLABLE); 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 super::*; use std::io::Cursor; #[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::NONE_CANCELLABLE), 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::NONE_CANCELLABLE), Ok(10) ); assert!(stream.can_seek()); assert_eq!( stream.seek(0, glib::SeekType::Set, crate::NONE_CANCELLABLE), Ok(()) ); assert_eq!( stream.write( &[11, 12, 13, 14, 15, 16, 17, 18, 19, 20], crate::NONE_CANCELLABLE ), 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.14.8/tests/check_gir.rs000064400000000000000000000003640072674642500141550ustar 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.to_string()); assert_eq!(res.nb_errors, 0); } gio-0.14.8/tests/com.github.gtk-rs.test.gschema.xml000064400000000000000000000005240072674642500202420ustar 00000000000000 "Good" true gio-0.14.8/tests/std_io_copy.rs000064400000000000000000000011110072674642500145410ustar 00000000000000#![cfg(feature = "v2_36")] use gio::prelude::*; use std::io; #[test] #[cfg(feature = "v2_36")] fn std_io_copy_with_gio() { let bytes = glib::Bytes::from_owned([1, 2, 3]); let mut read = gio::MemoryInputStream::new_from_bytes(&bytes).into_read(); let mut write = gio::MemoryOutputStream::new_resizable().into_write(); let result = io::copy(&mut read, &mut write); let out_stream = write.into_output_stream(); out_stream.close(gio::NONE_CANCELLABLE).unwrap(); assert_eq!(result.unwrap(), 3); assert_eq!(out_stream.steal_as_bytes().unwrap(), bytes); }