tokio_dbus_core/proto.rs
1raw_enum! {
2 /// The endianness of a message.
3 #[repr(u8)]
4 pub enum Endianness {
5 /// Little endian.
6 LITTLE = b'l',
7 /// Big endian.
8 BIG = b'B',
9 }
10}
11
12impl Endianness {
13 /// Native endian.
14 #[cfg(target_endian = "little")]
15 pub const NATIVE: Self = Self::LITTLE;
16 /// Native endian.
17 #[cfg(target_endian = "big")]
18 pub const NATIVE: Self = Self::BIG;
19}
20
21raw_enum! {
22 /// The type inside of a signature.
23 #[repr(u8)]
24 pub enum Type {
25 /// Not a valid type code, used to terminate signatures
26 INVALID = b'\0',
27 /// 8-bit unsigned integer
28 BYTE = b'y',
29 /// Boolean value, 0 is FALSE and 1 is TRUE. Everything else is invalid.
30 BOOLEAN = b'b',
31 /// 16-bit signed integer
32 INT16 = b'n',
33 /// 16-bit unsigned integer
34 UINT16 = b'q',
35 /// 32-bit signed integer
36 INT32 = b'i',
37 /// 32-bit unsigned integer
38 UINT32 = b'u',
39 /// 64-bit signed integer
40 INT64 = b'x',
41 /// 64-bit unsigned integer
42 UINT64 = b't',
43 /// IEEE 754 double
44 DOUBLE = b'd',
45 /// UTF-8 string (must be valid UTF-8). Must be nul terminated and contain
46 /// no other nul bytes.
47 STRING = b's',
48 /// Name of an object instance
49 OBJECT_PATH = b'o',
50 /// A type signature
51 SIGNATURE = b'g',
52 /// Array.
53 ARRAY = b'a',
54 /// Struct; type code 114 'r' is reserved for use in bindings and
55 /// implementations to represent the general concept of a struct, and must
56 /// not appear in signatures used on D-Bus..
57 STRUCT = b'r',
58 OPEN_PAREN = b'(',
59 CLOSE_PAREN = b')',
60 /// Variant type (the type of the value is part of the value itself).
61 VARIANT = b'v',
62 /// Entry in a dict or map (array of key-value pairs). Type code 101 'e' is
63 /// reserved for use in bindings and implementations to represent the
64 /// general concept of a dict or dict-entry, and must not appear in
65 /// signatures used on D-Bus..
66 DICT_ENTRY = b'e',
67 OPEN_BRACE = b'{',
68 CLOSE_BRACE = b'}',
69 /// Unix file descriptor.
70 UNIX_FD = b'h',
71 /// Reserved for a 'maybe' type compatible with the one in GVariant, and
72 /// must not appear in signatures used on D-Bus until specified here.
73 RESERVED0 = b'm',
74 /// Reserved for use in bindings/implementations to represent any single
75 /// complete type, and must not appear in signatures used on D-Bus.
76 RESERVED1 = b'*',
77 /// Reserved for use in bindings/implementations to represent any basic
78 /// type, and must not appear in signatures used on D-Bus.
79 RESERVED2 = b'?',
80 /// Reserved for internal use by bindings/implementations, and must not
81 /// appear in signatures used on D-Bus. GVariant uses these type-codes to
82 /// encode calling conventions.
83 RESERVED3 = b'@',
84 RESERVED4 = b'&',
85 RESERVED5 = b'^',
86 }
87}
88
89raw_enum! {
90 /// The type of a message.
91 #[repr(u8)]
92 pub enum MessageType {
93 /// Method call. This message type may prompt a reply.
94 METHOD_CALL = 1,
95 /// Method reply with returned data.
96 METHOD_RETURN = 2,
97 /// Error reply. If the first argument exists and is a string, it is an
98 /// error message.
99 ERROR = 3,
100 /// Signal emission.
101 SIGNAL = 4,
102 }
103}
104
105raw_set! {
106 /// Flags inside of a D-Bus message.
107 ///
108 /// # Examples
109 ///
110 /// ```
111 /// use tokio_dbus::Flags;
112 ///
113 /// let flags = Flags::EMPTY;
114 /// assert!(!(flags & Flags::NO_REPLY_EXPECTED));
115 ///
116 /// let flags = Flags::EMPTY | Flags::NO_REPLY_EXPECTED;
117 /// assert!(flags & Flags::NO_REPLY_EXPECTED);
118 /// assert!(!(flags & Flags::NO_AUTO_START));
119 /// ```
120 #[repr(u8)]
121 pub enum Flags {
122 /// An empty set of flags.
123 EMPTY = 0,
124 /// This message does not expect method return replies or error replies,
125 /// even if it is of a type that can have a reply; the reply should be
126 /// omitted.
127 NO_REPLY_EXPECTED = 1,
128 /// The bus must not launch an owner for the destination name in response to
129 /// this message.
130 NO_AUTO_START = 2,
131 /// This flag may be set on a method call message to inform the receiving
132 /// side that the caller is prepared to wait for interactive authorization,
133 /// which might take a considerable time to complete. For instance, if this
134 /// flag is set, it would be appropriate to query the user for passwords or
135 /// confirmation via Polkit or a similar framework.
136 ///
137 /// This flag is only useful when unprivileged code calls a more privileged
138 /// method call, and an authorization framework is deployed that allows
139 /// possibly interactive authorization. If no such framework is deployed it
140 /// has no effect. This flag should not be set by default by client
141 /// implementations. If it is set, the caller should also set a suitably
142 /// long timeout on the method call to make sure the user interaction may
143 /// complete. This flag is only valid for method call messages, and shall be
144 /// ignored otherwise.
145 ///
146 /// Interaction that takes place as a part of the effect of the method being
147 /// called is outside the scope of this flag, even if it could also be
148 /// characterized as authentication or authorization. For instance, in a
149 /// method call that directs a network management service to attempt to
150 /// connect to a virtual private network, this flag should control how the
151 /// network management service makes the decision "is this user allowed to
152 /// change system network configuration?", but it should not affect how or
153 /// whether the network management service interacts with the user to obtain
154 /// the credentials that are required for access to the VPN.
155 ///
156 /// If a this flag is not set on a method call, and a service determines
157 /// that the requested operation is not allowed without interactive
158 /// authorization, but could be allowed after successful interactive
159 /// authorization, it may return the
160 /// org.freedesktop.DBus.Error.InteractiveAuthorizationRequired error.
161 ///
162 /// The absence of this flag does not guarantee that interactive
163 /// authorization will not be applied, since existing services that pre-date
164 /// this flag might already use interactive authorization. However, existing
165 /// D-Bus APIs that will use interactive authorization should document that
166 /// the call may take longer than usual, and new D-Bus APIs should avoid
167 /// interactive authorization in the absence of this flag.
168 ALLOW_INTERACTIVE_AUTHORIZATION = 4,
169 }
170}
171
172raw_enum! {
173 #[repr(u8)]
174 pub enum Variant {
175 /// The object to send a call to, or the object a signal is emitted from.
176 /// The special path /org/freedesktop/DBus/Local is reserved;
177 /// implementations should not send messages with this path, and the
178 /// reference implementation of the bus daemon will disconnect any
179 /// application that attempts to do so. This header field is controlled by
180 /// the message sender.
181 PATH = 1,
182 /// The interface to invoke a method call on, or that a signal is emitted
183 /// from. Optional for method calls, required for signals. The special
184 /// interface org.freedesktop.DBus.Local is reserved; implementations should
185 /// not send messages with this interface, and the reference implementation
186 /// of the bus daemon will disconnect any application that attempts to do
187 /// so. This header field is controlled by the message sender.
188 INTERFACE = 2,
189 /// The member, either the method name or signal name. This header field is
190 /// controlled by the message sender.
191 MEMBER = 3,
192 /// The name of the error that occurred, for errors.
193 ERROR_NAME = 4,
194 /// The serial number of the message this message is a reply to. (The serial
195 /// number is the second UINT32 in the header.) This header field is
196 /// controlled by the message sender.
197 REPLY_SERIAL = 5,
198 /// The name of the connection this message is intended for. This field is
199 /// usually only meaningful in combination with the message bus (see the
200 /// section called “Message Bus Specification”), but other servers may
201 /// define their own meanings for it. This header field is controlled by the
202 /// message sender.
203 DESTINATION = 6,
204 /// Unique name of the sending connection. This field is usually only
205 /// meaningful in combination with the message bus, but other servers may
206 /// define their own meanings for it. On a message bus, this header field is
207 /// controlled by the message bus, so it is as reliable and trustworthy as
208 /// the message bus itself. Otherwise, this header field is controlled by
209 /// the message sender, unless there is out-of-band information that
210 /// indicates otherwise.
211 SENDER = 7,
212 /// The signature of the message body. If omitted, it is assumed to be the
213 /// empty signature "" (i.e. the body must be 0-length). This header field
214 /// is controlled by the message sender.
215 SIGNATURE = 8,
216 /// The number of Unix file descriptors that accompany the message. If
217 /// omitted, it is assumed that no Unix file descriptors accompany the
218 /// message. The actual file descriptors need to be transferred via platform
219 /// specific mechanism out-of-band. They must be sent at the same time as
220 /// part of the message itself. They may not be sent before the first byte
221 /// of the message itself is transferred or after the last byte of the
222 /// message itself. This header field is controlled by the message sender.
223 UNIX_FDS = 9,
224 }
225}