pub fn save_toolstate(&self, tool: &str, state: ToolState) {
        if let Some(ref path) = self.config.save_toolstates {
            if let Some(parent) = path.parent() {
                // Ensure the parent directory always exists
                t!(std::fs::create_dir_all(parent));
            }
            let mut file = t!(fs::OpenOptions::new()
                .create(true)
                .read(true)
                .write(true)
                .open(path));

            let mut current_toolstates: HashMap<Box<str>, ToolState> =
                serde_json::from_reader(&mut file).unwrap_or_default();
            current_toolstates.insert(tool.into(), state);
            t!(file.seek(SeekFrom::Start(0)));
            t!(file.set_len(0));
            t!(serde_json::to_writer(file, &current_toolstates));
        }
    }
/// Updates the actual toolstate of a tool.
///
/// The toolstates are saved to the file specified by the key
/// `rust.save-toolstates` in `config.toml`. If unspecified, nothing will be
/// done. The file is updated immediately after this function completes.
Updates the actual toolstate of a tool.
The toolstates are saved to the file specified by the key
`rust.save-toolstates` in `config.toml`. If unspecified, nothing will be
done. The file is updated immediately after this function completes.
Updates the actual toolstate of a tool . The toolstates are saved to the file specified by the key ` rust . save - toolstates ` in ` config . toml ` . If unspecified nothing will be done . The file is updated immediately after this function completes .
pub fn save_toolstate(&self, tool: &str, state: ToolState) {
        if let Some(ref path) = self.config.save_toolstates {
            if let Some(parent) = path.parent() {
                // Ensure the parent directory always exists
                t!(std::fs::create_dir_all(parent));
            }
            let mut file = t!(fs::OpenOptions::new()
                .create(true)
                .read(true)
                .write(true)
                .open(path));
            let mut current_toolstates: HashMap<Box<str>, ToolState> =
                serde_json::from_reader(&mut file).unwrap_or_default();
            current_toolstates.insert(tool.into(), state);
            t!(file.seek(SeekFrom::Start(0)));
            t!(file.set_len(0));
            t!(serde_json::to_writer(file, &current_toolstates));
        }
    }
pub fn save_toolstate ( & self , tool : & str , state : ToolState ) { if let Some ( ref path ) = self . config . save_toolstates { if let Some ( parent ) = path . parent ( ) { // Ensure the parent directory always exists t ! ( std fs create_dir_all ( parent ) ) ; } let mut file = t ! ( fs OpenOptions new ( ) create ( true ) read ( true ) write ( true ) open ( path ) ) ; let mut current_toolstates : HashMap < Box < str > , ToolState > = serde_json :: from_reader ( & mut file ) . unwrap_or_default ( ) ; current_toolstates . insert ( tool . into ( ) , state ) ; t ! ( file seek ( SeekFrom Start ( 0 ) ) ) ; t ! ( file set_len ( 0 ) ) ; t ! ( serde_json to_writer ( file current_toolstates ) ) ; } }
Updates the actual toolstate of a tool.
Updates the actual toolstate of a tool .
&self
tool
&str
state
ToolState