MCPcopy Create free account
hub / github.com/GCWing/BitFun / get_configs

Function get_configs

src/apps/desktop/src/api/config_api.rs:100–146  ·  view source on GitHub ↗
(
    state: State<'_, AppState>,
    startup_trace: State<'_, DesktopStartupTrace>,
    request: GetConfigsRequest,
)

Source from the content-addressed store, hash-verified

98
99#[tauri::command]
100pub async fn get_configs(
101 state: State<'_, AppState>,
102 startup_trace: State<'_, DesktopStartupTrace>,
103 request: GetConfigsRequest,
104) -> Result<BTreeMap<String, Value>, String> {
105 let config_service = &state.config_service;
106 let mut configs = BTreeMap::new();
107 let trace_started = Instant::now();
108 let trace_target = request.paths.join(",");
109
110 for path in request.paths {
111 if configs.contains_key(&path) {
112 continue;
113 }
114
115 match config_service
116 .get_config::<Value>(Some(path.as_str()))
117 .await
118 {
119 Ok(config) => {
120 configs.insert(path, config);
121 }
122 Err(e) => {
123 if request.skip_retry_on_not_found
124 && is_expected_config_path_not_found(&e, Some(path.as_str()))
125 {
126 startup_trace.record_tauri_command_elapsed(
127 "get_configs",
128 Some(&trace_target),
129 trace_started,
130 );
131 return Err(format!("Failed to get config: {}", e));
132 }
133 error!("Failed to get config: path={}, error={}", path, e);
134 startup_trace.record_tauri_command_elapsed(
135 "get_configs",
136 Some(&trace_target),
137 trace_started,
138 );
139 return Err(format!("Failed to get config: {}", e));
140 }
141 }
142 }
143
144 startup_trace.record_tauri_command_elapsed("get_configs", Some(&trace_target), trace_started);
145 Ok(configs)
146}
147
148#[cfg(test)]
149mod tests {

Callers

nothing calls this directly

Calls 5

joinMethod · 0.45
as_strMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected