add save pattern command.

This commit is contained in:
Vixalie 2025-03-10 15:52:07 +08:00
parent d465951f31
commit d2a854490f
2 changed files with 16 additions and 1 deletions

View File

@ -143,3 +143,17 @@ pub async fn list_patterns(
.map_err(|e| errors::AppError::StorageFailure(e.to_string()))?;
Ok(patterns)
}
#[tauri::command]
pub async fn save_pattern(
app_state: State<'_, Arc<RwLock<AppState>>>,
pattern: Pattern,
) -> Result<(), errors::AppError> {
let state = app_state.read().await;
state
.db
.store_pattern(&pattern)
.await
.map_err(|e| errors::AppError::StorageFailure(e.to_string()))?;
Ok(())
}

View File

@ -65,7 +65,8 @@ pub fn run() {
cmd::activate_central_adapter,
cmd::start_scan_devices,
cmd::stop_scan_devices,
cmd::list_patterns
cmd::list_patterns,
cmd::save_pattern
])
.run(tauri::generate_context!())
.expect("error while running tauri application");