|
1 | 1 | use std::{
|
2 | 2 | convert::{TryFrom, TryInto},
|
| 3 | + ops::Not, |
3 | 4 | path::PathBuf,
|
4 | 5 | };
|
5 | 6 |
|
@@ -88,11 +89,7 @@ fn get_stream_transport(opt: &observe::observe_origin::Stream) -> Result<factory
|
88 | 89 | .into_iter()
|
89 | 90 | .map(|mc| factory::MulticastInfo {
|
90 | 91 | multiaddr: mc.multiaddr,
|
91 |
| - interface: if mc.interface.is_empty() { |
92 |
| - None |
93 |
| - } else { |
94 |
| - Some(mc.interface) |
95 |
| - }, |
| 92 | + interface: mc.interface.is_empty().not().then_some(mc.interface), |
96 | 93 | })
|
97 | 94 | .collect(),
|
98 | 95 | })
|
@@ -125,54 +122,30 @@ impl TryInto<factory::ObserveOptions> for JsIncomeBuffer {
|
125 | 122 | observe::parser_type::Type::Dlt(opt) => {
|
126 | 123 | factory::ParserType::Dlt(factory::DltParserSettings {
|
127 | 124 | filter_config: opt.filter_config.map(|opt| factory::DltFilterConfig {
|
128 |
| - min_log_level: Some( |
129 |
| - if opt.min_log_level <= u8::MAX as u32 |
130 |
| - && opt.min_log_level >= u8::MIN as u32 |
131 |
| - { |
132 |
| - opt.min_log_level as u8 |
133 |
| - } else { |
134 |
| - 0 |
135 |
| - }, |
136 |
| - ), |
| 125 | + min_log_level: Some(u8::try_from(opt.min_log_level).unwrap_or(0)), |
137 | 126 | app_id_count: opt.app_id_count,
|
138 |
| - app_ids: if opt.app_ids.is_empty() { |
139 |
| - None |
140 |
| - } else { |
141 |
| - Some(opt.app_ids) |
142 |
| - }, |
| 127 | + app_ids: opt.app_ids.is_empty().not().then_some(opt.app_ids), |
143 | 128 | context_id_count: opt.context_id_count,
|
144 |
| - context_ids: if opt.context_ids.is_empty() { |
145 |
| - None |
146 |
| - } else { |
147 |
| - Some(opt.context_ids) |
148 |
| - }, |
149 |
| - ecu_ids: if opt.ecu_ids.is_empty() { |
150 |
| - None |
151 |
| - } else { |
152 |
| - Some(opt.ecu_ids) |
153 |
| - }, |
| 129 | + context_ids: opt.context_ids.is_empty().not().then_some(opt.context_ids), |
| 130 | + ecu_ids: opt.ecu_ids.is_empty().not().then_some(opt.ecu_ids), |
154 | 131 | }),
|
155 |
| - fibex_file_paths: if opt.fibex_file_paths.is_empty() { |
156 |
| - None |
157 |
| - } else { |
158 |
| - Some(opt.fibex_file_paths) |
159 |
| - }, |
| 132 | + fibex_file_paths: opt |
| 133 | + .fibex_file_paths |
| 134 | + .is_empty() |
| 135 | + .not() |
| 136 | + .then_some(opt.fibex_file_paths), |
160 | 137 | with_storage_header: opt.with_storage_header,
|
161 |
| - tz: if opt.tz.is_empty() { |
162 |
| - None |
163 |
| - } else { |
164 |
| - Some(opt.tz) |
165 |
| - }, |
| 138 | + tz: opt.tz.is_empty().not().then_some(opt.tz), |
166 | 139 | fibex_metadata: None,
|
167 | 140 | })
|
168 | 141 | }
|
169 | 142 | observe::parser_type::Type::SomeIp(opt) => {
|
170 | 143 | factory::ParserType::SomeIp(factory::SomeIpParserSettings {
|
171 |
| - fibex_file_paths: if opt.fibex_file_paths.is_empty() { |
172 |
| - None |
173 |
| - } else { |
174 |
| - Some(opt.fibex_file_paths) |
175 |
| - }, |
| 144 | + fibex_file_paths: opt |
| 145 | + .fibex_file_paths |
| 146 | + .is_empty() |
| 147 | + .not() |
| 148 | + .then_some(opt.fibex_file_paths), |
176 | 149 | })
|
177 | 150 | }
|
178 | 151 | observe::parser_type::Type::Text(_) => factory::ParserType::Text,
|
|
0 commit comments