add save pattern command.
This commit is contained in:
parent
d465951f31
commit
d2a854490f
|
@ -143,3 +143,17 @@ pub async fn list_patterns(
|
||||||
.map_err(|e| errors::AppError::StorageFailure(e.to_string()))?;
|
.map_err(|e| errors::AppError::StorageFailure(e.to_string()))?;
|
||||||
Ok(patterns)
|
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(())
|
||||||
|
}
|
||||||
|
|
|
@ -65,7 +65,8 @@ pub fn run() {
|
||||||
cmd::activate_central_adapter,
|
cmd::activate_central_adapter,
|
||||||
cmd::start_scan_devices,
|
cmd::start_scan_devices,
|
||||||
cmd::stop_scan_devices,
|
cmd::stop_scan_devices,
|
||||||
cmd::list_patterns
|
cmd::list_patterns,
|
||||||
|
cmd::save_pattern
|
||||||
])
|
])
|
||||||
.run(tauri::generate_context!())
|
.run(tauri::generate_context!())
|
||||||
.expect("error while running tauri application");
|
.expect("error while running tauri application");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user