Skip to main content

bctx_forge/tracker/
session.rs

1use super::metrics::SessionMetrics;
2use std::time::Instant;
3
4pub struct SessionLog {
5    pub id: String,
6    pub started_at: Instant,
7    pub metrics: SessionMetrics,
8}
9
10impl SessionLog {
11    pub fn new() -> Self {
12        Self {
13            id: uuid::Uuid::new_v4().to_string(),
14            started_at: Instant::now(),
15            metrics: SessionMetrics::default(),
16        }
17    }
18
19    pub fn elapsed_secs(&self) -> u64 {
20        self.started_at.elapsed().as_secs()
21    }
22}
23
24impl Default for SessionLog {
25    fn default() -> Self {
26        Self::new()
27    }
28}