1111
1212pub mod types;
1313
14- pub use types:: { AiProvider , AutopilotStatus , ClaiConfig , ProviderInfo , SpaceAutopilot , SpaceConfig } ;
14+ pub use types:: {
15+ AiProvider , AutopilotStatus , ClaiConfig , ProviderInfo , SpaceAutopilot , SpaceConfig ,
16+ } ;
1517
1618use std:: fs;
1719use std:: io:: Write ;
@@ -80,9 +82,7 @@ impl ConfigManager {
8082 source : e,
8183 } ) ?;
8284
83- serde_json:: from_str ( & contents) . map_err ( |e| ConfigError :: Parse {
84- source : e,
85- } )
85+ serde_json:: from_str ( & contents) . map_err ( |e| ConfigError :: Parse { source : e } )
8686 }
8787
8888 /// Saves the current config to disk.
@@ -95,9 +95,8 @@ impl ConfigManager {
9595
9696 /// Saves config to file with atomic write.
9797 fn save_to_file ( & self , config : & ClaiConfig ) -> Result < ( ) , ConfigError > {
98- let json = serde_json:: to_string_pretty ( config) . map_err ( |e| ConfigError :: Serialize {
99- source : e,
100- } ) ?;
98+ let json = serde_json:: to_string_pretty ( config)
99+ . map_err ( |e| ConfigError :: Serialize { source : e } ) ?;
101100
102101 // Write to temp file first
103102 let temp_path = self . config_path . with_extension ( "json.tmp" ) ;
@@ -107,10 +106,11 @@ impl ConfigManager {
107106 source : e,
108107 } ) ?;
109108
110- file. write_all ( json. as_bytes ( ) ) . map_err ( |e| ConfigError :: Io {
111- operation : "write temp config file" . to_string ( ) ,
112- source : e,
113- } ) ?;
109+ file. write_all ( json. as_bytes ( ) )
110+ . map_err ( |e| ConfigError :: Io {
111+ operation : "write temp config file" . to_string ( ) ,
112+ source : e,
113+ } ) ?;
114114
115115 file. sync_all ( ) . map_err ( |e| ConfigError :: Io {
116116 operation : "sync temp config file" . to_string ( ) ,
@@ -152,11 +152,7 @@ impl ConfigManager {
152152 /// Gets config for a space.
153153 pub fn get_space_config ( & self , space_id : & str ) -> SpaceConfig {
154154 let config = self . config . lock ( ) . unwrap ( ) ;
155- config
156- . spaces
157- . get ( space_id)
158- . cloned ( )
159- . unwrap_or_default ( )
155+ config. spaces . get ( space_id) . cloned ( ) . unwrap_or_default ( )
160156 }
161157
162158 // =========================================================================
@@ -176,10 +172,7 @@ impl ConfigManager {
176172 /// Enables auto-pilot for a room and saves config.
177173 pub fn enable_autopilot ( & self , space_id : & str , room_id : & str ) -> Result < ( ) , ConfigError > {
178174 self . update ( |config| {
179- let space_config = config
180- . spaces
181- . entry ( space_id. to_string ( ) )
182- . or_default ( ) ;
175+ let space_config = config. spaces . entry ( space_id. to_string ( ) ) . or_default ( ) ;
183176 space_config. autopilot . enable_room ( room_id) ;
184177 } )
185178 }
@@ -321,7 +314,12 @@ mod tests {
321314
322315 // Load from file
323316 let loaded = ConfigManager :: load_from_file ( & manager. config_path ) . unwrap ( ) ;
324- assert ! ( loaded. spaces. get( "space-1" ) . unwrap( ) . autopilot. is_room_enabled( "room-1" ) ) ;
317+ assert ! ( loaded
318+ . spaces
319+ . get( "space-1" )
320+ . unwrap( )
321+ . autopilot
322+ . is_room_enabled( "room-1" ) ) ;
325323 }
326324
327325 #[ test]
0 commit comments