Struct gio::DBusMessage [−][src]
pub struct DBusMessage(_);
Expand description
A type for representing D-Bus messages that can be sent or received
on a DBusConnection
.
Implements
Implementations
pub fn from_blob(
blob: &[u8],
capabilities: DBusCapabilityFlags
) -> Result<DBusMessage, Error>
pub fn from_blob(
blob: &[u8],
capabilities: DBusCapabilityFlags
) -> Result<DBusMessage, Error>
Creates a new DBusMessage
from the data stored at blob
. The byte
order that the message was in can be retrieved using
byte_order()
.
If the blob
cannot be parsed, contains invalid fields, or contains invalid
headers, IOErrorEnum::InvalidArgument
will be returned.
blob
A blob representing a binary D-Bus message.
capabilities
A DBusCapabilityFlags
describing what protocol features are supported.
Returns
A new DBusMessage
or None
if error
is set. Free with
g_object_unref()
.
pub fn new_method_call(
name: Option<&str>,
path: &str,
interface_: Option<&str>,
method: &str
) -> DBusMessage
pub fn new_method_call(
name: Option<&str>,
path: &str,
interface_: Option<&str>,
method: &str
) -> DBusMessage
Creates a new DBusMessage
for a method call.
name
A valid D-Bus name or None
.
path
A valid object path.
interface_
A valid D-Bus interface name or None
.
method
A valid method name.
Returns
A DBusMessage
. Free with g_object_unref()
.
Creates a new DBusMessage
for a signal emission.
path
A valid object path.
interface_
A valid D-Bus interface name.
signal
A valid signal name.
Returns
A DBusMessage
. Free with g_object_unref()
.
Copies self
. The copy is a deep copy and the returned
DBusMessage
is completely identical except that it is guaranteed
to not be locked.
This operation can fail if e.g. self
contains file descriptors
and the per-process or system-wide open files limit is reached.
Returns
A new DBusMessage
or None
if error
is set.
Free with g_object_unref()
.
Gets the body of a message.
Returns
A glib::Variant
or None
if the body is
empty. Do not free, it is owned by self
.
Gets the flags for self
.
Returns
Flags that are set (typically values from the DBusMessageFlags
enumeration bitwise ORed together).
Gets a header field on self
.
The caller is responsible for checking the type of the returned glib::Variant
matches what is expected.
header_field
A 8-bit unsigned integer (typically a value from the DBusMessageHeaderField
enumeration)
Returns
A glib::Variant
with the value if the header was found, None
otherwise. Do not free, it is owned by self
.
Gets the type of self
.
Returns
A 8-bit unsigned integer (typically a value from the DBusMessageType
enumeration).
This is supported on Unix only.
This is supported on Unix only.
Gets the UNIX file descriptors associated with self
, if any.
This method is only available on UNIX.
The file descriptors normally correspond to G_VARIANT_TYPE_HANDLE
values in the body of the message. For example,
if [glib::Variant::handle()
][crate::glib::Variant::handle()] returns 5, that is intended to be a reference
to the file descriptor that can be accessed by
g_unix_fd_list_get (list, 5, ...)
.
Returns
A UnixFDList
or None
if no file descriptors are
associated. Do not free, this object is owned by self
.
Creates a new DBusMessage
that is an error reply to self
.
error_name
A valid D-Bus error name.
error_message
The D-Bus error message.
Returns
A DBusMessage
. Free with g_object_unref()
.
Produces a human-readable multi-line description of self
.
The contents of the description has no ABI guarantees, the contents and formatting is subject to change at any time. Typical output looks something like this:
Flags: none
Version: 0
Serial: 4
Headers:
path -> objectpath '/org/gtk/GDBus/TestObject'
interface -> 'org.gtk.GDBus.TestInterface'
member -> 'GimmeStdout'
destination -> ':1.146'
Body: ()
UNIX File Descriptors:
(none)
or
Flags: no-reply-expected
Version: 0
Serial: 477
Headers:
reply-serial -> uint32 4
destination -> ':1.159'
sender -> ':1.146'
num-unix-fds -> uint32 1
Body: ()
UNIX File Descriptors:
fd 12: dev=0:10,mode=020620,ino=5,uid=500,gid=5,rdev=136:2,size=0,atime=1273085037,mtime=1273085851,ctime=1272982635
indent
Indentation level.
Returns
A string that should be freed with g_free()
.
Sets the body self
. As a side-effect the
DBusMessageHeaderField::Signature
header field is set to the
type string of body
(or cleared if body
is None
).
If body
is floating, self
assumes ownership of body
.
body
Either None
or a glib::Variant
that is a tuple.
Convenience setter for the DBusMessageHeaderField::Destination
header field.
value
The value to set.
Sets the flags to set on self
.
flags
Flags for self
that are set (typically values from the DBusMessageFlags
enumeration bitwise ORed together).
Sets a header field on self
.
If value
is floating, self
assumes ownership of value
.
header_field
A 8-bit unsigned integer (typically a value from the DBusMessageHeaderField
enumeration)
value
A glib::Variant
to set the header field or None
to clear the header field.
Sets self
to be of type_
.
type_
A 8-bit unsigned integer (typically a value from the DBusMessageType
enumeration).
This is supported on Unix only.
Convenience setter for the DBusMessageHeaderField::ReplySerial
header field.
value
The value to set.
This is supported on Unix only.
Sets the UNIX file descriptors associated with self
. As a
side-effect the DBusMessageHeaderField::NumUnixFds
header
field is set to the number of fds in fd_list
(or cleared if
fd_list
is None
).
This method is only available on UNIX.
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 by a value of type
G_VARIANT_TYPE_HANDLE
in the body of the message.
fd_list
A UnixFDList
or None
.
Serializes self
to a blob. The byte order returned by
byte_order()
will be used.
capabilities
A DBusCapabilityFlags
describing what protocol features are supported.
Returns
A pointer to a
valid binary D-Bus message of out_size
bytes generated by self
or None
if error
is set. Free with g_free()
.
If self
is not of type DBusMessageType::Error
does
nothing and returns false
.
Otherwise this method encodes the error in self
as a glib::Error
using g_dbus_error_set_dbus_error()
using the information in the
DBusMessageHeaderField::ErrorName
header field of self
as
well as the first string item in self
’s body.
Returns
Utility function to calculate how many bytes are needed to
completely deserialize the D-Bus message stored at blob
.
blob
A blob representing a binary D-Bus message.
Returns
Number of bytes needed or -1 if error
is set (e.g. if
blob
contains invalid data or not enough data is available to
determine the size).
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for DBusMessage
impl !Send for DBusMessage
impl !Sync for DBusMessage
impl Unpin for DBusMessage
impl UnwindSafe for DBusMessage
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type 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 more
Tries to cast to reference to an object of type 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 more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
V: ToValue,
N: Into<&'a str>,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + Send + Sync + 'static,
N: Into<&'a str>,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value> + 'static,
N: Into<&'a str>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
F: Fn(&[Value]) -> Option<Value>,
N: Into<&'a str>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Emit signal with details by signal id.
Emit signal by it’s name.
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Same as emit
but takes Value
for the arguments.
Same as emit_by_name
but takes Value
for the arguments.
Returns a SendValue
clone of self
.
impl<'a, T, C> FromValueOptional<'a> for T where
C: ValueTypeChecker<Error = ValueTypeMismatchOrNoneError>,
T: FromValue<'a, Checker = C>,