pub struct ToolState {
pub open_files: HashMap<PathBuf, FileState>,
pub current_file: Option<PathBuf>,
pub history: Vec<StateSnapshot>,
pub working_directory: PathBuf,
/* private fields */
}Expand description
Represents the state of the tool system
Fields§
§open_files: HashMap<PathBuf, FileState>Currently open files with their windowed views
current_file: Option<PathBuf>The currently active file
history: Vec<StateSnapshot>Session history for undo/redo
working_directory: PathBufCurrent working directory
Implementations§
Source§impl ToolState
impl ToolState
Sourcepub fn open_file(
&mut self,
path: PathBuf,
content: Vec<String>,
window_size: usize,
) -> Result<()>
pub fn open_file( &mut self, path: PathBuf, content: Vec<String>, window_size: usize, ) -> Result<()>
Open a file and add it to the state
Sourcepub fn get_current_file_state(&self) -> Option<&FileState>
pub fn get_current_file_state(&self) -> Option<&FileState>
Get the current file state
Sourcepub fn get_current_file_state_mut(&mut self) -> Option<&mut FileState>
pub fn get_current_file_state_mut(&mut self) -> Option<&mut FileState>
Get mutable current file state
Sourcepub fn switch_to_file(&mut self, path: &PathBuf) -> Result<(), ToolError>
pub fn switch_to_file(&mut self, path: &PathBuf) -> Result<(), ToolError>
Switch to a different open file
Sourcepub fn close_file(&mut self, path: &PathBuf)
pub fn close_file(&mut self, path: &PathBuf)
Close a file
Sourcepub fn create_snapshot(&self, operation: String) -> StateSnapshot
pub fn create_snapshot(&self, operation: String) -> StateSnapshot
Create a snapshot for history
Sourcepub fn push_history(&mut self, operation: String)
pub fn push_history(&mut self, operation: String)
Add to history
Sourcepub fn get_summary(&self) -> String
pub fn get_summary(&self) -> String
Get state summary for display
Sourcepub fn request_cancel(&self)
pub fn request_cancel(&self)
Signal cancellation — sets the shared flag so running tools can check it.
Sourcepub fn reset_cancel(&self)
pub fn reset_cancel(&self)
Reset the cancel signal (e.g. before starting a new tool call).
Sourcepub fn is_cancelled(&self) -> bool
pub fn is_cancelled(&self) -> bool
Check whether cancellation has been requested.
Sourcepub fn cancel_signal(&self) -> Arc<AtomicBool>
pub fn cancel_signal(&self) -> Arc<AtomicBool>
Return a clone of the inner Arc<AtomicBool> so a tool can check
the signal without holding the Mutex<ToolState> lock.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ToolState
impl RefUnwindSafe for ToolState
impl Send for ToolState
impl Sync for ToolState
impl Unpin for ToolState
impl UnsafeUnpin for ToolState
impl UnwindSafe for ToolState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more