Debian Codegraph @

src/monitor.rs

raw symbols SCIP
1 //! Connects to a device event source.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/, fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/, fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/, iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/, memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/, 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#};
4
5 use craterust-analyzer cargo udevrs 0.4.0 crate/::{
6 utilrust-analyzer cargo udevrs 0.4.0 util/, Errorrust-analyzer cargo udevrs 0.4.0 error/Error#, Resultrust-analyzer cargo udevrs 0.4.0 error/Result#, Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#, UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#, UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#, UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#, UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#, UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#,
7 };
8
9 /// UDEV Monitor magic bytes
10 pub const UDEV_MONITOR_MAGICrust-analyzer cargo udevrs 0.4.0 monitor/UDEV_MONITOR_MAGIC.: u32 = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().([0xfe, 0xed, 0xca, 0xfe]);
11 // FIXME: put behind a feature flag or conditional compilation for platforms with a different run
12 // directory.
13 /// Default filesystem path for the UDEV `run` directory.
14 pub const UDEV_ROOT_RUNrust-analyzer cargo udevrs 0.4.0 monitor/UDEV_ROOT_RUN.: &str = "/run";
15 /// Maximum length of BPF socket filters.
16 pub const BPF_FILTER_LENrust-analyzer cargo udevrs 0.4.0 monitor/BPF_FILTER_LEN.: usize = 512;
17
18 /// Collection of BPF socket filters for kernel events.
19 #[repr(C)]
20 pub struct BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#<const N: usize>([libcrust-analyzer cargo libc 0.2.169 crate/::sock_filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#; N]);
21
22 impl<const N: usize> BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#<N> {
23 /// Creates a new [BpfFilters].
24 pub const fn newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]new().() -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`] {
25 Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`](
26 [libcrust-analyzer cargo libc 0.2.169 crate/::sock_filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter# {
27 coderust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#code.: 0,
28 jtrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jt.: 0,
29 jfrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jf.: 0,
30 krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#k.: 0,
31 }; N],
32 )
33 }
34
35 /// Gets a reference to the list of [`sock_filter`](libc::sock_filter)s.
36 pub fn filtersrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]filters().(&self) -> &[libcrust-analyzer cargo libc 0.2.169 crate/::sock_filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#] {
37 self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()
38 }
39
40 /// Sets the code and data in the BPF socket filter.
41 ///
42 /// Increments the filter index on success.
43 ///
44 /// Returns: `Err(Error)` if the index is out-of-bounds
45 pub fn bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut self, i: &mut usize, code: u16, data: u32) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
46 let len = self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
47 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len {
48 self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = libcrust-analyzer cargo libc 0.2.169 crate/::sock_filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter# {
49 coderust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#code.,
50 krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#k.: data,
51 jtrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jt.: 0,
52 jfrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jf.: 0,
53 };
54 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i = i.saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_add().(1);
55 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
56 } else {
57 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
58 "invalid socket filter index: {i}, length: {len}"
59 )))
60 }
61 }
62
63 /// Sets all the fields in the BPF socket filter.
64 ///
65 /// Increments the filter index on success.
66 ///
67 /// Returns: `Err(Error)` if the index is out-of-bounds
68 pub fn bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(&mut self, i: &mut usize, code: u16, data: u32, jt: u8, jf: u8) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
69 let len = self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0..lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
70 if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().len {
71 self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0.[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut(). = libcrust-analyzer cargo libc 0.2.169 crate/::sock_filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter# {
72 coderust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#code.,
73 krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#k.: data,
74 jtrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jt.,
75 jfrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jf.,
76 };
77 *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&mut T`][Deref]deref().i = i.saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_add().(1);
78 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
79 } else {
80 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
81 "invalid socket filter index: {i}, length: {len}"
82 )))
83 }
84 }
85
86 /// Gets the length of set socket filters in the [BpfFilters].
87 pub fn lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]len().(&self) -> usize {
88 self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0.
89 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
90 .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|f| f.coderust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#code. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u16][`PartialEq<Self>`]ne().0 || f.jtrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jt. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 || f.jfrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#jf. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]ne().0 || f.krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_filter#k. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0)
91 .countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().()
92 }
93
94 /// Gets whether the [BpfFilters] has any set socket filters.
95 pub fn is_emptyrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]is_empty().(&self) -> bool {
96 self.lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0
97 }
98
99 /// Gets the [BpfFilters] as a [`sock_fprog`](libc::sock_fprog) FFI object.
100 ///
101 /// SAFETY: the resulting `sock_fprog` contains a mutable pointer that should not be accessed
102 /// directly. The result is meant to be passed to Linux API functions that require
103 /// `sock_fprog`.
104 pub fn as_sock_fprogrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]as_sock_fprog().(&mut self) -> libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog# {
105 libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog# {
106 lenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#len.: self.lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]len().() as u16,
107 filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#filter.: self.0rust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#0..as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(),
108 }
109 }
110 }
111 impl<const N: usize> Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# for BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#<N> {
112 fn defaultrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`][Default]default().() -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`][Default] {
113 Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`][Default]::newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]new().()
114 }
115 }
116
117 /// Handles device event sources.
118 pub struct UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor# {
119 udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#udev.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>,
120 sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.: i32,
121 snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#,
122 snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_group.: UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#,
123 snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_trusted_sender.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#,
124 snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#,
125 snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination_group.: UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#,
126 addrlenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#addrlen.: usize,
127 filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list.: UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#,
128 filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list.: UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#,
129 boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound.: bool,
130 filterrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter.: BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#<BPF_FILTER_LENrust-analyzer cargo udevrs 0.4.0 monitor/BPF_FILTER_LEN.>,
131 }
132
133 impl UdevMonitorrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor# {
134 /// Creates a new [UdevMonitor].
135 pub fn newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]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#<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]> {
136 let filter_subsystem_list = UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#::newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]new().(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(&udev));
137 let filter_tag_list = UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList#::newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]new().(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(&udev));
138
139 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
140 udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#udev.,
141 sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.: 0,
142 snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::new_nlrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]new_nl().(libcrust-analyzer cargo libc 0.2.169 crate/::AF_NETLINKrust-analyzer cargo libc 0.2.169 unix/linux_like/AF_NETLINK., 0, 2),
143 snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_group.: UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#,
144 snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_trusted_sender.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::new_nlrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]new_nl().(libcrust-analyzer cargo libc 0.2.169 crate/::AF_NETLINKrust-analyzer cargo libc 0.2.169 unix/linux_like/AF_NETLINK., 0, 0),
145 snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination.: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::new_nlrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]new_nl().(libcrust-analyzer cargo libc 0.2.169 crate/::AF_NETLINKrust-analyzer cargo libc 0.2.169 unix/linux_like/AF_NETLINK., 0, 0),
146 snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination_group.: UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#,
147 addrlenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#addrlen.: memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>(),
148 filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list.,
149 filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list.,
150 boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound.: false,
151 filterrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter.: BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#::newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]new().(),
152 })
153 }
154
155 /// Creates a [UdevMonitor] from group name and socket file descriptor.
156 pub fn new_from_netlink_fdrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new_from_netlink_fd().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#> + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#>(
157 udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>,
158 name: N,
159 fd: i32,
160 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]> {
161 let group = match name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().() {
162 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev# => {
163 if fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::OpenOptionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/OpenOptions#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]new().()
164 .readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]read().(true)
165 .openrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/impl#[OpenOptions]open().(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("{UDEV_ROOT_RUN}/udev/control"))
166 .is_okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]is_ok().()
167 {
168 let err_msg = "the udev service seems not to be active, disable the monitor";
169 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
170 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#)
171 } else {
172 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev#)
173 }
174 }
175 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel# => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel#),
176
177 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None# => {
178 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid netlink group: {name}")))
179 }
180 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
181
182 let mut udev_monitor = Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]::newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new().(udev)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
183
184 udev_monitor.set_snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_group().(group);
185 udev_monitor.set_snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_destination_group().(UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev#);
186
187 if fd rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
188 // SAFETY: all arguments are valid, and the return value is checked before use.
189 udev_monitor.set_sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_sock().(unsafe {
190 libcrust-analyzer cargo libc 0.2.169 crate/::socketrust-analyzer cargo libc 0.2.169 socket().(
191 libcrust-analyzer cargo libc 0.2.169 crate/::PF_NETLINKrust-analyzer cargo libc 0.2.169 unix/linux_like/PF_NETLINK.,
192 libcrust-analyzer cargo libc 0.2.169 crate/::SOCK_RAWrust-analyzer cargo libc 0.2.169 unix/linux_like/SOCK_RAW. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::SOCK_CLOEXECrust-analyzer cargo libc 0.2.169 unix/linux_like/SOCK_CLOEXEC. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::SOCK_NONBLOCKrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/SOCK_NONBLOCK.,
193 libcrust-analyzer cargo libc 0.2.169 crate/::NETLINK_KOBJECT_UEVENTrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/NETLINK_KOBJECT_UEVENT.,
194 )
195 });
196
197 if udev_monitor.sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]sock().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
198 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
199 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("error getting socket: {errno}");
200
201 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
202
203 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::Iorust-analyzer cargo udevrs 0.4.0 error/Error#Io#(err_msg))
204 } else {
205 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(udev_monitor)
206 }
207 } else {
208 udev_monitor.set_sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_sock().(fd);
209 udev_monitor.set_nl_addressrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_nl_address().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
210
211 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(udev_monitor.with_boundrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_bound().(true))
212 }
213 }
214
215 /// Creates a new [UdevMonitor] from the provided parameters.
216 ///
217 /// Parameters:
218 ///
219 /// `udev`: udev library context
220 /// `name`: name of event source
221 ///
222 /// From the `libudev` documentation:
223 ///
224 /// ```no_build,no_run
225 /// Create new udev monitor and connect to a specified event
226 /// source. Valid sources identifiers are "udev" and "kernel".
227 ///
228 /// Applications should usually not connect directly to the
229 /// "kernel" events, because the devices might not be usable
230 /// at that time, before `udev` has configured them, and created
231 /// device nodes. Accessing devices at the same time as `udev`,
232 /// might result in unpredictable behavior. The "`udev`" events
233 /// are sent out after `udev` has finished its event processing,
234 /// all rules have been processed, and needed device nodes are
235 /// created.
236 /// ```
237 ///
238 /// Returns: a new [UdevMonitor], or [Error], in case of an error
239 pub fn new_from_netlinkrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new_from_netlink().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#> + fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy#>(
240 udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>,
241 name: N,
242 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]> {
243 Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]::new_from_netlink_fdrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]new_from_netlink_fd().(udev, name, -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][Neg]neg().1)
244 }
245
246 fn set_nl_addressrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_nl_address().(&mut self) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
247 // SAFETY: `sockaddr_nl` is a well-aligned struct, so zeroing its memory results in a valid
248 // stack allocation.
249 let mut snl = unsafe { memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/zeroed().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>() };
250 let mut snl_len = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>() as u32;
251
252 // get the address the kernel has assigned us
253 // it is usually, but not necessarily the PID
254 //
255 // SAFETY: parameters are initialized properly, and pointers reference valid memory.
256 match unsafe {
257 libcrust-analyzer cargo libc 0.2.169 crate/::getsocknamerust-analyzer cargo libc 0.2.169 getsockname().(
258 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
259 &mut snl as *mut libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl# as *mut _,
260 &mut snl_len as *mut _,
261 )
262 } {
263 i if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]ge().0 => {
264 let pid = snl.nl_pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_pid.;
265 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("UDEV monitor SNL PID: {pid}");
266 self.set_snlrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl().(UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::Netlinkrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#Netlink#(snl));
267 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
268 }
269 _ => {
270 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
271 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
272 "unable to set SNL address: {errno}"
273 )))
274 }
275 }
276 }
277
278 /// Gets a reference to the [Udev] context.
279 pub const fn udevrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]udev().(&self) -> &Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#> {
280 &self.udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#udev.
281 }
282
283 /// Gets the socket file descriptor.
284 pub const fn sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]sock().(&self) -> i32 {
285 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.
286 }
287
288 /// Sets the socket file descriptor.
289 pub fn set_sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_sock().(&mut self, val: i32) {
290 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock. = val;
291 }
292
293 /// Builder function that sets the socket file descriptor.
294 pub fn with_sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_sock().(mut self, val: i32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
295 self.set_sockrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_sock().(val);
296 self
297 }
298
299 /// Gets a reference to the SNL [UdevSocket].
300 pub const fn snlrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]snl().(&self) -> &UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket# {
301 &self.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl.
302 }
303
304 /// Sets the SNL [UdevSocket].
305 ///
306 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
307 pub fn set_snlrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl().(&mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) {
308 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(val, UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::Netlinkrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#Netlink#(_)) {
309 self.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl. = val;
310 }
311 }
312
313 /// Builder function that sets the SNL [UdevSocket].
314 ///
315 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
316 pub fn with_snlrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_snl().(mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
317 self.set_snlrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl().(val);
318 self
319 }
320
321 /// Gets the SNL [UdevMonitorNetlinkGroup].
322 pub const fn snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]snl_group().(&self) -> UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup# {
323 self.snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_group.
324 }
325
326 /// Sets the SNL [UdevMonitorNetlinkGroup].
327 pub fn set_snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_group().<G: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#>>(&mut self, val: G) {
328 self.snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_group. = val.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
329 }
330
331 /// Builder function that sets the SNL [UdevMonitorNetlinkGroup].
332 pub fn with_snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_snl_group().<G: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#>>(mut self, val: G) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
333 self.set_snl_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_group().(val);
334 self
335 }
336
337 /// Gets a reference to the SNL trusted sender [UdevSocket].
338 pub const fn snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]snl_trusted_sender().(&self) -> &UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket# {
339 &self.snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_trusted_sender.
340 }
341
342 /// Sets the SNL trusted sender [UdevSocket].
343 ///
344 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
345 pub fn set_snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_trusted_sender().(&mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) {
346 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(val, UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::Netlinkrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#Netlink#(_)) {
347 self.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl. = val;
348 }
349 }
350
351 /// Builder function that sets the SNL trusted sender [UdevSocket].
352 ///
353 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
354 pub fn with_snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_snl_trusted_sender().(mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
355 self.set_snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_trusted_sender().(val);
356 self
357 }
358
359 /// Gets a reference to the SNL destination [UdevSocket].
360 pub const fn snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]snl_destination().(&self) -> &UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket# {
361 &self.snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination.
362 }
363
364 /// Sets the SNL destination [UdevSocket].
365 ///
366 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
367 pub fn set_snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_destination().(&mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) {
368 if matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(val, UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#::Netlinkrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#Netlink#(_)) {
369 self.snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination. = val;
370 }
371 }
372
373 /// Builder function that sets the SNL destination [UdevSocket].
374 ///
375 /// **NOTE**: the SNL socket is only set for [UdevSocket::Netlink] sockets.
376 pub fn with_snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_snl_destination().(mut self, val: UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket#) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
377 self.set_snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_destination().(val);
378 self
379 }
380
381 /// Gets the SNL destination [UdevMonitorNetlinkGroup].
382 pub const fn snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]snl_destination_group().(&self) -> UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup# {
383 self.snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination_group.
384 }
385
386 /// Sets the SNL destination [UdevMonitorNetlinkGroup].
387 pub fn set_snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_destination_group().<G: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#>>(&mut self, val: G) {
388 self.snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination_group. = val.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().();
389 }
390
391 /// Builder function that sets the SNL destination [UdevMonitorNetlinkGroup].
392 pub fn with_snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_snl_destination_group().<G: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#>>(mut self, val: G) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
393 self.set_snl_destination_grouprust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_snl_destination_group().(val);
394 self
395 }
396
397 /// Gets the socket address length.
398 pub const fn addrlenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]addrlen().(&self) -> usize {
399 self.addrlenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#addrlen.
400 }
401
402 /// Gets a reference to the filter subsystem [UdevList].
403 pub const fn filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_subsystem_list().(&self) -> &UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# {
404 &self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list.
405 }
406
407 /// Gets a mutable reference to the filter subsystem [UdevList].
408 pub fn filter_subsystem_list_mutrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_subsystem_list_mut().(&mut self) -> &mut UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# {
409 &mut self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list.
410 }
411
412 /// Sets the filter subsystem [UdevList].
413 pub fn set_filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_filter_subsystem_list().<L: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#>>(&mut self, list: L) {
414 self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list..set_listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]set_list().(list);
415 }
416
417 /// Builder function that sets the filter subsystem [UdevList].
418 pub fn with_filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_filter_subsystem_list().<L: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#>>(mut self, list: L) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
419 self.set_filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_filter_subsystem_list().(list);
420 self
421 }
422
423 /// Gets a reference to the filter tag [UdevList].
424 pub const fn filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_tag_list().(&self) -> &UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# {
425 &self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list.
426 }
427
428 /// Gets a mutable reference to the filter tag [UdevList].
429 pub fn filter_tag_list_mutrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_tag_list_mut().(&mut self) -> &mut UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# {
430 &mut self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list.
431 }
432
433 /// Sets the filter tag [UdevList].
434 pub fn set_filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_filter_tag_list().<L: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#>>(&mut self, list: L) {
435 self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list..set_listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]set_list().(list);
436 }
437
438 /// Builder function that sets the filter tag [UdevList].
439 pub fn with_filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_filter_tag_list().<L: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#>>(mut self, list: L) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
440 self.set_filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_filter_tag_list().(list);
441 self
442 }
443
444 /// Gets whether the [UdevMonitor] is bound to a socket.
445 pub const fn boundrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]bound().(&self) -> bool {
446 self.boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound.
447 }
448
449 fn set_boundrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_bound().(&mut self, val: bool) {
450 self.boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound. = val;
451 }
452
453 fn with_boundrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]with_bound().(mut self, val: bool) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor] {
454 self.set_boundrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_bound().(val);
455 self
456 }
457
458 /// Gets whether the [UdevDevice] passes the [UdevMonitor] filters.
459 pub fn passes_filterrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]passes_filter().(&self, device: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> bool {
460 if self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list..is_emptyrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]is_empty().() {
461 self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_tag_list().().has_tagrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]has_tag().(device)
462 } else {
463 for list_entry in self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list..iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().() {
464 if list_entry.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().device.get_subsystemrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_subsystem().() {
465 let (devtype, ddevtype) = (list_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().(), device.devtyperust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]devtype().());
466
467 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().ddevtype.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() && (devtype.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() || devtype 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().ddevtype) {
468 return self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_tag_list().().has_tagrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]has_tag().(device);
469 }
470 }
471 }
472 false
473 }
474 }
475
476 /// Updates the monitor socket filter.
477 ///
478 /// From the `libudev` documentation:
479 ///
480 /// ```no_build,no_run
481 /// Update the installed socket filter. This is only needed,
482 /// if the filter was removed or changed.
483 /// ```
484 ///
485 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
486 pub fn filter_updaterust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_update().(&mut self) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
487 if self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_subsystem_list().().entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()
488 && self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_tag_list().().entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry().().is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()
489 {
490 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
491 } else {
492 let mut ins: BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#<BPF_FILTER_LENrust-analyzer cargo udevrs 0.4.0 monitor/BPF_FILTER_LEN.> = BpfFiltersrust-analyzer cargo udevrs 0.4.0 monitor/BpfFilters#::newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]new().();
493 let mut i = 0usize;
494
495 // load magic in A
496 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
497 &mut i,
498 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_LDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_LD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Wrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_W. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ABSrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ABS.) as u16,
499 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::magic_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]magic_offset().() as u32,
500 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
501 // jump if magic matches
502 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
503 &mut i,
504 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
505 UDEV_MONITOR_MAGICrust-analyzer cargo udevrs 0.4.0 monitor/UDEV_MONITOR_MAGIC.,
506 1,
507 0,
508 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
509 // wrong magic, pass packet
510 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut i, (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_RETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_RET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16, 0xffff_ffff)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
511
512 if self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list..entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
513 let mut tag_matches = self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list..lenrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]len().();
514
515 for list_entry in self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list..iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().() {
516 let tag_bloom_bits = utilrust-analyzer cargo udevrs 0.4.0 util/::string_bloom64rust-analyzer cargo udevrs 0.4.0 util/string_bloom64().(list_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().());
517 let tag_bloom_hi = (tag_bloom_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().32) as u32;
518 let tag_bloom_lo = tag_bloom_bits as u32;
519
520 // load device bloom bits in A
521 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
522 &mut i,
523 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_LDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_LD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Wrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_W. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ABSrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ABS.) as u16,
524 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::filter_tag_bloom_hi_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_hi_offset().() as u32,
525 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
526 // clear bits (tag bits & bloom bits)
527 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
528 &mut i,
529 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ALUrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ALU. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ANDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_AND. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
530 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::filter_tag_bloom_hi_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_hi_offset().() as u32,
531 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
532 // jump to next tag if it does not match
533 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
534 &mut i,
535 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
536 tag_bloom_hi,
537 0,
538 3,
539 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
540
541 // load device bloom bits in A
542 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
543 &mut i,
544 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_LDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_LD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Wrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_W. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ABSrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ABS.) as u16,
545 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::filter_tag_bloom_lo_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_lo_offset().() as u32,
546 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
547 // clear bits (tag bits & bloom bits)
548 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
549 &mut i,
550 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ALUrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ALU. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ANDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_AND. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
551 tag_bloom_lo,
552 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
553 // jump behind end of tag match block if tag matches
554 tag_matches = tag_matches.saturating_subrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_sub().(1);
555 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
556 &mut i,
557 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
558 tag_bloom_lo,
559 1usize.saturating_addrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_add().(tag_matches.saturating_mulrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[usize]saturating_mul().(6)) as u8,
560 0,
561 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
562 }
563
564 // nothing matched, drop packet
565 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut i, (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_RETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_RET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16, 0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
566 }
567
568 // add all subsystem matches
569 if self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_subsystem_list().().entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry().().is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
570 for list_entry in self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_subsystem_list().().iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().() {
571 let mut hash = utilrust-analyzer cargo udevrs 0.4.0 util/::string_hash32rust-analyzer cargo udevrs 0.4.0 util/string_hash32().(list_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().());
572
573 // load device subsystem value in A
574 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
575 &mut i,
576 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_LDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_LD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Wrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_W. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ABSrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ABS.) as u16,
577 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::filter_subsystem_hash_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_subsystem_hash_offset().() as u32,
578 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
579
580 if list_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
581 // jump if subsystem does not match
582 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
583 &mut i,
584 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
585 hash,
586 0,
587 1,
588 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
589 } else {
590 // jump if subsystem does not match
591 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
592 &mut i,
593 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
594 hash,
595 0,
596 3,
597 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
598
599 // load device devtype value in A
600 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(
601 &mut i,
602 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_LDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_LD. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Wrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_W. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_ABSrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_ABS.) as u16,
603 UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::filter_devtype_hash_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_devtype_hash_offset().() as u32,
604 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
605
606 // jump if value does not match
607 hash = utilrust-analyzer cargo udevrs 0.4.0 util/::string_hash32rust-analyzer cargo udevrs 0.4.0 util/string_hash32().(list_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().());
608 ins.bpf_jmprust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_jmp().(
609 &mut i,
610 (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JMPrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JMP. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_JEQrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_JEQ. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16,
611 hash,
612 0,
613 1,
614 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
615 }
616
617 // matched pass packet
618 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut i, (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_RETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_RET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16, 0xffff_ffff)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
619 }
620
621 // nothing matched, drop packet
622 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut i, (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_RETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_RET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16, 0)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
623 }
624
625 // matched, pass packet
626 ins.bpf_stmtrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]bpf_stmt().(&mut i, (libcrust-analyzer cargo libc 0.2.169 crate/::BPF_RETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_RET. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().|rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor().libcrust-analyzer cargo libc 0.2.169 crate/::BPF_Krust-analyzer cargo libc 0.2.169 unix/linux_like/linux/BPF_K.) as u16, 0xffff_ffff)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
627
628 // install filter
629 self.filterrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter. = ins;
630 let mut filter = self.filterrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter..as_sock_fprogrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`BpfFilters<N>`]as_sock_fprog().();
631
632 // SAFETY: arguments are valid, and pointer reference valid memory.
633 let err = unsafe {
634 libcrust-analyzer cargo libc 0.2.169 crate/::setsockoptrust-analyzer cargo libc 0.2.169 setsockopt().(
635 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
636 libcrust-analyzer cargo libc 0.2.169 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SOL_SOCKET.,
637 libcrust-analyzer cargo libc 0.2.169 crate/::SO_ATTACH_FILTERrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SO_ATTACH_FILTER.,
638 &mut filter as *mut libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog# as *mut _,
639 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#>() as u32,
640 )
641 };
642
643 if err rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
644 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
645 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
646 "error setting BPF filter, error: {err}, errno: {errno}"
647 )))
648 } else {
649 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
650 }
651 }
652 }
653
654 /// Binds the [UdevMonitor] socket to the event source.
655 pub fn enable_receivingrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]enable_receiving().(&mut self) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
656 self.filter_updaterust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_update().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
657
658 let mut err = if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound. {
659 // SAFETY: all arguments are valid, and pointers reference valid memory.
660 unsafe {
661 libcrust-analyzer cargo libc 0.2.169 crate/::bindrust-analyzer cargo libc 0.2.169 bind().(
662 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
663 self.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl..as_nl_ptrrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]as_nl_ptr().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch(). as *const _,
664 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>() as u32,
665 )
666 }
667 } else {
668 0
669 };
670
671 if err rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
672 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
673 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("bind failed, error: {err}, errno: {errno}");
674 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
675 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
676 } else {
677 self.boundrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#bound. = true;
678 self.set_nl_addressrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_nl_address().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
679
680 let on = 1i32;
681
682 // SAFETY: all arguments are valid, and pointers reference valid memory.
683 err = unsafe {
684 libcrust-analyzer cargo libc 0.2.169 crate/::setsockoptrust-analyzer cargo libc 0.2.169 setsockopt().(
685 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
686 libcrust-analyzer cargo libc 0.2.169 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SOL_SOCKET.,
687 libcrust-analyzer cargo libc 0.2.169 crate/::SO_PASSCREDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SO_PASSCRED.,
688 &on as *const i32 as *const _,
689 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i32>() as u32,
690 )
691 };
692
693 if err rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
694 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
695 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("setting SO_PASSCRED failed, error: {err}, errno: {errno}");
696 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
697 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
698 } else {
699 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
700 }
701 }
702 }
703
704 /// Sets the size of the kernel socket buffer.
705 ///
706 /// From the `libudev` documentation:
707 ///
708 /// ```no_build,no_run
709 /// Set the size of the kernel socket buffer. This call needs the
710 /// appropriate privileges to succeed.
711 /// ```
712 ///
713 /// Returns: `Ok(())` on success, `Err(Error)` otherwise.
714 pub fn set_receive_buffer_sizerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]set_receive_buffer_size().(&mut self, size: usize) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
715 let int_size = size as i32;
716 // SAFETY: all arguments are valid, and pointers reference valid memory.
717 let err = unsafe {
718 libcrust-analyzer cargo libc 0.2.169 crate/::setsockoptrust-analyzer cargo libc 0.2.169 setsockopt().(
719 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
720 libcrust-analyzer cargo libc 0.2.169 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SOL_SOCKET.,
721 libcrust-analyzer cargo libc 0.2.169 crate/::SO_RCVBUFFORCErust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SO_RCVBUFFORCE.,
722 &int_size as *const i32 as *const _,
723 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<i32>() as u32,
724 )
725 };
726 if err rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 {
727 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
728 let err_msg =
729 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Error setting receive buffer size, error: {err}, errno: {errno}");
730 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
731 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
732 } else {
733 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
734 }
735 }
736
737 /// Receives data from the [UdevMonitor] socket.
738 ///
739 /// From the `libudev` documentation:
740 ///
741 /// ```no_build,no_run
742 /// Receive data from the udev monitor socket, allocate a new udev
743 /// device, fill in the received data, and return the device.
744 ///
745 /// Only socket connections with uid=0 are accepted.
746 ///
747 /// The monitor socket is by default set to NONBLOCK. A variant of poll() on
748 /// the file descriptor returned by udev_monitor_get_fd() should to be used to
749 /// wake up when new devices arrive, or alternatively the file descriptor
750 /// switched into blocking mode.
751 /// ```
752 ///
753 /// Returns: `Ok(UdevDevice)` on success, `Err(Error)` otherwise.
754 // FIXME: break this into smaller functions
755 pub fn receive_devicerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]receive_device().(&mut self) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#> {
756 // avoid infinite loop, only retry up to a given limit of queued devices
757 // TODO: should this limit be higher? lower?
758 // the original implementation retries indefinitely, as long as there are queued devices
759 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1024 {
760 let mut buf = [0u8; 8192];
761 let mut iov = libcrust-analyzer cargo libc 0.2.169 crate/::iovecrust-analyzer cargo libc 0.2.169 unix/iovec# {
762 iov_baserust-analyzer cargo libc 0.2.169 unix/iovec#iov_base.: buf.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut _,
763 iov_lenrust-analyzer cargo libc 0.2.169 unix/iovec#iov_len.: 8192,
764 };
765
766 let mut cred_msg = [0u8; memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#>()];
767
768 // SAFETY: `libc::sockaddr_nl` has a known-size, and is well-aligned.
769 // `snl` will also be initialized below by the syscall before being used.
770 let mut snl: libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl# = unsafe { memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/zeroed().() };
771 snl.nl_familyrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_family. = libcrust-analyzer cargo libc 0.2.169 crate/::AF_NETLINKrust-analyzer cargo libc 0.2.169 unix/linux_like/AF_NETLINK. as u16;
772
773 // SAFETY: `libc::msghdr` has a known-size, and is well-aligned.
774 // `smsg` is properly initialized below before further use.
775 let mut smsg: libcrust-analyzer cargo libc 0.2.169 crate/::msghdrrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr# = unsafe { memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::zeroedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/zeroed().() };
776
777 smsg.msg_iovrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_iov. = &mut iov as *mut libcrust-analyzer cargo libc 0.2.169 crate/::iovecrust-analyzer cargo libc 0.2.169 unix/iovec# as *mut _;
778 smsg.msg_iovlenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_iovlen. = 1;
779 smsg.msg_controlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_control. = cred_msg.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut _;
780 smsg.msg_controllenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_controllen. = cred_msg.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
781 smsg.msg_namerust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_name. = &mut snl as *mut libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl# as *mut _;
782 smsg.msg_namelenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_namelen. = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>() as u32;
783
784 // SAFETY: all parameters are properly initialized, and point to valid memory.
785 let buflen = unsafe { libcrust-analyzer cargo libc 0.2.169 crate/::recvmsgrust-analyzer cargo libc 0.2.169 recvmsg().(self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock., &mut smsg as *mut _, 0) };
786
787 let trusted_pid = self.snl_trusted_senderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_trusted_sender..pidrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]pid().().unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(0);
788
789 if buflen rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().0 {
790 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
791 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("unable to receive message: {errno}");
792
793 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
794
795 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
796 } else if buflen rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().32 || smsg.msg_flagsrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_flags. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().&rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[i32][`BitAnd<Self>`]bitand().libcrust-analyzer cargo libc 0.2.169 crate/::MSG_TRUNCrust-analyzer cargo libc 0.2.169 unix/linux_like/MSG_TRUNC. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 {
797 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid message length: {buflen}");
798
799 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
800
801 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
802 } else if snl.nl_groupsrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_groups. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 && (trusted_pid rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().0 || snl.nl_pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_pid. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().trusted_pid) {
803 // unicast message, check if we trust the sender
804 let err_msg = "unicast netlink message ignored".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
805
806 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
807
808 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
809 } else if snl.nl_groupsrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_groups. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel# as u32 && snl.nl_pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_pid. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]gt().0 {
810 let pid = snl.nl_pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#nl_pid.;
811 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("multicast kernel netlink message from PID {pid} ignored");
812
813 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
814
815 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
816 } else {
817 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
818 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
819
820 let libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred# {
821 pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#pid.: _,
822 uidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#uid.,
823 gidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#gid.: _,
824 } = parse_cmsgrust-analyzer cargo udevrs 0.4.0 monitor/parse_cmsg().(cred_msg.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().())?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
825
826 if uid rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().0 {
827 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("sender uid={uid}, message ignored");
828
829 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
830
831 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
832 } else {
833 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
834 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
835
836 let (bufpos, is_initialized) = match UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::try_fromrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`]try_from().(buf.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()) {
837 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(nlh) => {
838 let prop_off = nlh.properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off. as usize;
839 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("NetlinkHeader properties offset: {prop_off:#x}");
840 (cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/min().(buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(), prop_off), true)
841 }
842 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(_) => {
843 // kernel message header
844 let bufpos = buf
845 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
846 .positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]position().(|&b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u8][`PartialEq<Self>`]eq().b'\0')
847 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|b| b rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().1)
848 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(0);
849
850 if bufpos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().b"a@/d".lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() || bufpos rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().buflen as usize {
851 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("invalid message length :: buffer length: {buflen}, header length: {bufpos}, expected header: 4");
852
853 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
854
855 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
856 } else if buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#2]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().b"@/".as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().() {
857 let err_msg = "unrecognized message header".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
858
859 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
860
861 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
862 } else {
863 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#((bufpos, false))
864 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
865 }
866 };
867
868 let mut udev_device =
869 UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#::new_from_nulstrrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]new_from_nulstr().(Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`][Clone]clone().(&self.udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#udev.), buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().bufpos..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().())
870 .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|e| {
871 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("could not create device: {e}");
872 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
873 Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg)
874 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
875
876 if is_initialized {
877 udev_device.set_is_initializedrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]set_is_initialized().(true);
878 }
879
880 // skip device, if it does not pass the current filter
881 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.passes_filterrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]passes_filter().(&mut udev_device) {
882 // if somthing is queued, get next device
883 let mut pfd = [libcrust-analyzer cargo libc 0.2.169 crate/::pollfdrust-analyzer cargo libc 0.2.169 unix/pollfd# {
884 fdrust-analyzer cargo libc 0.2.169 unix/pollfd#fd.: self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
885 eventsrust-analyzer cargo libc 0.2.169 unix/pollfd#events.: libcrust-analyzer cargo libc 0.2.169 crate/::POLLINrust-analyzer cargo libc 0.2.169 unix/linux_like/POLLIN.,
886 reventsrust-analyzer cargo libc 0.2.169 unix/pollfd#revents.: 0,
887 }];
888 let pfd_len = pfd.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() as libcrust-analyzer cargo libc 0.2.169 crate/::nfds_trust-analyzer cargo libc 0.2.169 unix/linux_like/linux/nfds_t#;
889
890 // SAFETY: call to `poll` is safe because `pollfd` is properly initialized, and the
891 // resulting mutable pointer references valid memory.
892 if unsafe { libcrust-analyzer cargo libc 0.2.169 crate/::pollrust-analyzer cargo libc 0.2.169 poll().(pfd.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().(), pfd_len, 0) } rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]gt().0 {
893 // retry with the next device
894 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
895 } else {
896 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(
897 "device did not pass filter, no queued devices".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
898 ))
899 }?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
900 } else {
901 return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(udev_device);
902 }
903 }
904
905 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#("receive device retries exceeded".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
906 }
907
908 /// Sends an [UdevDevice] from one [UdevMonitor] to another.
909 // FIXME: break this into smaller functions
910 pub fn send_devicerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]send_device().(
911 &mut self,
912 mut destination: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]>,
913 device: &mut UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#,
914 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<isize> {
915 let mut nlh = UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#::newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]new().();
916
917 let mut iov = [
918 libcrust-analyzer cargo libc 0.2.169 crate/::iovecrust-analyzer cargo libc 0.2.169 unix/iovec# {
919 iov_baserust-analyzer cargo libc 0.2.169 unix/iovec#iov_base.: &mut nlh as *mut UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader# as *mut _,
920 iov_lenrust-analyzer cargo libc 0.2.169 unix/iovec#iov_len.: memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#>(),
921 },
922 libcrust-analyzer cargo libc 0.2.169 crate/::iovecrust-analyzer cargo libc 0.2.169 unix/iovec# {
923 iov_baserust-analyzer cargo libc 0.2.169 unix/iovec#iov_base.: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::null_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/null_mut().(),
924 iov_lenrust-analyzer cargo libc 0.2.169 unix/iovec#iov_len.: 0,
925 },
926 ];
927
928 let mut smsg = libcrust-analyzer cargo libc 0.2.169 crate/::msghdrrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr# {
929 msg_iovrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_iov.: iov.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]as_mut_ptr().() as *mut _,
930 msg_iovlenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_iovlen.: iov.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().(),
931 msg_controlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_control.: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::null_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/null_mut().(),
932 msg_controllenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_controllen.: 0,
933 msg_flagsrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_flags.: 0,
934 msg_namerust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_name.: corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::null_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/null_mut().(),
935 msg_namelenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_namelen.: 0,
936 };
937
938 if device.get_properties_monitor_bufrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_properties_monitor_buf().().lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().32 {
939 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(
940 "device buffer is too small to contain a valid device".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
941 ))
942 } else {
943 let mut buf = device.get_properties_monitor_bufrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_properties_monitor_buf().().to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
944 let blen = buf.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]len().();
945
946 // fill in versioned header
947 nlh.set_filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_subsystem_hash().(utilrust-analyzer cargo udevrs 0.4.0 util/::string_hash32rust-analyzer cargo udevrs 0.4.0 util/string_hash32().(device.get_subsystemrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]get_subsystem().()));
948
949 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().device.devtyperust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]devtype().().is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
950 nlh.set_filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_devtype_hash().(utilrust-analyzer cargo udevrs 0.4.0 util/::string_hash32rust-analyzer cargo udevrs 0.4.0 util/string_hash32().(device.devtyperust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]devtype().()));
951 }
952
953 // add tag bloom filter
954 let mut tag_bloom_bits = 0u64;
955 device
956 .tags_listrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]tags_list().()
957 .iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().()
958 .for_eachrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#for_each().(|list_entry| tag_bloom_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().|=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`BitOrAssign<Self>`]bitor_assign().utilrust-analyzer cargo udevrs 0.4.0 util/::string_bloom64rust-analyzer cargo udevrs 0.4.0 util/string_bloom64().(list_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().()));
959
960 if tag_bloom_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialOrd<Self>`]gt().0 {
961 nlh.set_filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_hi().((tag_bloom_bits rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().>>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u64][`Shr<i32>`]shr().32) as u32);
962 nlh.set_filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_lo().(tag_bloom_bits as u32);
963 }
964
965 // add properties list
966 nlh.properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off. = iov[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`Index<I>`]index()..iov_lenrust-analyzer cargo libc 0.2.169 unix/iovec#iov_len. as u32;
967 nlh.properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len. = blen as u32;
968
969 iov[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..iov_baserust-analyzer cargo libc 0.2.169 unix/iovec#iov_base. = buf.as_mut_ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]as_mut_ptr().() as *mut _;
970 iov[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut().1]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`IndexMut<I>`]index_mut()..iov_lenrust-analyzer cargo libc 0.2.169 unix/iovec#iov_len. = blen;
971
972 // Use custom address for target, or the default one.
973 //
974 // If we send to a multicast group, we will get
975 // ECONNREFUSED, which is expected.
976 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dest) = destination.as_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_mut().() {
977 smsg.msg_namerust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_name. = &mut dest.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl. as *mut UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket# as *mut _;
978 } else {
979 smsg.msg_namerust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_name. = &mut self.snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination. as *mut UdevSocketrust-analyzer cargo udevrs 0.4.0 socket/UdevSocket# as *mut _;
980 }
981
982 smsg.msg_namelenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/msghdr#msg_namelen. = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sockaddr_nlrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sockaddr_nl#>() as u32;
983 // SAFETY: call to `sendmsg` is safe because the parameters are properly initialized
984 // and the pointers reference valid memory.
985 let count = unsafe { libcrust-analyzer cargo libc 0.2.169 crate/::sendmsgrust-analyzer cargo libc 0.2.169 sendmsg().(self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock., &mut smsg as *mut _, 0) };
986
987 let mon_pid = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(dest) = destination.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() {
988 dest.snlrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl..pidrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]pid().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
989 } else {
990 self.snl_destinationrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#snl_destination..pidrust-analyzer cargo udevrs 0.4.0 socket/impl#[UdevSocket]pid().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().
991 };
992
993 if count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().0
994 && destination.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().()
995 && iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().().raw_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]raw_os_error().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#eq().Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(libcrust-analyzer cargo libc 0.2.169 crate/::ECONNREFUSEDrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/b64/x86_64/ECONNREFUSED.)
996 {
997 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("passed device to netlink monitor: PID({mon_pid})");
998 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(0)
999 } else if count rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[isize][`PartialOrd<Self>`]lt().0 {
1000 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
1001 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("sending device error: {errno}")))
1002 } else {
1003 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!(
1004 "monitor: passed {count} byte device to netlink monitor: PID({mon_pid})"
1005 );
1006 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(count)
1007 }
1008 }
1009 }
1010
1011 /// Adds an [UdevEntry] into the filter subsystem list.
1012 ///
1013 /// From `libudev` documentation:
1014 ///
1015 /// Parameters:
1016 ///
1017 /// - `subsystem`: the subsystem value to match the incoming devices against
1018 /// - must be non-empty
1019 /// - `devtype`: the devtype value to match the incoming devices against
1020 ///
1021 /// ```no_build,no_run
1022 /// This filter is efficiently executed inside the kernel, and libudev subscribers
1023 /// will usually not be woken up for devices which do not match.
1024 ///
1025 /// The filter must be installed before the monitor is switched to listening mode.
1026 /// ```
1027 ///
1028 /// Returns `Ok` on success, `Err` otherwise.
1029 pub fn filter_add_match_subsystem_devtyperust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_add_match_subsystem_devtype().(
1030 &mut self,
1031 subsystem: &str,
1032 devtype: &str,
1033 ) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
1034 if subsystem.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
1035 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#("empty subsystem filter".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
1036 } else {
1037 self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list.
1038 .add_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]add_entry().(subsystem, devtype)
1039 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(
1040 "unable to add entry to filter subsystem list".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
1041 ))
1042 }
1043 }
1044
1045 /// Adds an [UdevEntry] into the filter tag list.
1046 ///
1047 /// From `libudev` documentation:
1048 ///
1049 /// - `tag`: the name of a tag
1050 /// - must be non-empty
1051 ///
1052 /// ```no_build,no_run
1053 /// This filter is efficiently executed inside the kernel, and libudev subscribers
1054 /// will usually not be woken up for devices which do not match.
1055 ///
1056 /// The filter must be installed before the monitor is switched to listening mode.
1057 /// ```
1058 ///
1059 /// Returns `Ok` on success, `Err` otherwise.
1060 pub fn filter_add_match_tagrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_add_match_tag().(&mut self, tag: &str) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> {
1061 if tag.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]is_empty().() {
1062 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#("empty tag filter".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()))
1063 } else {
1064 self.filter_tag_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_tag_list.
1065 .add_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]add_entry().(tag, "")
1066 .ok_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or().(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(
1067 "unable to add entry to filter tag list".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
1068 ))
1069 }
1070 }
1071
1072 /// Removes all filters from the [UdevMonitor].
1073 ///
1074 /// Returns `Ok(())` on success, `Err(Error)` otherwise.
1075 pub fn filter_removerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitor]filter_remove().(&mut self) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<()> {
1076 let mut filter = libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog# {
1077 lenrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#len.: 0,
1078 filterrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#filter.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ptrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/::null_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/null_mut().(),
1079 };
1080
1081 self.filter_subsystem_listrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#filter_subsystem_list..clearrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]clear().();
1082
1083 // SAFETY: all arguments are valid, and pointers reference valid memory.
1084 let ret = unsafe {
1085 libcrust-analyzer cargo libc 0.2.169 crate/::setsockoptrust-analyzer cargo libc 0.2.169 setsockopt().(
1086 self.sockrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitor#sock.,
1087 libcrust-analyzer cargo libc 0.2.169 crate/::SOL_SOCKETrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SOL_SOCKET.,
1088 libcrust-analyzer cargo libc 0.2.169 crate/::SO_ATTACH_FILTERrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/arch/generic/SO_ATTACH_FILTER.,
1089 &mut filter as *mut libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog# as *mut _,
1090 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::sock_fprogrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/sock_fprog#>() as u32,
1091 )
1092 };
1093
1094 if ret rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().0 {
1095 let errno = iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#::last_os_errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/impl#[Error]last_os_error().();
1096 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1097 "unable to remove kernel `SO_ATTACH_FILTER`: {ret}, errno: {errno}"
1098 )))
1099 } else {
1100 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
1101 }
1102 }
1103 }
1104
1105 fn parse_cmsgrust-analyzer cargo udevrs 0.4.0 monitor/parse_cmsg().(msg_control: &[u8]) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#> {
1106 let controllen = msg_control.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
1107 let header_len = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::cmsghdrrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/gnu/cmsghdr#>();
1108 let ucred_len = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#>();
1109 let msg_control_len = header_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().ucred_len;
1110
1111 let int_len = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<libcrust-analyzer cargo libc 0.2.169 crate/::c_intrust-analyzer cargo libc 0.2.169 unix/c_int#>();
1112 let null_int = [0u8; 4];
1113
1114 match controllen {
1115 l if l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().msg_control_len => {
1116 // skip to the `cmsg_type` index of the `cmsghdr`
1117 let mut idx = int_len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().3;
1118
1119 let cmsg_type = libcrust-analyzer cargo libc 0.2.169 crate/::c_intrust-analyzer cargo libc 0.2.169 unix/c_int#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]from_ne_bytes().(
1120 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1121 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1122 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1123 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1124 );
1125
1126 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().int_len;
1127
1128 if cmsg_type rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]ne().libcrust-analyzer cargo libc 0.2.169 crate/::SCM_CREDENTIALSrust-analyzer cargo libc 0.2.169 unix/linux_like/SCM_CREDENTIALS. {
1129 let err_msg = "no sender credentials received, message ignored".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
1130
1131 logrust-analyzer cargo log 0.4.25 crate/::debugrust-analyzer cargo log 0.4.25 macros/debug!!("{err_msg}");
1132
1133 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
1134 } else {
1135 let pid = libcrust-analyzer cargo libc 0.2.169 crate/::pid_trust-analyzer cargo libc 0.2.169 unix/pid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]from_ne_bytes().(
1136 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1137 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1138 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1139 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1140 );
1141 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().int_len;
1142
1143 let uid = libcrust-analyzer cargo libc 0.2.169 crate/::uid_trust-analyzer cargo libc 0.2.169 unix/uid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_ne_bytes().(
1144 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1145 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1146 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1147 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1148 );
1149 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().int_len;
1150
1151 let gid = libcrust-analyzer cargo libc 0.2.169 crate/::gid_trust-analyzer cargo libc 0.2.169 unix/gid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_ne_bytes().(
1152 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1153 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1154 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1155 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1156 );
1157
1158 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred# { pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#pid., uidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#uid., gidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#gid. })
1159 }
1160 }
1161 l if l rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]ge().ucred_len => {
1162 let mut idx = 0;
1163
1164 let pid = libcrust-analyzer cargo libc 0.2.169 crate/::pid_trust-analyzer cargo libc 0.2.169 unix/pid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[i32]from_ne_bytes().(
1165 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1166 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1167 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1168 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1169 );
1170 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().int_len;
1171
1172 let uid = libcrust-analyzer cargo libc 0.2.169 crate/::uid_trust-analyzer cargo libc 0.2.169 unix/uid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_ne_bytes().(
1173 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1174 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1175 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1176 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1177 );
1178 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().int_len;
1179
1180 let gid = libcrust-analyzer cargo libc 0.2.169 crate/::gid_trust-analyzer cargo libc 0.2.169 unix/gid_t#::from_ne_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_ne_bytes().(
1181 msg_control[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().int_len]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().
1182 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[`[T]`][`AsRef<Self>`]as_ref().()
1183 .try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()
1184 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().(null_int),
1185 );
1186
1187 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(libcrust-analyzer cargo libc 0.2.169 crate/::ucredrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred# { pidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#pid., uidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#uid., gidrust-analyzer cargo libc 0.2.169 unix/linux_like/linux/ucred#gid. })
1188 }
1189 _ => Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1190 "msg_controllen ({controllen}) is too small for a cmsghdr"
1191 ))),
1192 }
1193 }
1194
1195 /// Represents the netlink group for the [UdevMonitor].
1196 #[repr(u32)]
1197 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
1198 pub enum UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup# {
1199 #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:]
1200 Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#,
1201 Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel#,
1202 Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev#,
1203 }
1204
1205 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&str> for UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup# {
1206 fn fromrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<&str>`]from().(val: &str) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<&str>`] {
1207 match val.to_lowercaserust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]to_lowercase().().as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() {
1208 "kernel" => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<&str>`]::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel#,
1209 "udev" => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<&str>`]::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev#,
1210 _ => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<&str>`]::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#,
1211 }
1212 }
1213 }
1214
1215 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<u32> for UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup# {
1216 fn fromrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<u32>`]from().(val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<u32>`] {
1217 match val {
1218 1 => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<u32>`]::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel#,
1219 2 => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<u32>`]::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev#,
1220 _ => Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkGroup][`From<u32>`]::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None#,
1221 }
1222 }
1223 }
1224
1225 impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<&UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#> for &'static str {
1226 fn fromrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`&'static str`][`From<&UdevMonitorNetlinkGroup>`]from().(val: &UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[`&'static str`][`From<&UdevMonitorNetlinkGroup>`] {
1227 match val {
1228 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Nonerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#None# => "none",
1229 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Kernelrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Kernel# => "kernel",
1230 UdevMonitorNetlinkGrouprust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#::Udevrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkGroup#Udev# => "udev",
1231 }
1232 }
1233 }
1234
1235 /// Represents a UDEV Netlink header.
1236 #[repr(C)]
1237 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:)]
1238 pub struct UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader# {
1239 prefixrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#prefix.: [u8; 8],
1240 magicrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#magic.: u32,
1241 header_sizerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#header_size.: u32,
1242 properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off.: u32,
1243 properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len.: u32,
1244 filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_subsystem_hash.: u32,
1245 filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_devtype_hash.: u32,
1246 filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_hi.: u32,
1247 filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_lo.: u32,
1248 }
1249
1250 impl UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader# {
1251 /// Creates a new [UdevMonitorNetlinkHeader].
1252 pub const fn newrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]new().() -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1253 Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1254 prefixrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#prefix.: [b'l', b'i', b'b', b'u', b'd', b'e', b'v', 0],
1255 magicrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#magic.: UDEV_MONITOR_MAGICrust-analyzer cargo udevrs 0.4.0 monitor/UDEV_MONITOR_MAGIC..to_berust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]to_be().(),
1256 header_sizerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#header_size.: memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]>() as u32,
1257 properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off.: 0,
1258 properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len.: 0,
1259 filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_subsystem_hash.: 0,
1260 filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_devtype_hash.: 0,
1261 filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_hi.: 0,
1262 filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_lo.: 0,
1263 }
1264 }
1265
1266 /// Gets a string representation of the [UdevMonitorNetlinkHeader] prefix.
1267 pub fn prefixrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]prefix().(&self) -> &str {
1268 stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::from_utf8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/converts/from_utf8().(self.prefixrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#prefix..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().()).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap_or().("")
1269 }
1270
1271 /// Gets the magic bytes.
1272 pub const fn magicrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]magic().(&self) -> u32 {
1273 self.magicrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#magic.
1274 }
1275
1276 /// Gets the total size of the [UdevMonitorNetlinkHeader].
1277 pub const fn header_sizerust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]header_size().(&self) -> u32 {
1278 self.header_sizerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#header_size.
1279 }
1280
1281 /// Gets the properties buffer offset.
1282 pub const fn properties_offrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]properties_off().(&self) -> u32 {
1283 self.properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off.
1284 }
1285
1286 /// Sets the properties buffer offset.
1287 pub fn set_properties_offrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_properties_off().(&mut self, val: u32) {
1288 self.properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off. = val;
1289 }
1290
1291 /// Builder function that sets the properties buffer offset.
1292 pub fn with_properties_offrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_properties_off().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1293 self.set_properties_offrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_properties_off().(val);
1294 self
1295 }
1296
1297 /// Gets the properties buffer length.
1298 pub const fn properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]properties_len().(&self) -> u32 {
1299 self.properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len.
1300 }
1301
1302 /// Sets the properties buffer legnth.
1303 pub fn set_properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_properties_len().(&mut self, val: u32) {
1304 self.properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len. = val;
1305 }
1306
1307 /// Builder function that sets the properties buffer length.
1308 pub fn with_properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_properties_len().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1309 self.set_properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_properties_len().(val);
1310 self
1311 }
1312
1313 /// Gets the filter subsystem hash.
1314 pub const fn filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_subsystem_hash().(&self) -> u32 {
1315 self.filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_subsystem_hash.
1316 }
1317
1318 /// Sets the filter subsystem hash.
1319 pub fn set_filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_subsystem_hash().(&mut self, val: u32) {
1320 self.filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_subsystem_hash. = val;
1321 }
1322
1323 /// Builder function that sets the filter subsystem hash.
1324 pub fn with_filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_filter_subsystem_hash().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1325 self.set_filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_subsystem_hash().(val);
1326 self
1327 }
1328
1329 /// Gets the filter devtype hash.
1330 pub const fn filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_devtype_hash().(&self) -> u32 {
1331 self.filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_devtype_hash.
1332 }
1333
1334 /// Sets the filter devtype hash.
1335 pub fn set_filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_devtype_hash().(&mut self, val: u32) {
1336 self.filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_devtype_hash. = val;
1337 }
1338
1339 /// Builder function that sets the filter devtype hash.
1340 pub fn with_filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_filter_devtype_hash().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1341 self.set_filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_devtype_hash().(val);
1342 self
1343 }
1344
1345 /// Gets the filter tag bloom hash high bits.
1346 pub const fn filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_hi().(&self) -> u32 {
1347 self.filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_hi.
1348 }
1349
1350 /// Sets the filter tag bloom hash high bits.
1351 pub fn set_filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_hi().(&mut self, val: u32) {
1352 self.filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_hi. = val;
1353 }
1354
1355 /// Builder function that sets the filter tag bloom hash high bits.
1356 pub fn with_filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_filter_tag_bloom_hi().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1357 self.set_filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_hi().(val);
1358 self
1359 }
1360
1361 /// Gets the filter tag bloom hash low bits.
1362 pub const fn filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_lo().(&self) -> u32 {
1363 self.filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_lo.
1364 }
1365
1366 /// Sets the filter tag bloom hash low bits.
1367 pub fn set_filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_lo().(&mut self, val: u32) {
1368 self.filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_lo. = val;
1369 }
1370
1371 /// Builder function that sets the filter tag bloom hash low bits.
1372 pub fn with_filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]with_filter_tag_bloom_lo().(mut self, val: u32) -> Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader] {
1373 self.set_filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]set_filter_tag_bloom_lo().(val);
1374 self
1375 }
1376
1377 /// `prefix` field offset.
1378 pub const fn prefix_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]prefix_offset().() -> usize {
1379 0
1380 }
1381
1382 /// `magic` field offset.
1383 pub const fn magic_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]magic_offset().() -> usize {
1384 8
1385 }
1386
1387 /// `header_size` field offset.
1388 pub const fn header_size_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]header_size_offset().() -> usize {
1389 12
1390 }
1391
1392 /// `properties_off` field offset.
1393 pub const fn properties_off_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]properties_off_offset().() -> usize {
1394 16
1395 }
1396
1397 /// `properties_len` field offset.
1398 pub const fn properties_len_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]properties_len_offset().() -> usize {
1399 20
1400 }
1401
1402 /// `filter_subsystem_hash` field offset.
1403 pub const fn filter_subsystem_hash_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_subsystem_hash_offset().() -> usize {
1404 24
1405 }
1406
1407 /// `filter_devtype_hash` field offset.
1408 pub const fn filter_devtype_hash_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_devtype_hash_offset().() -> usize {
1409 28
1410 }
1411
1412 /// `filter_tag_bloom_hi` field offset.
1413 pub const fn filter_tag_bloom_hi_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_hi_offset().() -> usize {
1414 32
1415 }
1416
1417 /// `filter_tag_bloom_lo` field offset.
1418 pub const fn filter_tag_bloom_lo_offsetrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader]filter_tag_bloom_lo_offset().() -> usize {
1419 36
1420 }
1421 }
1422
1423 impl TryFromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryFrom#<&[u8]> for UdevMonitorNetlinkHeaderrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader# {
1424 type Errorrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`]Error# = Errorrust-analyzer cargo udevrs 0.4.0 error/Error#;
1425
1426 fn try_fromrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`]try_from().(val: &[u8]) -> Resultrust-analyzer cargo udevrs 0.4.0 error/Result#<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`]> {
1427 let len = val.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
1428 let hdr_len = memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`]>();
1429 if len rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]lt().hdr_len {
1430 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1431 "invalid buffer length: {len}, expected at least: {hdr_len}"
1432 )))
1433 } else if &val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()...rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeTo#8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]ne().b"libudev\0".as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core array/impl#[`[T; N]`][`AsRef<[T]>`]as_ref().() {
1434 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(
1435 "invalid monitor netlink prefix, expected: 'libudev'".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
1436 ))
1437 } else {
1438 let mut idx = 0;
1439
1440 let prefix: [u8; 8] = val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().8]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`TryInto<U>`]try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
1441 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().prefix.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
1442
1443 let magic = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1444 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1445
1446 let header_size = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1447 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1448
1449 let properties_off = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1450 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1451
1452 let properties_len = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1453 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1454
1455 let filter_subsystem_hash = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1456 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1457
1458 let filter_devtype_hash = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1459 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1460
1461 let filter_tag_bloom_hi = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1462 idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().+=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`AddAssign<Self>`]add_assign().memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of().::<u32>();
1463
1464 let filter_tag_bloom_lo = u32::from_le_bytesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/impl#[u32]from_le_bytes().(val[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().idx..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#idx rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().4]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index()..try_intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/TryInto#try_into().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/try_trait/Try#branch().);
1465
1466 if magic rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]ne().UDEV_MONITOR_MAGICrust-analyzer cargo udevrs 0.4.0 monitor/UDEV_MONITOR_MAGIC. {
1467 let err_msg = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
1468 "UDEV magic bytes do not match, expected: {UDEV_MONITOR_MAGIC:#x}, have: {magic:#x}"
1469 );
1470 logrust-analyzer cargo log 0.4.25 crate/::errorrust-analyzer cargo log 0.4.25 macros/error!!("{err_msg}");
1471 Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(Errorrust-analyzer cargo udevrs 0.4.0 error/Error#::UdevMonitorrust-analyzer cargo udevrs 0.4.0 error/Error#UdevMonitor#(err_msg))
1472 } else {
1473 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo udevrs 0.4.0 monitor/impl#[UdevMonitorNetlinkHeader][`TryFrom<&[u8]>`] {
1474 prefixrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#prefix.,
1475 magicrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#magic.,
1476 header_sizerust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#header_size.,
1477 properties_offrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_off.,
1478 properties_lenrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#properties_len.,
1479 filter_subsystem_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_subsystem_hash.,
1480 filter_devtype_hashrust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_devtype_hash.,
1481 filter_tag_bloom_hirust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_hi.,
1482 filter_tag_bloom_lorust-analyzer cargo udevrs 0.4.0 monitor/UdevMonitorNetlinkHeader#filter_tag_bloom_lo.,
1483 })
1484 }
1485 }
1486 }
1487 }