pub struct ContextManager { /* private fields */ }Expand description
Manages session context with isolation between sessions
Each ContextManager instance maintains its own isolated context. Modifications to one context do not affect other contexts.
Implementations§
Source§impl ContextManager
impl ContextManager
Sourcepub fn with_context(context: SessionContext) -> Self
pub fn with_context(context: SessionContext) -> Self
Create a context manager with an initial context
Sourcepub fn set_context(&mut self, context: SessionContext)
pub fn set_context(&mut self, context: SessionContext)
Set the session context
This replaces the entire context. Each ContextManager maintains its own isolated context, so changes here do not affect other ContextManager instances.
Sourcepub fn get_context(&self) -> SessionResult<SessionContext>
pub fn get_context(&self) -> SessionResult<SessionContext>
Get the current context
Returns a clone of the context, ensuring isolation between different parts of the system.
Sourcepub fn add_file(&mut self, file_path: String) -> SessionResult<()>
pub fn add_file(&mut self, file_path: String) -> SessionResult<()>
Add a file to the context
Files are stored as paths in the context. Adding a file to one context does not affect other contexts.
Sourcepub fn remove_file(&mut self, file_path: &str) -> SessionResult<()>
pub fn remove_file(&mut self, file_path: &str) -> SessionResult<()>
Remove a file from the context
Removes the specified file path from the context. If the file is not in the context, this is a no-op.
Sourcepub fn get_files(&self) -> SessionResult<Vec<String>>
pub fn get_files(&self) -> SessionResult<Vec<String>>
Get all files in the context
Sourcepub fn clear_files(&mut self) -> SessionResult<()>
pub fn clear_files(&mut self) -> SessionResult<()>
Clear all files from the context
Sourcepub fn set_project_path(&mut self, path: Option<String>) -> SessionResult<()>
pub fn set_project_path(&mut self, path: Option<String>) -> SessionResult<()>
Set the project path in the context
Sourcepub fn get_project_path(&self) -> SessionResult<Option<String>>
pub fn get_project_path(&self) -> SessionResult<Option<String>>
Get the project path from the context
Sourcepub fn has_file(&self, file_path: &str) -> SessionResult<bool>
pub fn has_file(&self, file_path: &str) -> SessionResult<bool>
Check if a file is in the context
Sourcepub fn switch_project(&mut self, project_path: String) -> SessionResult<()>
pub fn switch_project(&mut self, project_path: String) -> SessionResult<()>
Switch to a different project
This updates the project path in the context and clears the file list to reflect the new project context.
Sourcepub fn get_context_for_persistence(&self) -> SessionResult<SessionContext>
pub fn get_context_for_persistence(&self) -> SessionResult<SessionContext>
Get the context for persistence
Returns the current context for saving to disk. This is used by the SessionStore to persist context with the session.
Sourcepub fn restore_from_persistence(&mut self, context: SessionContext)
pub fn restore_from_persistence(&mut self, context: SessionContext)
Restore context from persistence
Restores the context from a previously saved state. This is used by the SessionStore when loading a session from disk.
Trait Implementations§
Source§impl Clone for ContextManager
impl Clone for ContextManager
Source§fn clone(&self) -> ContextManager
fn clone(&self) -> ContextManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more