zond_engine/core/
session.rs1use dashmap::DashMap;
2use std::net::IpAddr;
3use std::sync::Arc;
4use tokio::sync::mpsc;
5
6use crate::core::handle::ScanHandle;
7use crate::core::models::host::Host;
8
9#[derive(Debug, Clone)]
11pub enum ScanEvent {
12 HostUpdated(IpAddr),
15}
16
17pub struct ScanSession {
19 pub store: Arc<DashMap<IpAddr, Host>>,
21
22 pub events: mpsc::UnboundedReceiver<ScanEvent>,
25
26 pub handle: ScanHandle,
28}
29
30impl ScanSession {
31 pub fn new() -> (Self, ScanHandle, mpsc::UnboundedSender<ScanEvent>) {
32 let store = Arc::new(DashMap::new());
33 let handle = ScanHandle::new();
34 let (tx, rx) = mpsc::unbounded_channel();
35
36 let session = Self {
37 store,
38 events: rx,
39 handle: handle.clone(),
40 };
41
42 (session, handle, tx)
43 }
44}