}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&TemplateTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
fn new_tx(&mut self) -> TemplateTransaction {
}
fn find_request(&mut self) -> Option<&mut TemplateTransaction> {
- for tx in &mut self.transactions {
- if tx.response.is_none() {
- return Some(tx);
- }
- }
- None
+ self.transactions.iter_mut().find(|tx| tx.response.is_none())
}
fn parse_request(&mut self, input: &[u8]) -> AppLayerResult {
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&DHCPTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
fn free_tx(&mut self, tx_id: u64) {
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&mut IKETransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter_mut().find(|tx| tx.tx_id == tx_id + 1)
}
pub fn new_tx(&mut self) -> IKETransaction {
#![allow(clippy::too_many_arguments)]
// To be fixed, but remove the noise for now.
-#![allow(clippy::manual_find)]
#![allow(clippy::match_like_matches_macro)]
#![allow(clippy::module_inception)]
#![allow(clippy::result_unit_err)]
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&mut ModbusTransaction> {
- for tx in &mut self.transactions {
- if tx.id == tx_id + 1 {
- return Some(tx);
- }
- }
- None
+ self.transactions.iter_mut().find(|tx| tx.id == tx_id + 1)
}
/// Searches the requests in order to find one matching the given response. Returns the matching
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&MQTTTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
pub fn get_tx_by_pkt_id(&mut self, pkt_id: u32) -> Option<&mut MQTTTransaction> {
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&PgsqlTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
fn new_tx(&mut self) -> PgsqlTransaction {
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&RFBTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
fn new_tx(&mut self) -> RFBTransaction {
}
fn get_current_tx(&mut self) -> Option<&mut RFBTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == self.tx_id {
- return Some(tx);
- }
- }
- return None;
+ let tx_id = self.tx_id;
+ self.transactions.iter_mut().find(|tx| tx.tx_id == tx_id)
}
fn parse_request(&mut self, input: &[u8]) -> AppLayerResult {
}
pub fn get_tx(&mut self, tx_id: u64) -> Option<&TelnetTransaction> {
- for tx in &mut self.transactions {
- if tx.tx_id == tx_id + 1 {
- return Some(tx);
- }
- }
- return None;
+ self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
}
fn _new_tx(&mut self) -> TelnetTransaction {