| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{ |
| 2 | linked_listrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/::{Iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/Iter#, IterMutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/IterMut#}, |
| 3 | LinkedListrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/LinkedList#, |
| 4 | }; |
| 5 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#; |
| 6 | |
| 7 | use craterust-analyzer cargo udevrs 0.4.0 crate/::{Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#, UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#}; |
| 8 | |
| 9 | /// Convenience alias for a [LinkedList] of [UdevEntry]. |
| 10 | pub type UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList# = LinkedListrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/LinkedList#<UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#>; |
| 11 | |
| 12 | /// Represents a list wrapper around a [UdevEntryList]. |
| 13 | #[repr(C)] |
| 14 | #[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:, 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:)] |
| 15 | pub struct UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# { |
| 16 | udevrust-analyzer cargo udevrs 0.4.0 list/UdevList#udev.: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>, |
| 17 | listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list.: UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#, |
| 18 | entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur.: usize, |
| 19 | entries_maxrust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_max.: usize, |
| 20 | uniquerust-analyzer cargo udevrs 0.4.0 list/UdevList#unique.: bool, |
| 21 | } |
| 22 | |
| 23 | impl UdevListrust-analyzer cargo udevrs 0.4.0 list/UdevList# { |
| 24 | /// Creates a new [UdevList]. |
| 25 | pub const fn newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]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#>) -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList] { |
| 26 | Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList] { |
| 27 | udevrust-analyzer cargo udevrs 0.4.0 list/UdevList#udev., |
| 28 | listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list.: LinkedListrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/LinkedList#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T>`]new().(), |
| 29 | entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur.: 0, |
| 30 | entries_maxrust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_max.: 0, |
| 31 | uniquerust-analyzer cargo udevrs 0.4.0 list/UdevList#unique.: true, |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | /// Creates a new [UdevList] from the provided parameters. |
| 36 | pub const fn createrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]create().(udev: Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<Udevrust-analyzer cargo udevrs 0.4.0 context/Udev#>, list: UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList#) -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList] { |
| 37 | Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList] { |
| 38 | udevrust-analyzer cargo udevrs 0.4.0 list/UdevList#udev., |
| 39 | listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list., |
| 40 | entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur.: 0, |
| 41 | entries_maxrust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_max.: 0, |
| 42 | uniquerust-analyzer cargo udevrs 0.4.0 list/UdevList#unique.: true, |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | /// Gets an [`Iterator`] over [UdevEntry] items. |
| 47 | pub fn iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().(&self) -> Iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/Iter#<UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 48 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter().() |
| 49 | } |
| 50 | |
| 51 | /// Gets an [`Iterator`] over [UdevEntry] items. |
| 52 | pub fn iter_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter_mut().(&mut self) -> IterMutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/IterMut#<UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 53 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iter_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter_mut().() |
| 54 | } |
| 55 | |
| 56 | /// Gets a reference to the [UdevEntryList]. |
| 57 | pub fn listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]list().(&self) -> &UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList# { |
| 58 | &self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list. |
| 59 | } |
| 60 | |
| 61 | /// Gets a mutable reference to the [UdevEntryList]. |
| 62 | pub fn list_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]list_mut().(&mut self) -> &mut UdevEntryListrust-analyzer cargo udevrs 0.4.0 list/UdevEntryList# { |
| 63 | &mut self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list. |
| 64 | } |
| 65 | |
| 66 | /// Sets the [UdevEntryList]. |
| 67 | pub fn set_listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]set_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) { |
| 68 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list. = list.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 69 | } |
| 70 | |
| 71 | /// Builder function that sets the [UdevEntryList]. |
| 72 | pub fn with_listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]with_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 list/impl#[UdevList] { |
| 73 | self.set_listrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]set_list().(list); |
| 74 | self |
| 75 | } |
| 76 | |
| 77 | /// Gets the length of the [UdevEntry] list. |
| 78 | pub fn lenrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]len().(&self) -> usize { |
| 79 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]len().() |
| 80 | } |
| 81 | |
| 82 | /// Gets whether the [UdevEntryList] is empty. |
| 83 | pub fn is_emptyrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]is_empty().(&self) -> bool { |
| 84 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]is_empty().() |
| 85 | } |
| 86 | |
| 87 | /// Clears the list of all entries. |
| 88 | pub fn clearrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]clear().(&mut self) { |
| 89 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..clearrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]clear().(); |
| 90 | } |
| 91 | |
| 92 | /// Gets an optional reference to the first [UdevEntry] in the [UdevEntryList]. |
| 93 | pub fn entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 94 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]front().() |
| 95 | } |
| 96 | |
| 97 | /// Gets an optional mutable reference to the first [UdevEntry] in the [UdevEntryList]. |
| 98 | pub fn entry_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 99 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..front_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]front_mut().() |
| 100 | } |
| 101 | |
| 102 | /// Gets an optional reference to an [UdevEntry] with a matching `name`. |
| 103 | pub fn entry_by_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_by_name().(&self, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 104 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| e.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().name) |
| 105 | } |
| 106 | |
| 107 | /// Gets an optional mutable reference to an [UdevEntry] with a matching `name`. |
| 108 | pub fn entry_by_name_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_by_name_mut().(&mut self, name: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 109 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iter_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter_mut().().findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#find().(|e| e.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().name) |
| 110 | } |
| 111 | |
| 112 | /// Gets the next [UdevEntry] in the list. |
| 113 | pub fn next_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]next_entry().(&self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 114 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(self.entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur.) |
| 115 | } |
| 116 | |
| 117 | /// Gets the next [UdevEntry] in the list. |
| 118 | pub fn next_entry_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]next_entry_mut().(&mut self) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&mut UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 119 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iter_mutrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter_mut().().nthrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#nth().(self.entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur.) |
| 120 | } |
| 121 | |
| 122 | /// Adds an entry to the list. |
| 123 | /// |
| 124 | /// If an [UdevEntry] with the same `name` exists, the `value` will be updated. |
| 125 | /// |
| 126 | /// If `value` is empty, the entry value with be empty. |
| 127 | pub fn add_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]add_entry().(&mut self, name: &str, value: &str) -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#> { |
| 128 | if self.uniquerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]unique().() && self.entry_by_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_by_name().(name).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() { |
| 129 | let existing = self.entry_by_name_mutrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_by_name_mut().(name).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().(); |
| 130 | logrust-analyzer cargo log 0.4.25 crate/::tracerust-analyzer cargo log 0.4.25 macros/trace!!("Updating property, {name}: {} => {value}", existing.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().()); |
| 131 | existing.set_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_value().(value); |
| 132 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(existing) |
| 133 | } else { |
| 134 | logrust-analyzer cargo log 0.4.25 crate/::tracerust-analyzer cargo log 0.4.25 macros/trace!!("Adding property, {name}: {value}"); |
| 135 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list. |
| 136 | .push_backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]push_back().(UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#::newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]new().().with_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_name().(name).with_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_value().(value)); |
| 137 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..backrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]back().() |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /// Removes an [UdevEntry] if an entry exists with a matching `name`. |
| 142 | pub fn remove_entryrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]remove_entry().(&mut self, name: &str) { |
| 143 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(pos) = self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]iter().().positionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#position().(|e| e.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[`&A`][`PartialEq<&B>`]eq().name) { |
| 144 | let mut ext = self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..split_offrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]split_off().(pos); |
| 145 | |
| 146 | if ext.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().1 { |
| 147 | ext.pop_frontrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T, A>`]pop_front().(); |
| 148 | self.listrust-analyzer cargo udevrs 0.4.0 list/UdevList#list..appendrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/linked_list/impl#[`LinkedList<T>`]append().(&mut ext); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /// Gets the current [UdevEntry]. |
| 154 | pub const fn entries_currust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entries_cur().(&self) -> usize { |
| 155 | self.entries_currust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_cur. |
| 156 | } |
| 157 | |
| 158 | /// Gets the maximum number of [UdevEntry] items. |
| 159 | pub const fn entries_maxrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entries_max().(&self) -> usize { |
| 160 | self.entries_maxrust-analyzer cargo udevrs 0.4.0 list/UdevList#entries_max. |
| 161 | } |
| 162 | |
| 163 | /// Gets whether the [UdevList] is unique. |
| 164 | pub const fn uniquerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]unique().(&self) -> bool { |
| 165 | self.uniquerust-analyzer cargo udevrs 0.4.0 list/UdevList#unique. |
| 166 | } |
| 167 | |
| 168 | /// Gets whether the [UdevDevice] matches an [UdevEntry] in the list. |
| 169 | pub fn has_tagrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]has_tag().(&self, device: &UdevDevicerust-analyzer cargo udevrs 0.4.0 device/UdevDevice#) -> bool { |
| 170 | if self.is_emptyrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]is_empty().() { |
| 171 | true |
| 172 | } else { |
| 173 | self.iterrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]iter().() |
| 174 | .filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|e| device.tags_listrust-analyzer cargo udevrs 0.4.0 device/impl#[UdevDevice]tags_list().().entry_by_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevList]entry_by_name().(e.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().()).is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()) |
| 175 | .countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/adapters/filter/impl#[`Filter<I, P>`][Iterator]count().() |
| 176 | !=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().0 |
| 177 | } |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | /// UDEV list entry. |
| 182 | /// |
| 183 | /// An entry contains contains a name, and optionally a value. |
| 184 | #[repr(C)] |
| 185 | #[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:, 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:)] |
| 186 | pub struct UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry# { |
| 187 | namerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 188 | valuerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#value.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 189 | numrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#num.: i32, |
| 190 | } |
| 191 | |
| 192 | impl UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry# { |
| 193 | /// Creates a new [UdevEntry]. |
| 194 | pub const fn newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]new().() -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry] { |
| 195 | Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry] { |
| 196 | namerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#name.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 197 | valuerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#value.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]new().(), |
| 198 | numrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#num.: 0, |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | /// Gets the [UdevEntry] name. |
| 203 | pub fn namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().(&self) -> &str { |
| 204 | self.namerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#name..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() |
| 205 | } |
| 206 | |
| 207 | /// Sets the [UdevEntry] name. |
| 208 | pub fn set_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_name().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(&mut self, name: N) { |
| 209 | self.namerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#name. = name.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 210 | } |
| 211 | |
| 212 | /// Builder function that sets the [UdevEntry] name. |
| 213 | pub fn with_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_name().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(mut self, name: N) -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry] { |
| 214 | self.set_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_name().(name); |
| 215 | self |
| 216 | } |
| 217 | |
| 218 | /// Gets the [UdevEntry] value. |
| 219 | pub fn valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().(&self) -> &str { |
| 220 | self.valuerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#value..as_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_str().() |
| 221 | } |
| 222 | |
| 223 | /// Sets the [UdevEntry] value. |
| 224 | pub fn set_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_value().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(&mut self, value: N) { |
| 225 | self.valuerust-analyzer cargo udevrs 0.4.0 list/UdevEntry#value. = value.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 226 | } |
| 227 | |
| 228 | /// Builder function that sets the [UdevEntry] value. |
| 229 | pub fn with_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_value().<N: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>(mut self, value: N) -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry] { |
| 230 | self.set_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_value().(value); |
| 231 | self |
| 232 | } |
| 233 | |
| 234 | /// Gets the [UdevEntry] number. |
| 235 | pub const fn numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]num().(&self) -> i32 { |
| 236 | self.numrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#num. |
| 237 | } |
| 238 | |
| 239 | /// Sets the [UdevEntry] number. |
| 240 | pub fn set_numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_num().(&mut self, num: i32) { |
| 241 | self.numrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#num. = num; |
| 242 | } |
| 243 | |
| 244 | /// Builder function that sets the [UdevEntry] number. |
| 245 | pub fn with_numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_num().(mut self, num: i32) -> Selfrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry] { |
| 246 | self.set_numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_num().(num); |
| 247 | self |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | #[cfg(test)] |
| 252 | mod testsrust-analyzer cargo udevrs 0.4.0 list/tests/ { |
| 253 | use superrust-analyzer cargo udevrs 0.4.0 list/::*; |
| 254 | |
| 255 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 256 | fn test_udev_entryrust-analyzer cargo udevrs 0.4.0 list/tests/test_udev_entry().() { |
| 257 | let mut null_entry = UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#::newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]new().(); |
| 258 | |
| 259 | let exp_name = "test_name"; |
| 260 | let exp_value = "test_value"; |
| 261 | let exp_num = 42; |
| 262 | |
| 263 | let exp_entry = UdevEntryrust-analyzer cargo udevrs 0.4.0 list/UdevEntry#::newrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]new().() |
| 264 | .with_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_name().(exp_name) |
| 265 | .with_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_value().(exp_value) |
| 266 | .with_numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]with_num().(exp_num); |
| 267 | |
| 268 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().(), ""); |
| 269 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().(), ""); |
| 270 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]num().(), 0); |
| 271 | |
| 272 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(exp_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().(), exp_name); |
| 273 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(exp_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().(), exp_value); |
| 274 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(exp_entry.numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]num().(), exp_num); |
| 275 | |
| 276 | null_entry.set_namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_name().(exp_name); |
| 277 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.namerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]name().(), exp_name); |
| 278 | |
| 279 | null_entry.set_valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_value().(exp_value); |
| 280 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.valuerust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]value().(), exp_value); |
| 281 | |
| 282 | null_entry.set_numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]set_num().(exp_num); |
| 283 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry.numrust-analyzer cargo udevrs 0.4.0 list/impl#[UdevEntry]num().(), exp_num); |
| 284 | |
| 285 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(null_entry, exp_entry); |
| 286 | } |
| 287 | } |