oxios_kernel/
session_context.rs1use crate::memory::RecallTiming;
7use crate::project::ProjectId;
8
9#[derive(Debug)]
15pub struct SessionContext {
16 pub recall_timing: Option<RecallTiming>,
20
21 pub primary_project_id: Option<ProjectId>,
23
24 pub secondary_project_ids: Vec<ProjectId>,
26}
27
28impl SessionContext {
29 pub fn new() -> Self {
31 Self {
32 recall_timing: Some(RecallTiming::new()),
33 primary_project_id: None,
34 secondary_project_ids: Vec::new(),
35 }
36 }
37
38 pub fn with_project(project_id: ProjectId) -> Self {
40 Self {
41 recall_timing: Some(RecallTiming::new()),
42 primary_project_id: Some(project_id),
43 secondary_project_ids: Vec::new(),
44 }
45 }
46
47 pub fn with_projects(primary: ProjectId, secondary: Vec<ProjectId>) -> Self {
49 Self {
50 recall_timing: Some(RecallTiming::new()),
51 primary_project_id: Some(primary),
52 secondary_project_ids: secondary,
53 }
54 }
55
56 pub fn all_project_ids(&self) -> Vec<ProjectId> {
58 let mut ids = Vec::new();
59 if let Some(primary) = self.primary_project_id {
60 ids.push(primary);
61 }
62 ids.extend(self.secondary_project_ids.iter().copied());
63 ids
64 }
65
66 pub fn has_project(&self) -> bool {
68 self.primary_project_id.is_some()
69 }
70}
71
72impl Default for SessionContext {
73 fn default() -> Self {
74 Self::new()
75 }
76}