Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! Pure Rust library for interacting with the [udev](https://www.kernel.org/doc/ols/2003/ols2003-pages-249-257.pdf) userspace `devfs`.
2 //!
3 //! Uses the [`libc`](https://crates.io/crates/libc) and [`nix`](https://crates.io/crates/nix) crate to make syscalls to Linux.
4
5 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#;
6
7 #[macro_use]
8 extern crate bitflagsrust-analyzer cargo udevrs 0.4.0 bitflags/;
9
10 mod contextrust-analyzer cargo udevrs 0.4.0 context/;
11 mod devicerust-analyzer cargo udevrs 0.4.0 device/;
12 mod enumeraterust-analyzer cargo udevrs 0.4.0 enumerate/;
13 mod errorrust-analyzer cargo udevrs 0.4.0 error/;
14 mod filerust-analyzer cargo udevrs 0.4.0 file/;
15 mod hwdbrust-analyzer cargo udevrs 0.4.0 hwdb/;
16 mod listrust-analyzer cargo udevrs 0.4.0 list/;
17 mod logrust-analyzer cargo udevrs 0.4.0 log/;
18 mod moderust-analyzer cargo udevrs 0.4.0 mode/;
19 mod monitorrust-analyzer cargo udevrs 0.4.0 monitor/;
20 mod murmur_hashrust-analyzer cargo udevrs 0.4.0 murmur_hash/;
21 mod queuerust-analyzer cargo udevrs 0.4.0 queue/;
22 mod socketrust-analyzer cargo udevrs 0.4.0 socket/;
23 mod utilrust-analyzer cargo udevrs 0.4.0 util/;
24
25 pub use contextrust-analyzer cargo udevrs 0.4.0 context/::*;
26 pub use devicerust-analyzer cargo udevrs 0.4.0 device/::*;
27 pub use enumeraterust-analyzer cargo udevrs 0.4.0 enumerate/::*;
28 pub use errorrust-analyzer cargo udevrs 0.4.0 error/::*;
29 pub use filerust-analyzer cargo udevrs 0.4.0 file/::*;
30 pub use hwdbrust-analyzer cargo udevrs 0.4.0 hwdb/::*;
31 pub use listrust-analyzer cargo udevrs 0.4.0 list/::*;
32 pub use logrust-analyzer cargo udevrs 0.4.0 log/::*;
33 pub use moderust-analyzer cargo udevrs 0.4.0 mode/::*;
34 pub use monitorrust-analyzer cargo udevrs 0.4.0 monitor/::*;
35 pub use murmur_hashrust-analyzer cargo udevrs 0.4.0 murmur_hash/::*;
36 pub use queuerust-analyzer cargo udevrs 0.4.0 queue/::*;
37 pub use socketrust-analyzer cargo udevrs 0.4.0 socket/::*;
38 pub use utilrust-analyzer cargo udevrs 0.4.0 util/::*;
39
40 /// Creates a new [Udev] context.
41 pub fn udev_newrust-analyzer cargo udevrs 0.4.0 udev_new().() -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#> {
42 Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#::newrust-analyzer cargo udevrs 0.4.0 context/impl#[Udev]new().())
43 }
44
45 /// Gets the [LogPriority] for the [Udev] context.
46 pub fn udev_get_log_priorityrust-analyzer cargo udevrs 0.4.0 udev_get_log_priority().(udev: &Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#) -> LogPriorityrust-analyzer cargo udevrs 0.4.0 log/LogPriority# {
47 udev.log_priorityrust-analyzer cargo udevrs 0.4.0 context/impl#[Udev]log_priority().()
48 }
49
50 /// Sets the [LogPriority] for the [Udev] context.
51 pub fn udev_set_log_priorityrust-analyzer cargo udevrs 0.4.0 udev_set_log_priority().(udev: &mut Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#, val: LogPriorityrust-analyzer cargo udevrs 0.4.0 log/LogPriority#) {
52 udev.set_log_priorityrust-analyzer cargo udevrs 0.4.0 context/impl#[Udev]set_log_priority().(val);
53 }
54
55 /// Gets a reference to the next entry in a [UdevList].
56 ///
57 /// Breaks with the original `libudev` API by requiring a reference to the list, instead of a list
58 /// entry. This is because the C version uses a linked-list composed of pointers, we don't.
59 pub fn udev_list_entry_get_nextrust-analyzer cargo udevrs 0.4.0 udev_list_entry_get_next().(list: &UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
60 list.next_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]next_entry().()
61 }
62
63 /// Gets a mutable reference to the next entry in a [UdevList].
64 ///
65 /// Breaks with the original `libudev` API by requiring a reference to the list, instead of a list
66 /// entry. This is because the C version uses a linked-list composed of pointers, we don't.
67 pub fn udev_list_entry_get_next_mutrust-analyzer cargo udevrs 0.4.0 udev_list_entry_get_next_mut().(list: &mut UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
68 list.next_entry_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]next_entry_mut().()
69 }
70
71 /// Gets the name of the [UdevEntry].
72 pub fn udev_list_entry_get_namerust-analyzer cargo udevrs 0.4.0 udev_list_entry_get_name().(entry: &UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#) -> &str {
73 entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().()
74 }
75
76 /// Gets the value of the [UdevEntry].
77 pub fn udev_list_entry_get_valuerust-analyzer cargo udevrs 0.4.0 udev_list_entry_get_value().(entry: &UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#) -> &str {
78 entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().()
79 }
80
81 /// Helper function that iterates over every [UdevEntry] in the list, applying the function to each
82 /// entry.
83 ///
84 /// Breaks with the original `libudev` API by requiring a reference to the list, instead of a list
85 /// entry. This is because the C version uses a linked-list composed of pointers, we don't.
86 pub fn udev_list_entry_foreachrust-analyzer cargo udevrs 0.4.0 udev_list_entry_foreach().(list: &UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#, f: fn(&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()>) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
87 for entry in list.iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().() {
88 f(entry)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
89 }
90 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
91 }
92
93 /// Helper function that iterates over every [UdevEntry] in the list, applying the function to each
94 /// entry.
95 ///
96 /// Breaks with the original `libudev` API by requiring a reference to the list, instead of a list
97 /// entry. This is because the C version uses a linked-list composed of pointers, we don't.
98 pub fn udev_list_entry_foreach_mutrust-analyzer cargo udevrs 0.4.0 udev_list_entry_foreach_mut().(
99 list: &mut UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#,
100 f: fn(&mut UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()>,
101 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
102 for entry in list.iter_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter_mut().() {
103 f(entry)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
104 }
105 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
106 }
107
108 /// Creates a new [UdevDevice] from the provided [Udev] context.
109 pub fn udev_device_newrust-analyzer cargo udevrs 0.4.0 udev_device_new().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>) -> UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice# {
110 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::newrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new().(udev)
111 }
112
113 /// Gets a reference to the [Udev] context from an [UdevDevice].
114 pub fn udev_device_get_udevrust-analyzer cargo udevrs 0.4.0 udev_device_get_udev().(device: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &Udevrust-analyzer cargo udevrs 0.4.0 context/Udev# {
115 device.udevrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]udev().()
116 }
117
118 /// Gets a cloned reference to the [Udev] context from an [UdevDevice].
119 pub fn udev_device_get_udev_clonedrust-analyzer cargo udevrs 0.4.0 udev_device_get_udev_cloned().(device: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#> {
120 device.udev_clonedrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]udev_cloned().()
121 }
122
123 /// Creates new [UdevDevice], and fills in information from the sys
124 /// device and the udev database entry.
125 ///
126 /// The `syspath` is the absolute path to the device, including the sys mount point.
127 ///
128 /// The initial refcount is 1, and needs to be decremented to release the resources of the udev device.
129 ///
130 /// Returns: a new [UdevDevice], or `Error`, if it does not exist
131 pub fn udev_device_new_from_syspathrust-analyzer cargo udevrs 0.4.0 udev_device_new_from_syspath().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>, syspath: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
132 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_syspathrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_syspath().(udev, syspath)
133 }
134
135 /// Creates new [UdevDevice].
136 ///
137 /// From the `libudev` documentation:
138 ///
139 /// ```no_build,no_run
140 /// Fills in information from the `sys` device and the udev database entry.
141 ///
142 /// The device is looked-up by its major/minor number and type. Character and block device
143 /// numbers are not unique across the two types.
144 /// ```
145 ///
146 /// Parameters:
147 ///
148 /// - `udev`: [Udev] library context
149 /// - `type`: `char` or `block` device
150 /// - `devnum`: device major/minor number
151 ///
152 /// Returns: a new [UdevDevice], or `Err`, if it does not exist
153 pub fn udev_device_new_from_devnumrust-analyzer cargo udevrs 0.4.0 udev_device_new_from_devnum().(
154 udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>,
155 devtype: &str,
156 devnum: libcrust-analyzer cargo libc 0.2.169 crate/::dev_trust-analyzer cargo libc 0.2.169 unix/linux_like/linux/dev_t#,
157 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
158 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_devnumrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_devnum().(udev, devtype, devnum)
159 }
160
161 /// Creates a new [UdevDevice] from the subsystem and sysname.
162 ///
163 /// From the `libudev` documentation:
164 ///
165 /// ```no_build,no_run
166 /// Fills in information from the sys device and the udev database entry.
167 ///
168 /// The device is looked up by the subsystem and name string of the device, like "mem" / "zero", or "block" / "sda".
169 /// ```
170 ///
171 /// Parameters:
172 ///
173 /// - `udev`: [Udev] library context
174 /// - `subsystem`: the subsystem of the device
175 /// - `sysname`: the name of the device
176 ///
177 /// Returns: a new [UdevDevice], or `Err`, if it does not exist
178 pub fn udev_device_new_from_subsystem_sysnamerust-analyzer cargo udevrs 0.4.0 udev_device_new_from_subsystem_sysname().(
179 udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>,
180 subsystem: &str,
181 sysname: &str,
182 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
183 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_subsystem_sysnamerust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_subsystem_sysname().(udev, subsystem, sysname)
184 }
185
186 /// Create new [UdevDevice] from an ID string.
187 ///
188 /// From the `libudev` documentation:
189 ///
190 /// ```no_build,no_run
191 ///
192 /// Fill in information from the sys device and the udev database entry.
193 ///
194 /// The device is looked-up by a special string:
195 ///
196 /// b8:2 - block device major:minor
197 /// c128:1 - char device major:minor
198 /// n3 - network device ifindex
199 /// +sound:card29 - kernel driver core subsystem:device name
200 /// ```
201 ///
202 /// Parameters:
203 ///
204 /// - `udev`: udev library context
205 /// - `id`: text string identifying a kernel device
206 ///
207 /// Returns: a new [UdevDevice], or `Err`, if it does not exist
208 pub fn udev_device_new_from_device_idrust-analyzer cargo udevrs 0.4.0 udev_device_new_from_device_id().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>, id: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
209 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_device_idrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_device_id().(udev, id)
210 }
211
212 /// Create new udev device from the environment information.
213 ///
214 /// From the original `libudev` documnentation:
215 ///
216 /// ```no_build,no_run
217 /// Fills in information from the current process environment.
218 /// This only works reliable if the process is called from a udev rule.
219 /// It is usually used for tools executed from IMPORT= rules.
220 /// ```
221 ///
222 /// Parameters:
223 ///
224 /// - `udev`: [Udev] library context
225 ///
226 /// Returns: a new [UdevDevice], or `Err`, if it does not exist
227 pub fn udev_device_new_from_environmentrust-analyzer cargo udevrs 0.4.0 udev_device_new_from_environment().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
228 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_environmentrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_environment().(udev)
229 }
230
231 /// Gets the next parent [UdevDevice].
232 ///
233 /// From the `libudev` documentation:
234 ///
235 /// ```no_build,no_run
236 /// Find the next parent device, and fill in information from the sys
237 /// device and the udev database entry.
238 ///
239 /// @udev_device: the device to start searching from
240 ///
241 /// Returned device is not referenced. It is attached to the child
242 /// device, and will be cleaned up when the child device is cleaned up.
243 ///
244 /// It is not necessarily just the upper level directory, empty or not
245 /// recognized sys directories are ignored.
246 ///
247 /// It can be called as many times as needed, without caring about
248 /// references.
249 /// ```
250 ///
251 /// Returns: a new [UdevDevice], or `Err`, if it no parent exists.
252 pub fn udev_device_get_parentrust-analyzer cargo udevrs 0.4.0 udev_device_get_parent().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#>> {
253 dev.get_parentrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_parent().()
254 }
255
256 /// Gets the next parent [UdevDevice] based on `subsystem` and `devtype`.
257 ///
258 /// From the `libudev` documentation:
259 ///
260 /// ```no_build,no_run
261 /// Find the next parent device, with a matching subsystem and devtype
262 /// value, and fill in information from the sys device and the udev
263 /// database entry.
264 ///
265 /// If devtype is #NULL, only subsystem is checked, and any devtype will
266 /// match.
267 ///
268 /// Returned device is not referenced. It is attached to the child
269 /// device, and will be cleaned up when the child device is cleaned up.
270 ///
271 /// It can be called as many times as needed, without caring about
272 /// references.
273 /// ```
274 ///
275 /// Parameters:
276 ///
277 /// - `udev_device`: udev device to start searching from
278 /// - `subsystem`: the subsystem of the device
279 /// - `devtype`: the type (DEVTYPE) of the device
280 ///
281 /// Returns: a new [UdevDevice], or `Err` if no matching parent exists.
282 pub fn udev_device_get_parent_with_subsystem_devtyperust-analyzer cargo udevrs 0.4.0 udev_device_get_parent_with_subsystem_devtype().(
283 dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#,
284 subsystem: &str,
285 devtype: &str,
286 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#>> {
287 dev.get_parent_with_subsystem_devtyperust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_parent_with_subsystem_devtype().(subsystem, devtype)
288 }
289
290 /// Reads [UdevDevice] information from the persistent database file.
291 ///
292 /// Returns: `Ok(())` on success, `Err(Error)` otherwise
293 pub fn udev_device_read_dbrust-analyzer cargo udevrs 0.4.0 udev_device_read_db().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
294 dev.read_dbrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]read_db().()
295 }
296
297 /// Gets the [UdevDevice] device path.
298 ///
299 /// From the `libudev` documentation:
300 ///
301 /// ```no_build,no_run
302 /// Retrieve the kernel devpath value of the udev device. The path
303 /// does not contain the sys mount point, and starts with a '/'.
304 /// ```
305 pub fn udev_device_get_devpathrust-analyzer cargo udevrs 0.4.0 udev_device_get_devpath().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
306 dev.devpathrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]devpath().()
307 }
308
309 /// Gets the [UdevDevice] `syspath`.
310 ///
311 /// From the `libudev` documentation:
312 ///
313 /// ```no_build,no_run
314 /// Retrieve the sys path of the udev device. The path is an
315 /// absolute path and starts with the sys mount point.
316 /// ```
317 pub fn udev_device_get_syspathrust-analyzer cargo udevrs 0.4.0 udev_device_get_syspath().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
318 dev.syspathrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]syspath().()
319 }
320
321 /// Gets the [UdevDevice] `sysname`.
322 ///
323 /// From the `libudev` documentation:
324 ///
325 /// ```no_build,no_run
326 /// Get the kernel device name in /sys.
327 /// ```
328 pub fn udev_device_get_sysnamerust-analyzer cargo udevrs 0.4.0 udev_device_get_sysname().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
329 dev.sysnamerust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]sysname().()
330 }
331
332 /// Gets the [UdevDevice] `sysnum`.
333 ///
334 /// From the `libudev` documentation:
335 ///
336 /// ```no_build,no_run
337 /// Get the instance number of the device.
338 /// ```
339 pub fn udev_device_get_sysnumrust-analyzer cargo udevrs 0.4.0 udev_device_get_sysnum().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
340 dev.sysnumrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]sysnum().()
341 }
342
343 /// Gets the [UdevDevice] `devnode`.
344 ///
345 /// From the `libudev` documentation:
346 ///
347 /// ```no_build,no_run
348 /// Retrieve the device node file name belonging to the udev device.
349 /// The path is an absolute path, and starts with the device directory.
350 /// ```
351 ///
352 /// Returns: the device node file name of the [UdevDevice], or an empty string if none exists.
353 pub fn udev_device_get_devnoderust-analyzer cargo udevrs 0.4.0 udev_device_get_devnode().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
354 dev.get_devnoderust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_devnode().()
355 }
356
357 /// Gets whether the [UdevDevice] is initialized.
358 ///
359 /// From the `libudev` documentation:
360 ///
361 /// ```no_build,no_run
362 /// Check if udev has already handled the device and has set up
363 /// device node permissions and context, or has renamed a network
364 /// device.
365 ///
366 /// This is only implemented for devices with a device node
367 /// or network interfaces. All other devices return 1 here.
368 /// ```
369 pub fn udev_device_get_is_initializedrust-analyzer cargo udevrs 0.4.0 udev_device_get_is_initialized().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> bool {
370 dev.get_is_initializedrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_is_initialized().()
371 }
372
373 /// Gets the list of device links for the [UdevDevice].
374 ///
375 /// From the `libudev` documentation:
376 ///
377 /// ```no_build,no_run
378 /// Retrieve the list of device links pointing to the device file of
379 /// the udev device. The next list entry can be retrieved with
380 /// udev_list_entry_get_next(), which returns #NULL if no more entries exist.
381 ///
382 /// The devlink path can be retrieved from the list entry by
383 /// udev_list_entry_get_name(). The path is an absolute path, and starts with
384 /// the device directory.
385 /// ```
386 ///
387 /// Returns: the first entry of the device node link list
388 pub fn udev_device_get_devlinks_list_entryrust-analyzer cargo udevrs 0.4.0 udev_device_get_devlinks_list_entry().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
389 dev.get_devlinks_list_entryrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_devlinks_list_entry().()
390 }
391
392 /// Gets the first tags list entry in the [UdevDevice].
393 ///
394 /// From the `libudev` documentation:
395 ///
396 /// ```no_build,no_run
397 /// Retrieve the list of tags attached to the udev device. The next
398 /// list entry can be retrieved with udev_list_entry_get_next(),
399 /// which returns `None` if no more entries exist. The tag string
400 /// can be retrieved from the list entry by udev_list_entry_get_name().
401 /// ```
402 ///
403 /// Returns: the first entry of the tag list
404 pub fn udev_device_get_tags_list_entryrust-analyzer cargo udevrs 0.4.0 udev_device_get_tags_list_entry().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
405 dev.get_tags_list_entryrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_tags_list_entry().()
406 }
407
408 /// Gets the current tags list entry in the [UdevDevice].
409 ///
410 /// From the `libudev` documentation:
411 ///
412 /// ```no_build,no_run
413 /// Retrieve the list of tags attached to the udev device. The next
414 /// list entry can be retrieved with udev_list_entry_get_next(),
415 /// which returns `None` if no more entries exist. The tag string
416 /// can be retrieved from the list entry by udev_list_entry_get_name().
417 /// ```
418 ///
419 /// Returns: the current entry of the tag list
420 pub fn udev_device_get_current_tags_list_entryrust-analyzer cargo udevrs 0.4.0 udev_device_get_current_tags_list_entry().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
421 dev.get_current_tags_list_entryrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_current_tags_list_entry().()
422 }
423
424 /// Gets the first entry in the `sysattr` properties list.
425 ///
426 /// From the `libudev` documentation:
427 ///
428 /// ```no_build,no_run
429 /// Retrieve the list of available sysattrs, with value being empty;
430 /// This just return all available sysfs attributes for a particular
431 /// device without reading their values.
432 /// ```
433 ///
434 /// Returns: the first entry of the property list
435 pub fn udev_device_get_sysattr_list_entryrust-analyzer cargo udevrs 0.4.0 udev_device_get_sysattr_list_entry().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
436 dev.get_sysattr_list_entryrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_sysattr_list_entry().()
437 }
438
439 /// Gets the value of a given property.
440 pub fn udev_device_get_property_valuerust-analyzer cargo udevrs 0.4.0 udev_device_get_property_value().<'d>(dev: &'d UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#, key: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'d str> {
441 dev.get_property_valuerust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_property_value().(key)
442 }
443
444 /// Gets the kernel driver name.
445 ///
446 /// Returns: the kernel driver name, or `None` if none is attached.
447 pub fn udev_device_get_driverrust-analyzer cargo udevrs 0.4.0 udev_device_get_driver().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&str> {
448 dev.get_driverrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_driver().()
449 }
450
451 /// Gets the device major/minor number.
452 pub fn udev_device_get_devnumrust-analyzer cargo udevrs 0.4.0 udev_device_get_devnum().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> u64 {
453 dev.get_devnumrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_devnum().()
454 }
455
456 /// Gets the device action.
457 ///
458 /// From the `libudev` documentation:
459 ///
460 /// ```no_build,no_run
461 /// This is only valid if the device was received through a monitor. Devices read from
462 /// sys do not have an action string. Usual actions are: add, remove, change, online,
463 /// offline.
464 /// ```
465 ///
466 /// Returns the kernel action value, or `None` if there is no action value available.
467 pub fn udev_device_get_actionrust-analyzer cargo udevrs 0.4.0 udev_device_get_action().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> &str {
468 dev.actionrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]action().()
469 }
470
471 /// Gets the device event sequence number.
472 ///
473 /// From the `libudev` documentation:
474 ///
475 /// ```no_build,no_run
476 /// This is only valid if the device was received through a monitor. Devices read from
477 /// sys do not have a sequence number.
478 /// ```
479 ///
480 /// Returns the kernel event sequence number, or zero if none is available.
481 pub const fn udev_device_get_seqnumrust-analyzer cargo udevrs 0.4.0 udev_device_get_seqnum().(dev: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> u64 {
482 dev.seqnumrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]seqnum().()
483 }
484
485 /// Gets the number of microseconds since the [UdevDevice] was initialized.
486 ///
487 /// From the `libudev` documentation:
488 ///
489 /// ```no_build,no_run
490 /// Return the number of microseconds passed since udev set up the
491 /// device for the first time.
492 ///
493 /// This is only implemented for devices with need to store properties
494 /// in the udev database. All other devices return 0 here.
495 /// ```
496 ///
497 /// Returns: the number of microseconds since the device was first seen.
498 pub fn udev_device_get_usec_since_initializedrust-analyzer cargo udevrs 0.4.0 udev_device_get_usec_since_initialized().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> u64 {
499 dev.get_usec_since_initializedrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_usec_since_initialized().()
500 }
501
502 /// Gets the sys attribute file value.
503 ///
504 /// From the `libudev` documentation:
505 ///
506 /// ```no_build,no_run
507 /// The retrieved value is cached in the device. Repeated calls will return the same
508 /// value and not open the attribute again.
509 /// ```
510 ///
511 /// Returns: the content of a sys attribute file, or `None` if there is no sys attribute value.
512 pub fn udev_device_get_sysattr_valuerust-analyzer cargo udevrs 0.4.0 udev_device_get_sysattr_value().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#, sysattr: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
513 dev.get_sysattr_valuerust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_sysattr_value().(sysattr)
514 }
515
516 /// Gets whether the [UdevDevice] has the provided `tag` associated.
517 ///
518 /// From the `libudev` documentation:
519 ///
520 /// ```no_build,no_run
521 /// Check if a given device has a certain tag associated.
522 /// ```
523 pub fn udev_device_has_tagrust-analyzer cargo udevrs 0.4.0 udev_device_has_tag().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#, tag: &str) -> bool {
524 dev.has_tagrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]has_tag().(tag)
525 }
526
527 /// Gets whether the [UdevDevice] has the provided current `tag` associated.
528 ///
529 /// From the `libudev` documentation:
530 ///
531 /// ```no_build,no_run
532 /// Check if a given device has a certain tag associated.
533 /// ```
534 ///
535 /// TODO: `eudev` does not database does not support current tags, implement in this library.
536 pub fn udev_device_has_current_tagrust-analyzer cargo udevrs 0.4.0 udev_device_has_current_tag().(dev: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#, tag: &str) -> bool {
537 dev.has_tagrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]has_tag().(tag)
538 }
539
540 /// Creates a new [UdevMonitor] from the provided parameters.
541 ///
542 /// Parameters:
543 ///
544 /// `udev`: udev library context
545 /// `name`: name of event source
546 ///
547 /// From the `libudev` documentation:
548 ///
549 /// ```no_build,no_run
550 /// Create new udev monitor and connect to a specified event
551 /// source. Valid sources identifiers are "udev" and "kernel".
552 ///
553 /// Applications should usually not connect directly to the
554 /// "kernel" events, because the devices might not be usable
555 /// at that time, before `udev` has configured them, and created
556 /// device nodes. Accessing devices at the same time as `udev`,
557 /// might result in unpredictable behavior. The "`udev`" events
558 /// are sent out after `udev` has finished its event processing,
559 /// all rules have been processed, and needed device nodes are
560 /// created.
561 /// ```
562 ///
563 /// Returns: a new [UdevMonitor], or [Error], in case of an error
564 pub fn udev_monitor_new_from_netlinkrust-analyzer cargo udevrs 0.4.0 udev_monitor_new_from_netlink().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>, name: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#>> {
565 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#::new_from_netlinkrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new_from_netlink().(udev, name)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
566 }
567
568 /// Gets the [Udev] context of the [UdevMonitor].
569 pub fn udev_monitor_get_udevrust-analyzer cargo udevrs 0.4.0 udev_monitor_get_udev().(monitor: &UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#> {
570 monitor.udevrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]udev().()
571 }
572
573 /// Binds the [UdevMonitor] socket to the event source.
574 pub fn udev_monitor_enable_receivingrust-analyzer cargo udevrs 0.4.0 udev_monitor_enable_receiving().(monitor: &mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
575 monitor.enable_receivingrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]enable_receiving().()
576 }
577
578 /// Sets the size of the kernel socket buffer.
579 ///
580 /// From the `libudev` documentation:
581 ///
582 /// ```no_build,no_run
583 /// Set the size of the kernel socket buffer. This call needs the
584 /// appropriate privileges to succeed.
585 /// ```
586 ///
587 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
588 pub fn udev_monitor_set_receive_buffer_sizerust-analyzer cargo udevrs 0.4.0 udev_monitor_set_receive_buffer_size().(monitor: &mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#, size: usize) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
589 monitor.set_receive_buffer_sizerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_receive_buffer_size().(size)
590 }
591
592 /// Gets the [UdevMonitor] socket file descriptor.
593 pub fn udev_monitor_get_fdrust-analyzer cargo udevrs 0.4.0 udev_monitor_get_fd().(monitor: &UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> i32 {
594 monitor.sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]sock().()
595 }
596
597 /// Receives data from the [UdevMonitor] socket.
598 ///
599 /// From the `libudev` documentation:
600 ///
601 /// ```no_build,no_run
602 /// Receive data from the udev monitor socket, allocate a new udev
603 /// device, fill in the received data, and return the device.
604 ///
605 /// Only socket connections with uid=0 are accepted.
606 ///
607 /// The monitor socket is by default set to NONBLOCK. A variant of poll() on
608 /// the file descriptor returned by udev_monitor_get_fd() should to be used to
609 /// wake up when new devices arrive, or alternatively the file descriptor
610 /// switched into blocking mode.
611 /// ```
612 ///
613 /// Returns: `Ok(UdevDevice)` on success, `Err(Error)` otherwise.
614 pub fn udev_monitor_receive_devicerust-analyzer cargo udevrs 0.4.0 udev_monitor_receive_device().(monitor: &mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
615 monitor.receive_devicerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]receive_device().()
616 }
617
618 /// Adds an [UdevEntry] into the filter subsystem list.
619 ///
620 /// From `libudev` documentation:
621 ///
622 /// Parameters:
623 ///
624 /// - `subsystem`: the subsystem value to match the incoming devices against
625 /// - must be non-empty
626 /// - `devtype`: the devtype value to match the incoming devices against
627 ///
628 /// ```no_build,no_run
629 /// This filter is efficiently executed inside the kernel, and libudev subscribers
630 /// will usually not be woken up for devices which do not match.
631 ///
632 /// The filter must be installed before the monitor is switched to listening mode.
633 /// ```
634 ///
635 /// Returns `Ok` on success, `Err` otherwise.
636 pub fn udev_monitor_filter_add_match_subsystem_devtyperust-analyzer cargo udevrs 0.4.0 udev_monitor_filter_add_match_subsystem_devtype().<'m>(
637 monitor: &'m mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#,
638 subsystem: &str,
639 devtype: &str,
640 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'m UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
641 monitor.filter_add_match_subsystem_devtyperust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_add_match_subsystem_devtype().(subsystem, devtype)
642 }
643
644 /// Adds an [UdevEntry] into the filter tag list.
645 ///
646 /// From `libudev` documentation:
647 ///
648 /// - `tag`: the name of a tag
649 /// - must be non-empty
650 ///
651 /// ```no_build,no_run
652 /// This filter is efficiently executed inside the kernel, and libudev subscribers
653 /// will usually not be woken up for devices which do not match.
654 ///
655 /// The filter must be installed before the monitor is switched to listening mode.
656 /// ```
657 ///
658 /// Returns `Ok` on success, `Err` otherwise.
659 pub fn udev_monitor_filter_add_match_tagrust-analyzer cargo udevrs 0.4.0 udev_monitor_filter_add_match_tag().<'m>(
660 monitor: &'m mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#,
661 tag: &str,
662 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'m UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
663 monitor.filter_add_match_tagrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_add_match_tag().(tag)
664 }
665
666 /// Updates the monitor socket filter.
667 ///
668 /// From the `libudev` documentation:
669 ///
670 /// ```no_build,no_run
671 /// Update the installed socket filter. This is only needed,
672 /// if the filter was removed or changed.
673 /// ```
674 ///
675 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
676 pub fn udev_monitor_filter_updaterust-analyzer cargo udevrs 0.4.0 udev_monitor_filter_update().(monitor: &mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
677 monitor.filter_updaterust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_update().()
678 }
679
680 /// Removes all filters from the [UdevMonitor].
681 ///
682 /// Returns `Ok(())` on success, `Err(Error)` otherwise.
683 pub fn udev_monitor_filter_removerust-analyzer cargo udevrs 0.4.0 udev_monitor_filter_remove().(monitor: &mut UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
684 monitor.filter_removerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_remove().()
685 }
686
687 /// Creates a new [UdevEnumerate].
688 pub fn udev_enumerate_newrust-analyzer cargo udevrs 0.4.0 udev_enumerate_new().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#> {
689 Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#::newrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]new().(udev))
690 }
691
692 /// Adds an entry to the match subsystem [UdevEntry] list.
693 ///
694 /// From the `libudev` documentation:
695 ///
696 /// ```no_build,no_run
697 /// Match only devices belonging to a certain kernel subsystem.
698 /// ```
699 ///
700 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
701 pub fn udev_enumerate_add_match_subsystemrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_subsystem().<'e>(
702 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
703 subsystem: &str,
704 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
705 enumerate.add_match_subsystemrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_match_subsystem().(subsystem)
706 }
707
708 /// Adds an entry to the no-match subsystem [UdevEntry] list.
709 ///
710 /// From the `libudev` documentation:
711 ///
712 /// ```no_build,no_run
713 /// Match only devices not belonging to a certain kernel subsystem.
714 /// ```
715 ///
716 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
717 pub fn udev_enumerate_add_nomatch_subsystemrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_nomatch_subsystem().<'e>(
718 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
719 subsystem: &str,
720 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
721 enumerate.add_nomatch_subsystemrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_nomatch_subsystem().(subsystem)
722 }
723
724 /// Adds an entry to the match sysattr [UdevEntry] list.
725 ///
726 /// From the `libudev` documentation:
727 ///
728 /// ```no_build,no_run
729 /// Match only devices with a given /sys device attribute.
730 /// ```
731 ///
732 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
733 pub fn udev_enumerate_add_match_sysattrrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_sysattr().<'e>(
734 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
735 sysattr: &str,
736 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
737 enumerate.add_match_sysattrrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_match_sysattr().(sysattr)
738 }
739
740 /// Adds an entry to the no-match sysattr [UdevEntry] list.
741 ///
742 /// From the `libudev` documentation:
743 ///
744 /// ```no_build,no_run
745 /// Match only devices without a given /sys device attribute.
746 /// ```
747 ///
748 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
749 pub fn udev_enumerate_add_nomatch_sysattrrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_nomatch_sysattr().<'e>(
750 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
751 sysattr: &str,
752 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
753 enumerate.add_nomatch_sysattrrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_nomatch_sysattr().(sysattr)
754 }
755
756 /// Adds an entry to the match properties [UdevEntry] list.
757 ///
758 /// From the `libudev` documentation:
759 ///
760 /// ```no_build,no_run
761 /// Match only devices with a certain property.
762 /// ```
763 ///
764 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
765 pub fn udev_enumerate_add_match_propertyrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_property().<'e>(
766 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
767 property: &str,
768 value: &str,
769 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
770 enumerate.add_match_propertyrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_match_property().(property, value)
771 }
772
773 /// Adds an entry to the match sysname [UdevEntry] list.
774 ///
775 /// From the `libudev` documentation:
776 ///
777 /// ```no_build,no_run
778 /// Match only devices with a given /sys device name.
779 /// ```
780 ///
781 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
782 pub fn udev_enumerate_add_match_sysnamerust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_sysname().<'e>(
783 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
784 sysname: &str,
785 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
786 enumerate.add_match_sysnamerust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_match_sysname().(sysname)
787 }
788
789 /// Adds an entry to the match tag [UdevEntry] list.
790 ///
791 /// From the `libudev` documentation:
792 ///
793 /// ```no_build,no_run
794 /// Match only devices with a certain tag.
795 /// ```
796 ///
797 /// Returns `Ok(UdevEntry)` on success, `Err(Error)` otherwise.
798 pub fn udev_enumerate_add_match_tagrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_tag().<'e>(
799 enumerate: &'e mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
800 tag: &str,
801 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&'e UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
802 enumerate.add_match_tagrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_match_tag().(tag)
803 }
804
805 /// Sets the parent [UdevDevice] on a given device tree.
806 ///
807 /// From the `libudev` documentation:
808 ///
809 /// ```no_build,no_run
810 /// Return the devices on the subtree of one given device. The parent
811 /// itself is included in the list.
812 ///
813 /// A reference for the device is held until the udev_enumerate context
814 /// is cleaned up.
815 /// ```
816 ///
817 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
818 pub fn udev_enumerate_add_match_parentrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_parent().(
819 enumerate: &mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
820 dev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#>,
821 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
822 enumerate.set_parentrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]set_parent().(dev);
823 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
824 }
825
826 /// Sets whether the match lists are initialized.
827 ///
828 /// From the `libudev` documentation:
829 ///
830 /// ```no_build,no_run
831 /// Match only devices which udev has set up already. This makes
832 /// sure, that the device node permissions and context are properly set
833 /// and that network devices are fully renamed.
834 ///
835 /// Usually, devices which are found in the kernel but not already
836 /// handled by udev, have still pending events. Services should subscribe
837 /// to monitor events and wait for these devices to become ready, instead
838 /// of using uninitialized devices.
839 ///
840 /// For now, this will not affect devices which do not have a device node
841 /// and are not network interfaces.
842 /// ```
843 ///
844 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
845 pub fn udev_enumerate_add_match_is_initializedrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_match_is_initialized().(
846 enumerate: &mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#,
847 val: bool,
848 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
849 enumerate.set_match_is_initializedrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]set_match_is_initialized().(val);
850 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
851 }
852
853 /// Adds a devices to the list of devices.
854 ///
855 /// From the `libudev` documentation:
856 ///
857 /// ```no_build,no_run
858 /// Add a device to the list of devices, to retrieve it back sorted in dependency order.
859 /// ```
860 ///
861 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
862 pub fn udev_enumerate_add_syspathrust-analyzer cargo udevrs 0.4.0 udev_enumerate_add_syspath().(enumerate: &mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#, syspath: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
863 enumerate.add_syspathrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]add_syspath().(syspath)
864 }
865
866 /// Scan `/sys` for devices which match the given filters.
867 ///
868 /// From the `libudev` documentation:
869 ///
870 /// ```no_build,no_run
871 /// Scan /sys for all devices which match the given filters. No matches
872 /// will return all currently available devices.
873 /// ```
874 ///
875 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
876 pub fn udev_enumerate_scan_devicesrust-analyzer cargo udevrs 0.4.0 udev_enumerate_scan_devices().(enumerate: &mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
877 enumerate.scan_devicesrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]scan_devices().()
878 }
879
880 /// Scans `/sys` for all kernel subsystems.
881 ///
882 /// From `libudev` documentation:
883 ///
884 /// ```no_build,no_run
885 /// Scan /sys for all kernel subsystems, including buses, classes, drivers.
886 /// ```
887 ///
888 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
889 pub fn udev_enumerate_scan_subsystemsrust-analyzer cargo udevrs 0.4.0 udev_enumerate_scan_subsystems().(enumerate: &mut UdevEnumeraterust-analyzer cargo udevrs 0.4.0 enumerate/UdevEnumerate#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
890 enumerate.scan_subsystemsrust-analyzer cargo udevrs 0.4.0 enumerate/impl#[UdevEnumerate]scan_subsystems().()
891 }
892
893 /// Creates a new [UdevQueue].
894 pub fn udev_queue_newrust-analyzer cargo udevrs 0.4.0 udev_queue_new().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>) -> Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#> {
895 Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#::newrust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]new().(udev))
896 }
897
898 /// Gets a reference to the [Udev] context.
899 pub fn udev_queue_get_udevrust-analyzer cargo udevrs 0.4.0 udev_queue_get_udev().(queue: &UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#) -> &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#> {
900 queue.udevrust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]udev().()
901 }
902
903 /// Checks if [Udev] is active on the system.
904 pub fn udev_queue_get_udev_is_activerust-analyzer cargo udevrs 0.4.0 udev_queue_get_udev_is_active().(queue: &UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#) -> bool {
905 queue.udev_is_activerust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]udev_is_active().()
906 }
907
908 /// Gets whether [UdevQueue] is currently processing any events.
909 pub fn udev_queue_get_queue_is_emptyrust-analyzer cargo udevrs 0.4.0 udev_queue_get_queue_is_empty().(queue: &UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#) -> bool {
910 queue.queue_is_emptyrust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]queue_is_empty().()
911 }
912
913 /// Gets a file descriptor to watch for a queue to become empty.
914 pub fn udev_queue_get_fdrust-analyzer cargo udevrs 0.4.0 udev_queue_get_fd().(queue: &mut UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<i32> {
915 queue.get_fdrust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]get_fd().()
916 }
917
918 /// Clears the watched file descriptor for queue changes.
919 ///
920 /// # Safety
921 ///
922 /// Users must ensure that every [UdevQueue] has a unique file descriptor, if the descriptor is
923 /// non-negative.
924 ///
925 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
926 pub fn udev_queue_flushrust-analyzer cargo udevrs 0.4.0 udev_queue_flush().(queue: &mut UdevQueuerust-analyzer cargo udevrs 0.4.0 queue/UdevQueue#) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
927 queue.flushrust-analyzer cargo udevrs 0.4.0 queue/impl#[UdevQueue]flush().()
928 }
929
930 /// Creates a new [UdevHwdb].
931 ///
932 /// From the `libudev` documentation:
933 ///
934 /// ```no_build,no_run
935 /// Provides access to the static hardware properties database; the database to
936 /// use can be overriden by setting the UDEV_HWDB_BIN environment
937 /// variable to its file name.
938 /// ```
939 pub fn udev_hwdb_newrust-analyzer cargo udevrs 0.4.0 udev_hwdb_new().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<UdevHwdbrust-analyzer cargo udevrs 0.4.0 hwdb/UdevHwdb#>> {
940 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(UdevHwdbrust-analyzer cargo udevrs 0.4.0 hwdb/UdevHwdb#::newrust-analyzer cargo udevrs 0.4.0 hwdb/impl#[UdevHwdb]new().(udev)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))
941 }
942
943 /// Looks up a matching device in the hardware database.
944 ///
945 /// Parameters:
946 ///
947 /// - `modalias`: modalias string
948 /// - `flags`: (unused), preserved for easier mapping to `libudev` C API
949 ///
950 /// From the `libudev` documentation:
951 ///
952 /// ```no_build,no_run
953 /// The lookup key is a `modalias` string, whose formats are defined for the Linux kernel modules.
954 /// Examples are: pci:v00008086d00001C2D*, usb:v04F2pB221*. The first entry
955 /// of a list of retrieved properties is returned.
956 /// ```
957 ///
958 /// Returns: an optional reference to an [UdevEntry].
959 pub fn udev_hwdb_get_properties_list_entryrust-analyzer cargo udevrs 0.4.0 udev_hwdb_get_properties_list_entry().<'h>(
960 hwdb: &'h mut UdevHwdbrust-analyzer cargo udevrs 0.4.0 hwdb/UdevHwdb#,
961 modalias: &str,
962 flags: u32,
963 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'h UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
964 hwdb.get_properties_list_entryrust-analyzer cargo udevrs 0.4.0 hwdb/impl#[UdevHwdb]get_properties_list_entry().(modalias, flags)
965 }
966
967 /// Looks up a matching device modalias in the hardware database and returns the list of properties.
968 pub fn udev_hwdb_queryrust-analyzer cargo udevrs 0.4.0 udev_hwdb_query().<'h>(hwdb: &'h mut UdevHwdbrust-analyzer cargo udevrs 0.4.0 hwdb/UdevHwdb#, modalias: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'h UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#> {
969 // populate list if modalias is present and return
970 hwdb.queryrust-analyzer cargo udevrs 0.4.0 hwdb/impl#[UdevHwdb]query().(modalias)
971 }
972
973 /// Looks up a specific matching property name (key) for device modalias
974 ///
975 /// ```no_run
976 /// use std::sync::Arc;
977 /// use udevrs::{Udev, UdevHwdb};
978 /// let udev = Arc::new(Udev::new());
979 ///
980 /// let mut hwdb = UdevHwdb::new(udev).unwrap();
981 /// let query = udevrs::udev_hwdb_query_one(&mut hwdb, "usb:v1D6Bp0001", "ID_VENDOR_FROM_DATABASE");
982 /// assert_eq!(query, Some("Linux Foundation"));
983 /// ```
984 pub fn udev_hwdb_query_onerust-analyzer cargo udevrs 0.4.0 udev_hwdb_query_one().<'h>(
985 hwdb: &'h mut UdevHwdbrust-analyzer cargo udevrs 0.4.0 hwdb/UdevHwdb#,
986 modalias: &str,
987 name: &str,
988 ) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&'h str> {
989 hwdb.queryrust-analyzer cargo udevrs 0.4.0 hwdb/impl#[UdevHwdb]query().(modalias)
990 .and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|list| list.iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| e.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().name).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|e| e.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().()))
991 }
992
993 /// Encodes provided string, removing potentially unsafe characters.
994 ///
995 /// From the `libudev` documentation:
996 ///
997 /// ```no_build,no_run
998 /// Encode all potentially unsafe characters of a string to the
999 /// corresponding 2 char hex value prefixed by '\x'.
1000 /// ```
1001 ///
1002 /// Returns: `Ok(String)` on success, `Err(Error)` otherwise
1003 pub fn udev_util_encode_stringrust-analyzer cargo udevrs 0.4.0 udev_util_encode_string().(arg: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> {
1004 utilrust-analyzer cargo udevrs 0.4.0 util/::encode_stringrust-analyzer cargo udevrs 0.4.0 util/encode_string().(arg)
1005 }