pub struct DBusConnection { /* private fields */ }
Expand description
The GDBusConnection
type is used for D-Bus connections to remote
peers such as a message buses.
It is a low-level API that offers a lot of flexibility. For instance,
it lets you establish a connection over any transport that can by represented
as a IOStream
.
This class is rarely used directly in D-Bus clients. If you are writing
a D-Bus client, it is often easier to use the bus_own_name()
,
bus_watch_name()
or DBusProxy::for_bus()
APIs.
As an exception to the usual GLib rule that a particular object must not
be used by two threads at the same time, GDBusConnection
s methods may be
called from any thread. This is so that bus_get()
and
bus_get_sync()
can safely return the same GDBusConnection
when
called from any thread.
Most of the ways to obtain a GDBusConnection
automatically initialize it
(i.e. connect to D-Bus): for instance, new()
and
bus_get()
, and the synchronous versions of those methods, give you
an initialized connection. Language bindings for GIO should use
Initable::new()
or [AsyncInitable::new_async()
][crate::AsyncInitable::new_async()], which also
initialize the connection.
If you construct an uninitialized GDBusConnection
, such as via
glib::Object::new()
, you must initialize it via InitableExt::init()
or
AsyncInitableExt::init_async()
before using its methods or properties.
Calling methods or accessing properties on a GDBusConnection
that has not
completed initialization successfully is considered to be invalid, and leads
to undefined behaviour. In particular, if initialization fails with a
GError
, the only valid thing you can do with that GDBusConnection
is to
free it with GObject::Object::unref()
.
§An example D-Bus server
Here is an example for a D-Bus server: gdbus-example-server.c
§An example for exporting a subtree
Here is an example for exporting a subtree: gdbus-example-subtree.c
§An example for file descriptor passing
Here is an example for passing UNIX file descriptors: gdbus-unix-fd-client.c
§An example for exporting a GObject
Here is an example for exporting a #GObject: gdbus-example-export.c
§Properties
§address
A D-Bus address specifying potential endpoints that can be used when establishing the connection.
Writeable | Construct Only
§authentication-observer
A #GDBusAuthObserver object to assist in the authentication process or None
.
Writeable | Construct Only
§capabilities
Flags from the #GDBusCapabilityFlags enumeration representing connection features negotiated with the other peer.
Readable
§closed
A boolean specifying whether the connection has been closed.
Readable
§exit-on-close
A boolean specifying whether the process will be terminated (by
calling raise(SIGTERM)
) if the connection is closed by the
remote peer.
Note that #GDBusConnection objects returned by g_bus_get_finish()
and g_bus_get_sync() will (usually) have this property set to true
.
Readable | Writeable
§flags
Flags from the #GDBusConnectionFlags enumeration.
Readable | Writeable | Construct Only
§guid
The GUID of the peer performing the role of server when authenticating.
If you are constructing a #GDBusConnection and pass
DBusConnectionFlags::AUTHENTICATION_SERVER
in the
#GDBusConnection:flags property then you must also set this
property to a valid guid.
If you are constructing a #GDBusConnection and pass
DBusConnectionFlags::AUTHENTICATION_CLIENT
in the
#GDBusConnection:flags property you will be able to read the GUID
of the other peer here after the connection has been successfully
initialized.
Note that the D-Bus specification uses the term ‘UUID’ to refer to this, whereas GLib consistently uses the term ‘GUID’ for historical reasons.
Despite its name, the format of #GDBusConnection:guid does not follow RFC 4122 or the Microsoft GUID format.
Readable | Writeable | Construct Only
§stream
The underlying #GIOStream used for I/O.
If this is passed on construction and is a #GSocketConnection, then the corresponding #GSocket will be put into non-blocking mode.
While the #GDBusConnection is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly.
Readable | Writeable | Construct Only
§unique-name
The unique name as assigned by the message bus or None
if the
connection is not open or not a message bus connection.
Readable
§Signals
§closed
Emitted when the connection is closed.
The cause of this event can be
-
If g_dbus_connection_close() is called. In this case @remote_peer_vanished is set to
false
and @error isNone
. -
If the remote peer closes the connection. In this case @remote_peer_vanished is set to
true
and @error is set. -
If the remote peer sends invalid or malformed data. In this case @remote_peer_vanished is set to
false
and @error is set.
Upon receiving this signal, you should give up your reference to @connection. You are guaranteed that this signal is emitted only once.
§Implements
[trait@glib::ObjectExt
], AsyncInitableExt
, InitableExt
GLib type: GObject with reference counted clone semantics.
Implementations§
Source§impl DBusConnection
impl DBusConnection
Sourcepub fn register_object<'a>(
&'a self,
object_path: &'a str,
interface_info: &'a DBusInterfaceInfo,
) -> RegistrationBuilder<'a>
pub fn register_object<'a>( &'a self, object_path: &'a str, interface_info: &'a DBusInterfaceInfo, ) -> RegistrationBuilder<'a>
Registers callbacks for exported objects at @object_path with the D-Bus interface that is described in @interface_info.
Calls to functions in @vtable (and @user_data_free_func) will happen in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from.
Note that all #GVariant values passed to functions in @vtable will match
the signature given in @interface_info - if a remote caller passes
incorrect values, the org.freedesktop.DBus.Error.InvalidArgs
is returned to the remote caller.
Additionally, if the remote caller attempts to invoke methods or
access properties not mentioned in @interface_info the
org.freedesktop.DBus.Error.UnknownMethod
resp.
org.freedesktop.DBus.Error.InvalidArgs
errors
are returned to the caller.
It is considered a programming error if the #GDBusInterfaceGetPropertyFunc function in @vtable returns a #GVariant of incorrect type.
If an existing callback is already registered at @object_path and
@interface_name, then @error is set to IOErrorEnum::Exists
.
GDBus automatically implements the standard D-Bus interfaces org.freedesktop.DBus.Properties, org.freedesktop.DBus.Introspectable and org.freedesktop.Peer, so you don’t have to implement those for the objects you export. You can implement org.freedesktop.DBus.Properties yourself, e.g. to handle getting and setting of properties asynchronously.
Note that the reference count on @interface_info will be incremented by 1 (unless allocated statically, e.g. if the reference count is -1, see g_dbus_interface_info_ref()) for as long as the object is exported. Also note that @vtable will be copied.
See this [server][gdbus-server] for an example of how to use this method.
§object_path
the object path to register at
§interface_info
introspection data for the interface
§vtable
a #GDBusInterfaceVTable to call into or None
§Returns
0 if @error is set, otherwise a registration id (never 0) that can be used with g_dbus_connection_unregister_object()
Sourcepub fn unregister_object(
&self,
registration_id: RegistrationId,
) -> Result<(), BoolError>
pub fn unregister_object( &self, registration_id: RegistrationId, ) -> Result<(), BoolError>
Sourcepub fn export_action_group<P: IsA<ActionGroup>>(
&self,
object_path: &str,
action_group: &P,
) -> Result<ActionGroupExportId, Error>
pub fn export_action_group<P: IsA<ActionGroup>>( &self, object_path: &str, action_group: &P, ) -> Result<ActionGroupExportId, Error>
Exports @action_group on @self at @object_path.
The implemented D-Bus API should be considered private. It is subject to change in the future.
A given object path can only have one action group exported on it. If this constraint is violated, the export will fail and 0 will be returned (with @error set accordingly).
You can unexport the action group using
unexport_action_group()
with the return value of
this function.
The thread default main context is taken at the time of this call. All incoming action activations and state change requests are reported from this context. Any changes on the action group that cause it to emit signals must also come from this same context. Since incoming action activations and state change requests are rather likely to cause changes on the action group, this effectively limits a given action group to being exported from only one main context.
§object_path
a D-Bus object path
§action_group
an action group
§Returns
the ID of the export (never zero), or 0 in case of failure
Sourcepub fn unexport_action_group(&self, export_id: ActionGroupExportId)
pub fn unexport_action_group(&self, export_id: ActionGroupExportId)
Reverses the effect of a previous call to
export_action_group()
.
It is an error to call this function with an ID that wasn’t returned from
export_action_group()
or to call it with the same
ID more than once.
§export_id
the ID from export_action_group()
Exports @menu on @self at @object_path.
The implemented D-Bus API should be considered private. It is subject to change in the future.
An object path can only have one menu model exported on it. If this constraint is violated, the export will fail and 0 will be returned (with @error set accordingly).
Exporting menus with sections containing more than
G_MENU_EXPORTER_MAX_SECTION_SIZE
items is not supported and results in
undefined behavior.
You can unexport the menu model using g_dbus_connection_unexport_menu_model() with the return value of this function.
§object_path
a D-Bus object path
§menu
a #GMenuModel
§Returns
the ID of the export (never zero), or 0 in case of failure
Reverses the effect of a previous call to g_dbus_connection_export_menu_model().
It is an error to call this function with an ID that wasn’t returned from g_dbus_connection_export_menu_model() or to call it with the same ID more than once.
§export_id
the ID from g_dbus_connection_export_menu_model()
Sourcepub fn add_filter<P: Fn(&DBusConnection, &DBusMessage, bool) -> Option<DBusMessage> + 'static>(
&self,
filter_function: P,
) -> FilterId
pub fn add_filter<P: Fn(&DBusConnection, &DBusMessage, bool) -> Option<DBusMessage> + 'static>( &self, filter_function: P, ) -> FilterId
Adds a message filter. Filters are handlers that are run on all incoming and outgoing messages, prior to standard dispatch. Filters are run in the order that they were added. The same handler can be added as a filter more than once, in which case it will be run more than once. Filters added during a filter callback won’t be run on the message being processed. Filter functions are allowed to modify and even drop messages.
Note that filters are run in a dedicated message handling thread so they can’t block and, generally, can’t do anything but signal a worker thread. Also note that filters are rarely needed - use API such as g_dbus_connection_send_message_with_reply(), g_dbus_connection_signal_subscribe() or g_dbus_connection_call() instead.
If a filter consumes an incoming message the message is not dispatched anywhere else - not even the standard dispatch machinery (that API such as g_dbus_connection_signal_subscribe() and g_dbus_connection_send_message_with_reply() relies on) will see the message. Similarly, if a filter consumes an outgoing message, the message will not be sent to the other peer.
If @user_data_free_func is non-None
, it will be called (in the
thread-default main context of the thread you are calling this
method from) at some point after @user_data is no longer
needed. (It is not guaranteed to be called synchronously when the
filter is removed, and may be called after @self has been
destroyed.)
§filter_function
a filter function
§Returns
a filter identifier that can be used with g_dbus_connection_remove_filter()
Sourcepub fn remove_filter(&self, filter_id: FilterId)
pub fn remove_filter(&self, filter_id: FilterId)
Removes a filter.
Note that since filters run in a different thread, there is a race condition where it is possible that the filter will be running even after calling g_dbus_connection_remove_filter(), so you cannot just free data that the filter might be using. Instead, you should pass a #GDestroyNotify to g_dbus_connection_add_filter(), which will be called when it is guaranteed that the data is no longer needed.
§filter_id
an identifier obtained from g_dbus_connection_add_filter()
Sourcepub fn signal_subscribe<P: Fn(&DBusConnection, &str, &str, &str, &str, &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
pub fn signal_subscribe<P: Fn(&DBusConnection, &str, &str, &str, &str, &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
Subscribes to signals on @self and invokes @callback whenever the signal is received. Note that @callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from.
If @self is not a message bus connection, @sender must be
None
.
If @sender is a well-known name note that @callback is invoked with the unique name for the owner of @sender, not the well-known name as one would expect. This is because the message bus rewrites the name. As such, to avoid certain race conditions, users should be tracking the name owner of the well-known name and use that when processing the received signal.
If one of DBusSignalFlags::MATCH_ARG0_NAMESPACE
or
DBusSignalFlags::MATCH_ARG0_PATH
are given, @arg0 is
interpreted as part of a namespace or path. The first argument
of a signal is matched against that part as specified by D-Bus.
If @user_data_free_func is non-None
, it will be called (in the
thread-default main context of the thread you are calling this
method from) at some point after @user_data is no longer
needed. (It is not guaranteed to be called synchronously when the
signal is unsubscribed from, and may be called after @self
has been destroyed.)
As @callback is potentially invoked in a different thread from where it’s emitted, it’s possible for this to happen after g_dbus_connection_signal_unsubscribe() has been called in another thread. Due to this, @user_data should have a strong reference which is freed with @user_data_free_func, rather than pointing to data whose lifecycle is tied to the signal subscription. For example, if a #GObject is used to store the subscription ID from g_dbus_connection_signal_subscribe(), a strong reference to that #GObject must be passed to @user_data, and g_object_unref() passed to @user_data_free_func. You are responsible for breaking the resulting reference count cycle by explicitly unsubscribing from the signal when dropping the last external reference to the #GObject. Alternatively, a weak reference may be used.
It is guaranteed that if you unsubscribe from a signal using g_dbus_connection_signal_unsubscribe() from the same thread which made the corresponding g_dbus_connection_signal_subscribe() call, @callback will not be invoked after g_dbus_connection_signal_unsubscribe() returns.
The returned subscription identifier is an opaque value which is guaranteed to never be zero.
This function can never fail.
§sender
sender name to match on (unique or well-known name)
or None
to listen from all senders
§interface_name
D-Bus interface name to match on or None
to
match on all interfaces
§member
D-Bus signal name to match on or None
to match on
all signals
§object_path
object path to match on or None
to match on
all object paths
§arg0
contents of first string argument to match on or None
to match on all kinds of arguments
§flags
#GDBusSignalFlags describing how arg0 is used in subscribing to the signal
§callback
callback to invoke when there is a signal matching the requested data
§Returns
a subscription identifier that can be used with g_dbus_connection_signal_unsubscribe()
Sourcepub fn signal_unsubscribe(&self, subscription_id: SignalSubscriptionId)
pub fn signal_unsubscribe(&self, subscription_id: SignalSubscriptionId)
Unsubscribes from signals.
Note that there may still be D-Bus traffic to process (relating to this
signal subscription) in the current thread-default #GMainContext after this
function has returned. You should continue to iterate the #GMainContext
until the #GDestroyNotify function passed to
g_dbus_connection_signal_subscribe() is called, in order to avoid memory
leaks through callbacks queued on the #GMainContext after it’s stopped being
iterated.
Alternatively, any idle source with a priority lower than G_PRIORITY_DEFAULT
that was scheduled after unsubscription, also indicates that all resources
of this subscription are released.
§subscription_id
a subscription id obtained from g_dbus_connection_signal_subscribe()
Source§impl DBusConnection
impl DBusConnection
Sourcepub fn for_address_sync(
address: &str,
flags: DBusConnectionFlags,
observer: Option<&DBusAuthObserver>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<DBusConnection, Error>
pub fn for_address_sync( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<DBusConnection, Error>
Synchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by @address which must be in the D-Bus address format.
This constructor can only be used to initiate client-side
connections - use g_dbus_connection_new_sync() if you need to act
as the server. In particular, @flags cannot contain the
DBusConnectionFlags::AUTHENTICATION_SERVER
,
DBusConnectionFlags::AUTHENTICATION_ALLOW_ANONYMOUS
or
DBusConnectionFlags::AUTHENTICATION_REQUIRE_SAME_USER
flags.
This is a synchronous failable constructor. See g_dbus_connection_new_for_address() for the asynchronous version.
If @observer is not None
it may be used to control the
authentication process.
§address
a D-Bus address
§flags
flags describing how to make the connection
§observer
a #GDBusAuthObserver or None
§cancellable
a #GCancellable or None
§Returns
a #GDBusConnection or None
if @error is set.
Free with g_object_unref().
Sourcepub fn new_sync(
stream: &impl IsA<IOStream>,
guid: Option<&str>,
flags: DBusConnectionFlags,
observer: Option<&DBusAuthObserver>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<DBusConnection, Error>
pub fn new_sync( stream: &impl IsA<IOStream>, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<DBusConnection, Error>
Synchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by @stream.
If @stream is a #GSocketConnection, then the corresponding #GSocket will be put into non-blocking mode.
The D-Bus connection will interact with @stream from a worker thread. As a result, the caller should not interact with @stream after this method has been called, except by calling g_object_unref() on it.
If @observer is not None
it may be used to control the
authentication process.
This is a synchronous failable constructor. See g_dbus_connection_new() for the asynchronous version.
§stream
a #GIOStream
§guid
the GUID to use if authenticating as a server or None
§flags
flags describing how to make the connection
§observer
a #GDBusAuthObserver or None
§cancellable
a #GCancellable or None
§Returns
a #GDBusConnection or None
if @error is set.
Free with g_object_unref().
Sourcepub fn call<P: FnOnce(Result<Variant, Error>) + 'static>(
&self,
bus_name: Option<&str>,
object_path: &str,
interface_name: &str,
method_name: &str,
parameters: Option<&Variant>,
reply_type: Option<&VariantTy>,
flags: DBusCallFlags,
timeout_msec: i32,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
pub fn call<P: FnOnce(Result<Variant, Error>) + 'static>( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously invokes the @method_name method on the @interface_name D-Bus interface on the remote object at @object_path owned by @bus_name.
If @self is closed then the operation will fail with
IOErrorEnum::Closed
. If @cancellable is canceled, the operation will
fail with IOErrorEnum::Cancelled
. If @parameters contains a value
not compatible with the D-Bus protocol, the operation fails with
IOErrorEnum::InvalidArgument
.
If @reply_type is non-None
then the reply will be checked for having this type and an
error will be raised if it does not match. Said another way, if you give a @reply_type
then any non-None
return value will be of this type. Unless it’s
G_VARIANT_TYPE_UNIT
, the @reply_type will be a tuple containing one or more
values.
If the @parameters #GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.:
⚠️ The following code is in C ⚠️
g_dbus_connection_call (connection,
"org.freedesktop.StringThings",
"/org/freedesktop/StringThings",
"org.freedesktop.StringThings",
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
(GAsyncReadyCallback) two_strings_done,
NULL);
This is an asynchronous method. When the operation is finished, @callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call g_dbus_connection_call_finish() to get the result of the operation. See g_dbus_connection_call_sync() for the synchronous version of this function.
If @callback is None
then the D-Bus method call message will be sent with
the DBusMessageFlags::NO_REPLY_EXPECTED
flag set.
§bus_name
a unique or well-known bus name or None
if
@self is not a message bus connection
§object_path
path of remote object
§interface_name
D-Bus interface to invoke method on
§method_name
the name of the method to invoke
§parameters
a #GVariant tuple with parameters for the method
or None
if not passing parameters
§reply_type
the expected type of the reply (which will be a
tuple), or None
§flags
flags from the #GDBusCallFlags enumeration
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request
is satisfied or None
if you don’t care about the result of the
method invocation
pub fn call_future( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, ) -> Pin<Box_<dyn Future<Output = Result<Variant, Error>> + 'static>>
Sourcepub fn call_sync(
&self,
bus_name: Option<&str>,
object_path: &str,
interface_name: &str,
method_name: &str,
parameters: Option<&Variant>,
reply_type: Option<&VariantTy>,
flags: DBusCallFlags,
timeout_msec: i32,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<Variant, Error>
pub fn call_sync( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<Variant, Error>
Synchronously invokes the @method_name method on the @interface_name D-Bus interface on the remote object at @object_path owned by @bus_name.
If @self is closed then the operation will fail with
IOErrorEnum::Closed
. If @cancellable is canceled, the
operation will fail with IOErrorEnum::Cancelled
. If @parameters
contains a value not compatible with the D-Bus protocol, the operation
fails with IOErrorEnum::InvalidArgument
.
If @reply_type is non-None
then the reply will be checked for having
this type and an error will be raised if it does not match. Said
another way, if you give a @reply_type then any non-None
return
value will be of this type.
If the @parameters #GVariant is floating, it is consumed. This allows convenient ‘inline’ use of g_variant_new(), e.g.:
⚠️ The following code is in C ⚠️
g_dbus_connection_call_sync (connection,
"org.freedesktop.StringThings",
"/org/freedesktop/StringThings",
"org.freedesktop.StringThings",
"TwoStrings",
g_variant_new ("(ss)",
"Thing One",
"Thing Two"),
NULL,
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
&error);
The calling thread is blocked until a reply is received. See g_dbus_connection_call() for the asynchronous version of this method.
§bus_name
a unique or well-known bus name or None
if
@self is not a message bus connection
§object_path
path of remote object
§interface_name
D-Bus interface to invoke method on
§method_name
the name of the method to invoke
§parameters
a #GVariant tuple with parameters for the method
or None
if not passing parameters
§reply_type
the expected type of the reply, or None
§flags
flags from the #GDBusCallFlags enumeration
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§cancellable
a #GCancellable or None
§Returns
None
if @error is set. Otherwise a non-floating
#GVariant tuple with return values. Free with g_variant_unref().
Sourcepub fn call_with_unix_fd_list<P: FnOnce(Result<(Variant, Option<UnixFDList>), Error>) + 'static>(
&self,
bus_name: Option<&str>,
object_path: &str,
interface_name: &str,
method_name: &str,
parameters: Option<&Variant>,
reply_type: Option<&VariantTy>,
flags: DBusCallFlags,
timeout_msec: i32,
fd_list: Option<&impl IsA<UnixFDList>>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
Available on Unix only.
pub fn call_with_unix_fd_list<P: FnOnce(Result<(Variant, Option<UnixFDList>), Error>) + 'static>( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA<UnixFDList>>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Like g_dbus_connection_call() but also takes a #GUnixFDList object.
The file descriptors normally correspond to G_VARIANT_TYPE_HANDLE
values in the body of the message. For example, if a message contains
two file descriptors, @fd_list would have length 2, and
g_variant_new_handle (0)
and g_variant_new_handle (1)
would appear
somewhere in the body of the message (not necessarily in that order!)
to represent the file descriptors at indexes 0 and 1 respectively.
When designing D-Bus APIs that are intended to be interoperable,
please note that non-GDBus implementations of D-Bus can usually only
access file descriptors if they are referenced in this way by a
value of type G_VARIANT_TYPE_HANDLE
in the body of the message.
This method is only available on UNIX.
§bus_name
a unique or well-known bus name or None
if
@self is not a message bus connection
§object_path
path of remote object
§interface_name
D-Bus interface to invoke method on
§method_name
the name of the method to invoke
§parameters
a #GVariant tuple with parameters for the method
or None
if not passing parameters
§reply_type
the expected type of the reply, or None
§flags
flags from the #GDBusCallFlags enumeration
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§fd_list
a #GUnixFDList or None
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request is
satisfied or None
if you don’t * care about the result of the
method invocation
pub fn call_with_unix_fd_list_future( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&(impl IsA<UnixFDList> + Clone + 'static)>, ) -> Pin<Box_<dyn Future<Output = Result<(Variant, Option<UnixFDList>), Error>> + 'static>>
Sourcepub fn call_with_unix_fd_list_sync(
&self,
bus_name: Option<&str>,
object_path: &str,
interface_name: &str,
method_name: &str,
parameters: Option<&Variant>,
reply_type: Option<&VariantTy>,
flags: DBusCallFlags,
timeout_msec: i32,
fd_list: Option<&impl IsA<UnixFDList>>,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(Variant, Option<UnixFDList>), Error>
Available on Unix only.
pub fn call_with_unix_fd_list_sync( &self, bus_name: Option<&str>, object_path: &str, interface_name: &str, method_name: &str, parameters: Option<&Variant>, reply_type: Option<&VariantTy>, flags: DBusCallFlags, timeout_msec: i32, fd_list: Option<&impl IsA<UnixFDList>>, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(Variant, Option<UnixFDList>), Error>
Like g_dbus_connection_call_sync() but also takes and returns #GUnixFDList objects. See g_dbus_connection_call_with_unix_fd_list() and g_dbus_connection_call_with_unix_fd_list_finish() for more details.
This method is only available on UNIX.
§bus_name
a unique or well-known bus name or None
if @self is not a message bus connection
§object_path
path of remote object
§interface_name
D-Bus interface to invoke method on
§method_name
the name of the method to invoke
§parameters
a #GVariant tuple with parameters for
the method or None
if not passing parameters
§reply_type
the expected type of the reply, or None
§flags
flags from the #GDBusCallFlags enumeration
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§fd_list
a #GUnixFDList or None
§cancellable
a #GCancellable or None
§Returns
None
if @error is set. Otherwise a non-floating
#GVariant tuple with return values. Free with g_variant_unref().
§out_fd_list
return location for a #GUnixFDList or None
Sourcepub fn close<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
pub fn close<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Closes @self. Note that this never causes the process to exit (this might only happen if the other end of a shared message bus connection disconnects, see #GDBusConnection:exit-on-close).
Once the connection is closed, operations such as sending a message
will return with the error IOErrorEnum::Closed
. Closing a connection
will not automatically flush the connection so queued messages may
be lost. Use g_dbus_connection_flush() if you need such guarantees.
If @self is already closed, this method fails with
IOErrorEnum::Closed
.
When @self has been closed, the #GDBusConnection::closed signal is emitted in the [thread-default main context][g-main-context-push-thread-default] of the thread that @self was constructed in.
This is an asynchronous method. When the operation is finished, @callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call g_dbus_connection_close_finish() to get the result of the operation. See g_dbus_connection_close_sync() for the synchronous version.
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request is
satisfied or None
if you don’t care about the result
pub fn close_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
Sourcepub fn close_sync(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
pub fn close_sync( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sourcepub fn emit_signal(
&self,
destination_bus_name: Option<&str>,
object_path: &str,
interface_name: &str,
signal_name: &str,
parameters: Option<&Variant>,
) -> Result<(), Error>
pub fn emit_signal( &self, destination_bus_name: Option<&str>, object_path: &str, interface_name: &str, signal_name: &str, parameters: Option<&Variant>, ) -> Result<(), Error>
Emits a signal.
If the parameters GVariant is floating, it is consumed.
This can only fail if @parameters is not compatible with the D-Bus protocol
(IOErrorEnum::InvalidArgument
), or if @self has been closed
(IOErrorEnum::Closed
).
§destination_bus_name
the unique bus name for the destination
for the signal or None
to emit to all listeners
§object_path
path of remote object
§interface_name
D-Bus interface to emit a signal on
§signal_name
the name of the signal to emit
§parameters
a #GVariant tuple with parameters for the signal
or None
if not passing parameters
§Returns
true
unless @error is set
Sourcepub fn flush<P: FnOnce(Result<(), Error>) + 'static>(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
pub fn flush<P: FnOnce(Result<(), Error>) + 'static>( &self, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously flushes @self, that is, writes all queued outgoing message to the transport and then flushes the transport (using g_output_stream_flush_async()). This is useful in programs that wants to emit a D-Bus signal and then exit immediately. Without flushing the connection, there is no guaranteed that the message has been sent to the networking buffers in the OS kernel.
This is an asynchronous method. When the operation is finished, @callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call g_dbus_connection_flush_finish() to get the result of the operation. See g_dbus_connection_flush_sync() for the synchronous version.
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the
request is satisfied or None
if you don’t care about the result
pub fn flush_future( &self, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
Sourcepub fn flush_sync(
&self,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(), Error>
pub fn flush_sync( &self, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(), Error>
Sourcepub fn capabilities(&self) -> DBusCapabilityFlags
pub fn capabilities(&self) -> DBusCapabilityFlags
Gets the capabilities negotiated with the remote peer
§Returns
zero or more flags from the #GDBusCapabilityFlags enumeration
Sourcepub fn exits_on_close(&self) -> bool
pub fn exits_on_close(&self) -> bool
Gets whether the process is terminated when @self is closed by the remote peer. See #GDBusConnection:exit-on-close for more details.
§Returns
whether the process is terminated when @self is closed by the remote peer
Sourcepub fn flags(&self) -> DBusConnectionFlags
Available on crate feature v2_60
only.
pub fn flags(&self) -> DBusConnectionFlags
v2_60
only.Gets the flags used to construct this connection
§Returns
zero or more flags from the #GDBusConnectionFlags enumeration
Sourcepub fn guid(&self) -> GString
pub fn guid(&self) -> GString
The GUID of the peer performing the role of server when authenticating. See #GDBusConnection:guid for more details.
§Returns
The GUID. Do not free this string, it is owned by @self.
Sourcepub fn last_serial(&self) -> u32
pub fn last_serial(&self) -> u32
Retrieves the last serial number assigned to a #GDBusMessage on the current thread. This includes messages sent via both low-level API such as g_dbus_connection_send_message() as well as high-level API such as g_dbus_connection_emit_signal(), g_dbus_connection_call() or g_dbus_proxy_call().
§Returns
the last used serial or zero when no message has been sent within the current thread
Sourcepub fn peer_credentials(&self) -> Option<Credentials>
pub fn peer_credentials(&self) -> Option<Credentials>
Gets the credentials of the authenticated peer. This will always
return None
unless @self acted as a server
(e.g. DBusConnectionFlags::AUTHENTICATION_SERVER
was passed)
when set up and the client passed credentials as part of the
authentication process.
In a message bus setup, the message bus is always the server and
each application is a client. So this method will always return
None
for message bus clients.
§Returns
a #GCredentials or None
if not
available. Do not free this object, it is owned by @self.
Sourcepub fn stream(&self) -> IOStream
pub fn stream(&self) -> IOStream
Gets the underlying stream used for IO.
While the #GDBusConnection is active, it will interact with this stream from a worker thread, so it is not safe to interact with the stream directly.
§Returns
the stream used for IO
Sourcepub fn unique_name(&self) -> Option<GString>
pub fn unique_name(&self) -> Option<GString>
Sourcepub fn send_message(
&self,
message: &DBusMessage,
flags: DBusSendMessageFlags,
) -> Result<u32, Error>
pub fn send_message( &self, message: &DBusMessage, flags: DBusSendMessageFlags, ) -> Result<u32, Error>
Asynchronously sends @message to the peer represented by @self.
Unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag, the serial number
will be assigned by @self and set on @message via
g_dbus_message_set_serial(). If @out_serial is not None
, then the
serial number used will be written to this location prior to
submitting the message to the underlying transport. While it has a volatile
qualifier, this is a historical artifact and the argument passed to it should
not be volatile
.
If @self is closed then the operation will fail with
IOErrorEnum::Closed
. If @message is not well-formed,
the operation fails with IOErrorEnum::InvalidArgument
.
See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Note that @message must be unlocked, unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag.
§message
a #GDBusMessage
§flags
flags affecting how the message is sent
§Returns
true
if the message was well-formed and queued for
transmission, false
if @error is set
§out_serial
return location for serial number assigned
to @message when sending it or None
Sourcepub fn send_message_with_reply<P: FnOnce(Result<DBusMessage, Error>) + 'static>(
&self,
message: &DBusMessage,
flags: DBusSendMessageFlags,
timeout_msec: i32,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
) -> u32
pub fn send_message_with_reply<P: FnOnce(Result<DBusMessage, Error>) + 'static>( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, cancellable: Option<&impl IsA<Cancellable>>, callback: P, ) -> u32
Asynchronously sends @message to the peer represented by @self.
Unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag, the serial number
will be assigned by @self and set on @message via
g_dbus_message_set_serial(). If @out_serial is not None
, then the
serial number used will be written to this location prior to
submitting the message to the underlying transport. While it has a volatile
qualifier, this is a historical artifact and the argument passed to it should
not be volatile
.
If @self is closed then the operation will fail with
IOErrorEnum::Closed
. If @cancellable is canceled, the operation will
fail with IOErrorEnum::Cancelled
. If @message is not well-formed,
the operation fails with IOErrorEnum::InvalidArgument
.
This is an asynchronous method. When the operation is finished, @callback will be invoked in the [thread-default main context][g-main-context-push-thread-default] of the thread you are calling this method from. You can then call g_dbus_connection_send_message_with_reply_finish() to get the result of the operation. See g_dbus_connection_send_message_with_reply_sync() for the synchronous version.
Note that @message must be unlocked, unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag.
See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.
§message
a #GDBusMessage
§flags
flags affecting how the message is sent
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request
is satisfied or None
if you don’t care about the result
§Returns
§out_serial
return location for serial number assigned
to @message when sending it or None
pub fn send_message_with_reply_future( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, ) -> Pin<Box_<dyn Future<Output = Result<DBusMessage, Error>> + 'static>>
Sourcepub fn send_message_with_reply_sync(
&self,
message: &DBusMessage,
flags: DBusSendMessageFlags,
timeout_msec: i32,
cancellable: Option<&impl IsA<Cancellable>>,
) -> Result<(DBusMessage, u32), Error>
pub fn send_message_with_reply_sync( &self, message: &DBusMessage, flags: DBusSendMessageFlags, timeout_msec: i32, cancellable: Option<&impl IsA<Cancellable>>, ) -> Result<(DBusMessage, u32), Error>
Synchronously sends @message to the peer represented by @self and blocks the calling thread until a reply is received or the timeout is reached. See g_dbus_connection_send_message_with_reply() for the asynchronous version of this method.
Unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag, the serial number
will be assigned by @self and set on @message via
g_dbus_message_set_serial(). If @out_serial is not None
, then the
serial number used will be written to this location prior to
submitting the message to the underlying transport. While it has a volatile
qualifier, this is a historical artifact and the argument passed to it should
not be volatile
.
If @self is closed then the operation will fail with
IOErrorEnum::Closed
. If @cancellable is canceled, the operation will
fail with IOErrorEnum::Cancelled
. If @message is not well-formed,
the operation fails with IOErrorEnum::InvalidArgument
.
Note that @error is only set if a local in-process error
occurred. That is to say that the returned #GDBusMessage object may
be of type DBusMessageType::Error
. Use
g_dbus_message_to_gerror() to transcode this to a #GError.
See this [server][gdbus-server] and [client][gdbus-unix-fd-client] for an example of how to use this low-level API to send and receive UNIX file descriptors.
Note that @message must be unlocked, unless @flags contain the
DBusSendMessageFlags::PRESERVE_SERIAL
flag.
§message
a #GDBusMessage
§flags
flags affecting how the message is sent.
§timeout_msec
the timeout in milliseconds, -1 to use the default
timeout or G_MAXINT
for no timeout
§cancellable
a #GCancellable or None
§Returns
a locked #GDBusMessage that is the reply
to @message or None
if @error is set
§out_serial
return location for serial number
assigned to @message when sending it or None
Sourcepub fn set_exit_on_close(&self, exit_on_close: bool)
pub fn set_exit_on_close(&self, exit_on_close: bool)
Sets whether the process should be terminated when @self is closed by the remote peer. See #GDBusConnection:exit-on-close for more details.
Note that this function should be used with care. Most modern UNIX
desktops tie the notion of a user session with the session bus, and expect
all of a user’s applications to quit when their bus connection goes away.
If you are setting @exit_on_close to false
for the shared session
bus connection, you should make sure that your application exits
when the user session ends.
§exit_on_close
whether the process should be terminated when @self is closed by the remote peer
Sourcepub fn start_message_processing(&self)
pub fn start_message_processing(&self)
If @self was created with
DBusConnectionFlags::DELAY_MESSAGE_PROCESSING
, this method
starts processing messages. Does nothing on if @self wasn’t
created with this flag or if the method has already been called.
Sourcepub fn new<P: FnOnce(Result<DBusConnection, Error>) + 'static>(
stream: &impl IsA<IOStream>,
guid: Option<&str>,
flags: DBusConnectionFlags,
observer: Option<&DBusAuthObserver>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
pub fn new<P: FnOnce(Result<DBusConnection, Error>) + 'static>( stream: &impl IsA<IOStream>, guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously sets up a D-Bus connection for exchanging D-Bus messages with the end represented by @stream.
If @stream is a #GSocketConnection, then the corresponding #GSocket will be put into non-blocking mode.
The D-Bus connection will interact with @stream from a worker thread. As a result, the caller should not interact with @stream after this method has been called, except by calling g_object_unref() on it.
If @observer is not None
it may be used to control the
authentication process.
When the operation is finished, @callback will be invoked. You can then call g_dbus_connection_new_finish() to get the result of the operation.
This is an asynchronous failable constructor. See g_dbus_connection_new_sync() for the synchronous version.
§stream
a #GIOStream
§guid
the GUID to use if authenticating as a server or None
§flags
flags describing how to make the connection
§observer
a #GDBusAuthObserver or None
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request is satisfied
pub fn new_future( stream: &(impl IsA<IOStream> + Clone + 'static), guid: Option<&str>, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, ) -> Pin<Box_<dyn Future<Output = Result<DBusConnection, Error>> + 'static>>
Sourcepub fn for_address<P: FnOnce(Result<DBusConnection, Error>) + 'static>(
address: &str,
flags: DBusConnectionFlags,
observer: Option<&DBusAuthObserver>,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
pub fn for_address<P: FnOnce(Result<DBusConnection, Error>) + 'static>( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
Asynchronously connects and sets up a D-Bus client connection for exchanging D-Bus messages with an endpoint specified by @address which must be in the D-Bus address format.
This constructor can only be used to initiate client-side
connections - use g_dbus_connection_new() if you need to act as the
server. In particular, @flags cannot contain the
DBusConnectionFlags::AUTHENTICATION_SERVER
,
DBusConnectionFlags::AUTHENTICATION_ALLOW_ANONYMOUS
or
DBusConnectionFlags::AUTHENTICATION_REQUIRE_SAME_USER
flags.
When the operation is finished, @callback will be invoked. You can then call g_dbus_connection_new_for_address_finish() to get the result of the operation.
If @observer is not None
it may be used to control the
authentication process.
This is an asynchronous failable constructor. See g_dbus_connection_new_for_address_sync() for the synchronous version.
§address
a D-Bus address
§flags
flags describing how to make the connection
§observer
a #GDBusAuthObserver or None
§cancellable
a #GCancellable or None
§callback
a #GAsyncReadyCallback to call when the request is satisfied
pub fn for_address_future( address: &str, flags: DBusConnectionFlags, observer: Option<&DBusAuthObserver>, ) -> Pin<Box_<dyn Future<Output = Result<DBusConnection, Error>> + 'static>>
Sourcepub fn connect_closed<F: Fn(&Self, bool, Option<&Error>) + Send + Sync + 'static>(
&self,
f: F,
) -> SignalHandlerId
pub fn connect_closed<F: Fn(&Self, bool, Option<&Error>) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId
Emitted when the connection is closed.
The cause of this event can be
-
If g_dbus_connection_close() is called. In this case @remote_peer_vanished is set to
false
and @error isNone
. -
If the remote peer closes the connection. In this case @remote_peer_vanished is set to
true
and @error is set. -
If the remote peer sends invalid or malformed data. In this case @remote_peer_vanished is set to
false
and @error is set.
Upon receiving this signal, you should give up your reference to @connection. You are guaranteed that this signal is emitted only once.
§remote_peer_vanished
true
if @connection is closed because the
remote peer closed its end of the connection
§error
a #GError with more details about the event or None
pub fn connect_capabilities_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId
pub fn connect_closed_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId
pub fn connect_exit_on_close_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId
pub fn connect_unique_name_notify<F: Fn(&Self) + Send + Sync + 'static>( &self, f: F, ) -> SignalHandlerId
Trait Implementations§
Source§impl Clone for DBusConnection
impl Clone for DBusConnection
Source§impl Debug for DBusConnection
impl Debug for DBusConnection
Source§impl HasParamSpec for DBusConnection
impl HasParamSpec for DBusConnection
type ParamSpec = ParamSpecObject
Source§type SetValue = DBusConnection
type SetValue = DBusConnection
type BuilderFn = fn(_: &str) -> ParamSpecObjectBuilder<'_, DBusConnection>
fn param_spec_builder() -> Self::BuilderFn
Source§impl Hash for DBusConnection
impl Hash for DBusConnection
Source§impl Ord for DBusConnection
impl Ord for DBusConnection
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Comparison for two GObjects.
Compares the memory addresses of the provided objects.
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl ParentClassIs for DBusConnection
impl ParentClassIs for DBusConnection
Source§impl<OT: ObjectType> PartialEq<OT> for DBusConnection
impl<OT: ObjectType> PartialEq<OT> for DBusConnection
Source§impl<OT: ObjectType> PartialOrd<OT> for DBusConnection
impl<OT: ObjectType> PartialOrd<OT> for DBusConnection
Source§impl StaticType for DBusConnection
impl StaticType for DBusConnection
Source§fn static_type() -> Type
fn static_type() -> Type
Self
.impl Eq for DBusConnection
impl IsA<AsyncInitable> for DBusConnection
impl IsA<Initable> for DBusConnection
impl Send for DBusConnection
impl Sync for DBusConnection
Auto Trait Implementations§
impl Freeze for DBusConnection
impl RefUnwindSafe for DBusConnection
impl Unpin for DBusConnection
impl UnwindSafe for DBusConnection
Blanket Implementations§
Source§impl<O> AsyncInitableExt for Owhere
O: IsA<AsyncInitable>,
impl<O> AsyncInitableExt for Owhere
O: IsA<AsyncInitable>,
Source§unsafe fn init_async<P: FnOnce(Result<(), Error>) + 'static>(
&self,
io_priority: Priority,
cancellable: Option<&impl IsA<Cancellable>>,
callback: P,
)
unsafe fn init_async<P: FnOnce(Result<(), Error>) + 'static>( &self, io_priority: Priority, cancellable: Option<&impl IsA<Cancellable>>, callback: P, )
unsafe fn init_future( &self, io_priority: Priority, ) -> Pin<Box_<dyn Future<Output = Result<(), Error>> + 'static>>
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Cast for Twhere
T: ObjectType,
impl<T> Cast for Twhere
T: ObjectType,
Source§fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast<T>(self) -> Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moreSource§fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
fn upcast_ref<T>(&self) -> &Twhere
T: ObjectType,
Self: IsA<T>,
T
. Read moreSource§fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: MayDowncastTo<T>,
fn downcast<T>(self) -> Result<T, Self>where
T: ObjectType,
Self: MayDowncastTo<T>,
T
. Read moreSource§fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: MayDowncastTo<T>,
fn downcast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
Self: MayDowncastTo<T>,
T
. Read moreSource§fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
fn dynamic_cast<T>(self) -> Result<T, Self>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while upcast
will do many checks at compile-time already. downcast
will
perform the same checks at runtime as dynamic_cast
, but will also ensure some amount of
compile-time safety. Read moreSource§fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
fn dynamic_cast_ref<T>(&self) -> Option<&T>where
T: ObjectType,
T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read moreSource§unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
unsafe fn unsafe_cast<T>(self) -> Twhere
T: ObjectType,
T
unconditionally. Read moreSource§unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
unsafe fn unsafe_cast_ref<T>(&self) -> &Twhere
T: ObjectType,
&T
unconditionally. Read moreSource§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *const GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GPtrArray> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
impl<T> FromGlibPtrArrayContainerAsVec<<T as GlibPtrDefault>::GlibType, *mut GSList> for Twhere
T: GlibPtrDefault + FromGlibPtrNone<<T as GlibPtrDefault>::GlibType> + FromGlibPtrFull<<T as GlibPtrDefault>::GlibType>,
Source§impl<O> InitableExt for O
impl<O> InitableExt for O
Source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
Source§impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
impl<U> IsSubclassableExt for Uwhere
U: IsClass + ParentClassIs,
fn parent_class_init<T>(class: &mut Class<U>)
fn parent_instance_init<T>(instance: &mut InitializingObject<T>)
Source§impl<T> ObjectExt for Twhere
T: ObjectType,
impl<T> ObjectExt for Twhere
T: ObjectType,
Source§fn is<U>(&self) -> boolwhere
U: StaticType,
fn is<U>(&self) -> boolwhere
U: StaticType,
true
if the object is an instance of (can be cast to) T
.Source§fn object_class(&self) -> &Class<Object>
fn object_class(&self) -> &Class<Object>
ObjectClass
of the object. Read moreSource§fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
fn class_of<U>(&self) -> Option<&Class<U>>where
U: IsClass,
T
. Read moreSource§fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
fn interface<U>(&self) -> Option<InterfaceRef<'_, U>>where
U: IsInterface,
T
of the object. Read moreSource§fn set_property_from_value(&self, property_name: &str, value: &Value)
fn set_property_from_value(&self, property_name: &str, value: &Value)
Source§fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
fn set_properties(&self, property_values: &[(&str, &dyn ToValue)])
Source§fn set_properties_from_value(&self, property_values: &[(&str, Value)])
fn set_properties_from_value(&self, property_values: &[(&str, Value)])
Source§fn property<V>(&self, property_name: &str) -> Vwhere
V: for<'b> FromValue<'b> + 'static,
fn property<V>(&self, property_name: &str) -> Vwhere
V: for<'b> FromValue<'b> + 'static,
property_name
of the object and cast it to the type V. Read moreSource§fn property_value(&self, property_name: &str) -> Value
fn property_value(&self, property_name: &str) -> Value
property_name
of the object. Read moreSource§fn property_type(&self, property_name: &str) -> Option<Type>
fn property_type(&self, property_name: &str) -> Option<Type>
property_name
of this object. Read moreSource§fn find_property(&self, property_name: &str) -> Option<ParamSpec>
fn find_property(&self, property_name: &str) -> Option<ParamSpec>
ParamSpec
of the property property_name
of this object.Source§fn list_properties(&self) -> PtrSlice<ParamSpec>
fn list_properties(&self) -> PtrSlice<ParamSpec>
ParamSpec
of the properties of this object.Source§fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
fn freeze_notify(&self) -> PropertyNotificationFreezeGuard
Source§unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
unsafe fn set_qdata<QD>(&self, key: Quark, value: QD)where
QD: 'static,
key
. Read moreSource§unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn qdata<QD>(&self, key: Quark) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moreSource§unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
unsafe fn steal_qdata<QD>(&self, key: Quark) -> Option<QD>where
QD: 'static,
key
. Read moreSource§unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
unsafe fn set_data<QD>(&self, key: &str, value: QD)where
QD: 'static,
key
. Read moreSource§unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
unsafe fn data<QD>(&self, key: &str) -> Option<NonNull<QD>>where
QD: 'static,
key
. Read moreSource§unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
unsafe fn steal_data<QD>(&self, key: &str) -> Option<QD>where
QD: 'static,
key
. Read moreSource§fn block_signal(&self, handler_id: &SignalHandlerId)
fn block_signal(&self, handler_id: &SignalHandlerId)
Source§fn unblock_signal(&self, handler_id: &SignalHandlerId)
fn unblock_signal(&self, handler_id: &SignalHandlerId)
Source§fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
fn stop_signal_emission(&self, signal_id: SignalId, detail: Option<Quark>)
Source§fn stop_signal_emission_by_name(&self, signal_name: &str)
fn stop_signal_emission_by_name(&self, signal_name: &str)
Source§fn connect<F>(
&self,
signal_name: &str,
after: bool,
callback: F,
) -> SignalHandlerId
fn connect<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
signal_name
on this object. Read moreSource§fn connect_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> SignalHandlerId
fn connect_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
signal_id
on this object. Read moreSource§fn connect_local<F>(
&self,
signal_name: &str,
after: bool,
callback: F,
) -> SignalHandlerId
fn connect_local<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
signal_name
on this object. Read moreSource§fn connect_local_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> SignalHandlerId
fn connect_local_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
signal_id
on this object. Read moreSource§unsafe fn connect_unsafe<F>(
&self,
signal_name: &str,
after: bool,
callback: F,
) -> SignalHandlerId
unsafe fn connect_unsafe<F>( &self, signal_name: &str, after: bool, callback: F, ) -> SignalHandlerId
signal_name
on this object. Read moreSource§unsafe fn connect_unsafe_id<F>(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
callback: F,
) -> SignalHandlerId
unsafe fn connect_unsafe_id<F>( &self, signal_id: SignalId, details: Option<Quark>, after: bool, callback: F, ) -> SignalHandlerId
signal_id
on this object. Read moreSource§fn connect_closure(
&self,
signal_name: &str,
after: bool,
closure: RustClosure,
) -> SignalHandlerId
fn connect_closure( &self, signal_name: &str, after: bool, closure: RustClosure, ) -> SignalHandlerId
signal_name
on this object. Read moreSource§fn connect_closure_id(
&self,
signal_id: SignalId,
details: Option<Quark>,
after: bool,
closure: RustClosure,
) -> SignalHandlerId
fn connect_closure_id( &self, signal_id: SignalId, details: Option<Quark>, after: bool, closure: RustClosure, ) -> SignalHandlerId
signal_id
on this object. Read moreSource§fn watch_closure(&self, closure: &impl AsRef<Closure>)
fn watch_closure(&self, closure: &impl AsRef<Closure>)
closure
to the lifetime of the object. When
the object’s reference count drops to zero, the closure will be
invalidated. An invalidated closure will ignore any calls to
invoke_with_values
, or
invoke
when using Rust closures.Source§fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit<R>(&self, signal_id: SignalId, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
Source§fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
fn emit_with_values(&self, signal_id: SignalId, args: &[Value]) -> Option<Value>
Self::emit
but takes Value
for the arguments.Source§fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name<R>(&self, signal_name: &str, args: &[&dyn ToValue]) -> Rwhere
R: TryFromClosureReturnValue,
Source§fn emit_by_name_with_values(
&self,
signal_name: &str,
args: &[Value],
) -> Option<Value>
fn emit_by_name_with_values( &self, signal_name: &str, args: &[Value], ) -> Option<Value>
Source§fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue],
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_by_name_with_details<R>(
&self,
signal_name: &str,
details: Quark,
args: &[&dyn ToValue],
) -> Rwhere
R: TryFromClosureReturnValue,
Source§fn emit_by_name_with_details_and_values(
&self,
signal_name: &str,
details: Quark,
args: &[Value],
) -> Option<Value>
fn emit_by_name_with_details_and_values( &self, signal_name: &str, details: Quark, args: &[Value], ) -> Option<Value>
Source§fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue],
) -> Rwhere
R: TryFromClosureReturnValue,
fn emit_with_details<R>(
&self,
signal_id: SignalId,
details: Quark,
args: &[&dyn ToValue],
) -> Rwhere
R: TryFromClosureReturnValue,
Source§fn emit_with_details_and_values(
&self,
signal_id: SignalId,
details: Quark,
args: &[Value],
) -> Option<Value>
fn emit_with_details_and_values( &self, signal_id: SignalId, details: Quark, args: &[Value], ) -> Option<Value>
Source§fn disconnect(&self, handler_id: SignalHandlerId)
fn disconnect(&self, handler_id: SignalHandlerId)
Source§fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
notify
signal of the object. Read moreSource§fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
fn connect_notify_local<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId
notify
signal of the object. Read moreSource§unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F,
) -> SignalHandlerId
unsafe fn connect_notify_unsafe<F>( &self, name: Option<&str>, f: F, ) -> SignalHandlerId
notify
signal of the object. Read moreSource§fn notify(&self, property_name: &str)
fn notify(&self, property_name: &str)
Source§fn notify_by_pspec(&self, pspec: &ParamSpec)
fn notify_by_pspec(&self, pspec: &ParamSpec)
Source§fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>
fn add_weak_ref_notify<F>(&self, f: F) -> WeakRefNotify<T>
Source§fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>where
F: FnOnce() + 'static,
fn add_weak_ref_notify_local<F>(&self, f: F) -> WeakRefNotify<T>where
F: FnOnce() + 'static,
Source§fn bind_property<'a, 'f, 't, O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str,
) -> BindingBuilder<'a, 'f, 't>where
O: ObjectType,
fn bind_property<'a, 'f, 't, O>(
&'a self,
source_property: &'a str,
target: &'a O,
target_property: &'a str,
) -> BindingBuilder<'a, 'f, 't>where
O: ObjectType,
Source§unsafe fn run_dispose(&self)
unsafe fn run_dispose(&self)
Source§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
Source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
Source§fn ensure_type()
fn ensure_type()
Source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
Source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
SendValue
clone of self
.