Initial commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
use tauri::State;
|
||||
use crate::state::AppState;
|
||||
use dsp_thomann::dsp408::DSP408;
|
||||
use std::{net::IpAddr, str::FromStr};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn device_count(
|
||||
state: State<AppState>
|
||||
) -> usize {
|
||||
let devices = state.devices.lock().unwrap();
|
||||
devices.len()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn create_dsp408(
|
||||
state: State<AppState>,
|
||||
ip: String,
|
||||
port: u16,
|
||||
device_id: u8,
|
||||
) -> Result<usize, String> {
|
||||
|
||||
let mut devices = state
|
||||
.devices
|
||||
.lock()
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
let ip = IpAddr::from_str(&ip).map_err(|e| e.to_string())?;
|
||||
|
||||
let dsp = DSP408::new(ip, port, device_id)
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
devices.push(dsp);
|
||||
|
||||
Ok(devices.len())
|
||||
}
|
||||
Reference in New Issue
Block a user