use crate::os::SystemOS; use crate::task::TaskId; pub struct SessionsFacade<'a> { pub(in crate::os) os: &'a mut SystemOS, } impl<'a> SessionsFacade<'a> { pub fn create_vm_game_task(&mut self, app_id: u32, title: impl Into) -> TaskId { let title = title.into(); let process_id = self.os.process_manager.spawn_vm_game(app_id, title.clone()); let task_id = self.os.task_manager.create_game_task(process_id, app_id, title); self.os .lifecycle() .set_foreground_task(task_id) .expect("newly created game task should have an associated process"); task_id } pub fn create_vm_shell_task(&mut self, app_id: u32, title: impl Into) -> TaskId { let title = title.into(); let process_id = self.os.process_manager.spawn_vm_shell(app_id, title.clone()); let task_id = self.os.task_manager.create_shell_task(process_id, app_id, title); self.os .lifecycle() .set_foreground_task(task_id) .expect("newly created shell task should have an associated process"); task_id } pub fn create_native_shell_task(&mut self, app_id: u32, title: impl Into) -> TaskId { let title = title.into(); let process_id = self.os.process_manager.spawn_native_shell(app_id, title.clone()); let task_id = self.os.task_manager.create_shell_task(process_id, app_id, title); self.os .lifecycle() .set_foreground_task(task_id) .expect("newly created native shell task should have an associated process"); task_id } }