use std::hash::{Hash, Hasher};
use crate::{five_tuple::FiveTuple, Duration};
#[allow(clippy::upper_case_acronyms)]
pub type FlowID = u64;
#[derive(Clone, PartialEq, Eq, Default, Debug)]
pub struct Flow {
pub flow_id: FlowID,
pub five_tuple: FiveTuple,
pub first_seen: Duration,
pub last_seen: Duration,
}
impl Flow {
pub fn new(five_tuple: &FiveTuple, ts_sec: u32, ts_usec: u32) -> Self {
let d = Duration::new(ts_sec, ts_usec);
Flow {
flow_id: 0,
five_tuple: five_tuple.clone(),
first_seen: d,
last_seen: d,
}
}
}
#[allow(clippy::derive_hash_xor_eq)]
impl Hash for Flow {
fn hash<H: Hasher>(&self, state: &mut H) {
self.five_tuple.hash(state);
self.first_seen.hash(state);
}
}